Ir para conteúdo
  • 0

Ajuda ERRO DB cleanner sqile


warriorfrog

Pergunta

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

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0


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

Link para o comentário
Compartilhar em outros sites

  • 0

 

-- [[> 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
Link para o comentário
Compartilhar em outros sites

  • 0
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 por Vodkart
Link para o comentário
Compartilhar em outros sites

  • 0


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 por Vodkart
Link para o comentário
Compartilhar em outros sites

  • 0

é 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

Link para o comentário
Compartilhar em outros sites

  • 0

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

Link para o comentário
Compartilhar em outros sites

  • 0

 

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 ! õ/

Link para o comentário
Compartilhar em outros sites

  • 0

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
Link para o comentário
Compartilhar em outros sites

  • 0

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

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...