WA
erro

Ajuda ERRO DB cleanner sqile

Por warriorfrog, 24 de set. de 2013 em Scripts

resolvido
script
23
1.8k
warriorfrogW
24 de setembro de 2013 às 20:26

Achei um DB Cleanner pra SQILE, mas ta dando erro ao iniciar, preciso muito desse script, alguem sabe como arrumar?

 

Erro:

 


[Error - GlobalEvent Interface]
data/globalevents/scripts/dbclean.lua:onStartup
field 'time' <a nil value>
stack traceback
data/globalevents/scripts/dbclean.lua:24: in function <data/globalevents/scripts/dbclean.lua:11>

 

Script:

 


<globalevent name="dbclean" type="start" event="script" value="dbclean.lua"/>

 

 


-- [[> Automated Database Cleanup 1.1 //By Cybermaster <]] --
-- [[> Function getDBPlayersCount() by Elf <]] --

function getDBPlayersCount()
local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `players`;")
local tmp = result:getDataInt("count")
result:free()
return tmp
end

function onStartup()
local DB_BEFORE = getDBPlayersCount()

--In each table, players with below specified level, and days of inactivity will be deleted from db on server startup
local cleanup = {
[1] = {level = 11, time = 5 * 24 * 60 * 60},
[2] = {level = 50, time = 15 * 24 * 60 * 60},
[3] = {level = 100, time = 30 * 24 * 60 * 60},
[4] = {level = 200, time = 60 * 24 * 60 * 60},
[5] = {level = 300, time = 90 * 24 * 60 * 60}
}

for i = 1, #cleanup do
db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup.level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < UNIX_TIMESTAMP() - ".. cleanup.time ..";")
end

local DB_NOW = DB_BEFORE - getDBPlayersCount()
if DB_NOW > 0 then
local text = ">> [DBCLEANUP] "..DB_NOW.." inactive players have been deleted from database."
print("" .. text .. "")
local file = io.open("data/logs/db_cleanup.txt", "a")
file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")
file:close()
end
return true
end

ikaroangeloI
24 de setembro de 2013 às 20:53


Mano tem uma talkaction se não me engano e do datapack do emporia da vapus, vou tentar postar aqui para você que com ela da para você executar query in game, num sei se vai rular em SQLite:

 

Em talkactions adicione:

 

<talkaction log="yes" words="/dbquery" access="6" script="dbquery.lua"/>

 

 

crie o arquivo dbquery.lua com o codigo:

 

function onSay(cid, words, param)

 

db.executeQuery(param)

 

return TRUE

end

 

 

Assim você tenta in-game:

/dbquery QUERY CODE

luccagomesL
24 de setembro de 2013 às 21:53

@ikaro isso é mysql

VodkartV
24 de setembro de 2013 às 22:05

 

-- [[> Automated Database Cleanup 1.1 //By Cybermaster <]] --
-- [[> Function getDBPlayersCount() by Elf <]] --
 
function getDBPlayersCount()
local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `players`;")
local tmp = result:getDataInt("count")
result:free()
return tmp
end
 
function onStartup()
local DB_BEFORE = getDBPlayersCount()
 
--In each table, players with below specified level, and days of inactivity will be deleted from db on server startup
local cleanup = {
[1] = {level = 11, time = 5 * 24 * 60 * 60},
[2] = {level = 50, time = 15 * 24 * 60 * 60},
[3] = {level = 100, time = 30 * 24 * 60 * 60},
[4] = {level = 200, time = 60 * 24 * 60 * 60},
[5] = {level = 300, time = 90 * 24 * 60 * 60}
}
 
for i = 1, #cleanup do
db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup[i].level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < UNIX_TIMESTAMP() - ".. cleanup[i].time ..";")
end
 
local DB_NOW = DB_BEFORE - getDBPlayersCount()
if DB_NOW > 0 then
local text = ">> [DBCLEANUP] "..DB_NOW.." inactive players have been deleted from database."
print("" .. text .. "")
local file = io.open("data/logs/db_cleanup.txt", "a")
file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")
file:close()
end
return true
end
warriorfrogW
25 de setembro de 2013 às 00:38

Vodkart te dei +rep, mas qnd eu inicie deu erro!
http://imgur.com/OMlYrBO

VodkartV
25 de setembro de 2013 às 07:07
UNIX_TIMESTAMP()
por
os.time()

ficando assim:

 

 

-- [[> Automated Database Cleanup 1.1 //By Cybermaster <]] --
-- [[> Function getDBPlayersCount() by Elf <]] --
 
function getDBPlayersCount()
local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `players`;")
local tmp = result:getDataInt("count")
result:free()
return tmp
end
 
function onStartup()
local DB_BEFORE = getDBPlayersCount()
 
--In each table, players with below specified level, and days of inactivity will be deleted from db on server startup
local cleanup = {
[1] = {level = 11, time = 5 * 24 * 60 * 60},
[2] = {level = 50, time = 15 * 24 * 60 * 60},
[3] = {level = 100, time = 30 * 24 * 60 * 60},
[4] = {level = 200, time = 60 * 24 * 60 * 60},
[5] = {level = 300, time = 90 * 24 * 60 * 60}
}
 
for i = 1, #cleanup do
db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup[i].level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < os.time() - ".. cleanup[i].time ..";")
end
 
local DB_NOW = DB_BEFORE - getDBPlayersCount()
if DB_NOW > 0 then
local text = ">> [DBCLEANUP] "..DB_NOW.." inactive players have been deleted from database."
print("" .. text .. "")
local file = io.open("data/logs/db_cleanup.txt", "a")
file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")
file:close()
end
return true
end

Editado Setembro 25 por Vodkart

SeagullS
25 de setembro de 2013 às 07:17

Vodkart desculpa da spam aqui, mas não consegui te manda mensagem pode me ajudar em um script?

warriorfrogW
25 de setembro de 2013 às 13:01

Aff n pegou pffvr me ajudem, falta só isso pra terminar meu sv!

outros erros

http://imgur.com/YSDUuVS

Editado Setembro 25 por warriorfrog

VodkartV
25 de setembro de 2013 às 14:36


function onStartup()

local count,cleanup = 0, {

{level = 11, time = 5 * 24 * 60 * 60},

{level = 50, time = 15 * 24 * 60 * 60},

{level = 100, time = 30 * 24 * 60 * 60},

{level = 200, time = 60 * 24 * 60 * 60},

{level = 300, time = 90 * 24 * 60 * 60}

}

for i = 1, #cleanup do

if db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup.level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < "..os.time() - cleanup.time) then

count = count + 1

end

end

if count > 0 then

local text = ">> [DBCLEANUP] "..count.." inactive players have been deleted from database."

print("" .. text .. "")

local file = io.open("data/logs/db_cleanup.txt", "a")

file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")

file:close()

end

return true

end

Editado Setembro 25 por Vodkart

warriorfrogW
25 de setembro de 2013 às 22:21

ta dando só mais um erro, mas funcionou! Q isso?

+outro rep

 

http://imgur.com/k0lg0nk

 

E toda vez q eu fecho e abro o ot diz q deletou 4, mas acho q n ta deletando é nada

Editado Setembro 26 por warriorfrog

VodkartV
26 de setembro de 2013 às 06:59

é porque tem jogadores que são donos de guild, ai teria que deletar a guild antes para depois deletar o player...

 

quando eu tiver um tempinho eu faço esse script para deletar guild, house e o player

warriorfrogW
26 de setembro de 2013 às 12:18

Aguardando então, vai ajudar muito e muita gente, mas eu acho q n ta dando certo pq toda vez q abre e fecha são deletadas 4 contas (toda vez msm) sendo q só tem 2 guilds no sve uns 10 players pq ta em testes, mas talvez seja pro causa da guild msm, to aguardando anciosamente, só falta isso pra eu abrir o sv

jowteiJ
26 de setembro de 2013 às 12:29

 

Achei um DB Cleanner pra SQILE, mas ta dando erro ao iniciar, preciso muito desse script, alguem sabe como arrumar?

 

Erro:

 

[Error - GlobalEvent Interface]

data/globalevents/scripts/dbclean.lua:onStartup

field 'time' <a nil value>

stack traceback

data/globalevents/scripts/dbclean.lua:24: in function <data/globalevents/scripts/dbclean.lua:11>

 

Script:

 

<globalevent name="dbclean" type="start" event="script" value="dbclean.lua"/>

 

 

-- [[> Automated Database Cleanup 1.1 //By Cybermaster <]] --

-- [[> Function getDBPlayersCount() by Elf <]] --

 

function getDBPlayersCount()

local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `players`;")

local tmp = result:getDataInt("count")

result:free()

return tmp

end

 

function onStartup()

local DB_BEFORE = getDBPlayersCount()

 

--In each table, players with below specified level, and days of inactivity will be deleted from db on server startup

local cleanup = {

[1] = {level = 11, time = 5 * 24 * 60 * 60},

[2] = {level = 50, time = 15 * 24 * 60 * 60},

[3] = {level = 100, time = 30 * 24 * 60 * 60},

[4] = {level = 200, time = 60 * 24 * 60 * 60},

[5] = {level = 300, time = 90 * 24 * 60 * 60}

}

 

for i = 1, #cleanup do

db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup.level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < UNIX_TIMESTAMP() - ".. cleanup.time ..";")

end

 

local DB_NOW = DB_BEFORE - getDBPlayersCount()

if DB_NOW > 0 then

local text = ">> [DBCLEANUP] "..DB_NOW.." inactive players have been deleted from database."

print("" .. text .. "")

local file = io.open("data/logs/db_cleanup.txt", "a")

file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")

file:close()

end

return true

end

 

Eu, Deus e o mundo, aguarda o VODKART FAZER ESSE SCRIPT ! õ/

VodkartV
26 de setembro de 2013 às 14:01

Aguardando então, vai ajudar muito e muita gente, mas eu acho q n ta dando certo pq toda vez q abre e fecha são deletadas 4 contas (toda vez msm) sendo q só tem 2 guilds no sve uns 10 players pq ta em testes, mas talvez seja pro causa da guild msm, to aguardando anciosamente, só falta isso pra eu abrir o sv

 

não, ese de aparecer somente 4 é eu q fiz besteira kkkk

mas deleta as demais conta...

 

tenta assim pra ve se vai aparecer só 4 de novo:

 

 

function onStartup()
function getDBPlayersCount()
local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `players`;")
local tmp = result:getDataInt("count")
result:free()
return tmp
end
local DB_BEFORE = getDBPlayersCount()
local cleanup = {
{level = 11, time = 5 * 24 * 60 * 60},
{level = 50, time = 15 * 24 * 60 * 60},
{level = 100, time = 30 * 24 * 60 * 60},
{level = 200, time = 60 * 24 * 60 * 60},
{level = 300, time = 90 * 24 * 60 * 60}
}
for i = 1, #cleanup do
db.executeQuery("DELETE FROM `players` WHERE `level` < ".. cleanup[i].level .." AND `id` > 6 AND `group_id` < 2 AND `lastlogin` < "..os.time() - cleanup[i].time)
end 
local DB_NOW = DB_BEFORE - getDBPlayersCount()
if DB_NOW > 0 then
local text = ">> [DBCLEANUP] "..DB_NOW.." inactive players have been deleted from database."
print("" .. text .. "")
local file = io.open("data/logs/db_cleanup.txt", "a")
file:write("\n[".. os.date("%d %B %Y %X ", os.time()) .."] "..text.."")
file:close()
end
return true
end
davidjohsonD
27 de setembro de 2013 às 02:06

Parece q dps q eu usei isso ai bugou o account mananger foi logo dps disso, qnd eu logo no acc mananger ela loga normalmente no 0/0, agora qnd eu entro na minha conta e tento acessar o account mananger da password incorrect