Preciso Ajuda com Data Base Clean : ja que quizer deletar Player e Account --- so que nao podo adicionar Player_id :
so deleta Account nao Player --- Quero tene Base dato Limpia --- REP+++ Quiem poda ajudar..
Script :
Spoiler
--[[ Advanced Auto-DB Clean ]]-- --[[ tiny little part from : Automated Database Cleanup 1.1 ]]--
local c = { accounts = true , -- delete accounts that doenst contain players(same as deleting acc after the time down, as on deleting players that been inactive account will be emty so account will be deleted)
players = true, -- delete players who are inactive?(this must be enabled)
time = 60, -- in days
remove_all = true, -- remove all players data from data baase whe he is deleted?
log_File = true, -- make a log file state amount of player cleaned in every clean with their names?
print_console = true -- print amount of player and accounts deleted on each start up
}
local players = {} local names = {} function cleanPlayers() local Info = db.getResult("SELECT players.id AS id , players.name AS name FROM players WHERE players.name NOT IN ('Account Manager','Druid Sample','Knight Sample','Paladin Sample','Sorcerer Sample') AND group_id < 2 AND lastlogin > 0 AND lastlogin < UNIX_TIMESTAMP() - '".. (c.time*24*60*60) .."' ;")
if (Info:getID() ~= -1) then while true do table.insert(players, Info:getDataInt("id")) table.insert(names, Info:getDataString("name")) if not Info:next() then break end end Info:free() end if #players > 0 then db.executeQuery("DELETE FROM players WHERE players.id IN ("..table.concat(players,",")..") ;") if c.remove_all == true then db.executeQuery("DELETE FROM player_skills WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_items WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_depotitems WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_deaths WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_storage WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_killers WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_namelocks WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_spells WHERE player_id IN ("..table.concat(players,",")..") ;") db.executeQuery("DELETE FROM player_viplist WHERE player_id IN ("..table.concat(players,",")..") ;") end if c.print_console == true then print(">> [DB] : "..#players.." players have been removed for not loggin for long time.") end if c.log_File == true then doWriteLogFile("data/logs/Database clean.txt"," : "..#players.." players cleaned --> (".. table.concat(names,", ")..") \n\n ") end end
end local accounts = {} function cleanDBAcc() function getDB() local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `accounts`;") local tmp = result:getDataInt("count") result:free() return tmp end local before = getDB() local Info = db.getResult("SELECT accounts.id AS `id` FROM accounts INNER JOIN players ON accounts.id = players.account_id ;")
if (Info:getID() ~= -1) then while true do table.insert(accounts, Info:getDataInt("id")) if not Info:next() then break end end Info:free() end db.executeQuery("DELETE FROM accounts WHERE accounts.id NOT IN("..table.concat(accounts,",")..");") local new = before - getDB() if c.print_console == true then if new > 0 then if c.print_console == true then print("\n>>>>[DB] : "..new.." Accounts were deleted\n") end if c.log_File == true then doWriteLogFile("data/logs/Database clean.txt"," : "..new.." accounts cleaned \n\n ") end end end return true end function onStartup() cleanPlayers() if c.accounts == true then cleanDBAcc() end return true end
Pergunta
Neo Sonny 0
Preciso Ajuda com Data Base Clean : ja que quizer deletar Player e Account --- so que nao podo adicionar Player_id :
so deleta Account nao Player --- Quero tene Base dato Limpia --- REP+++ Quiem poda ajudar..
Script :
--[[ Advanced Auto-DB Clean ]]--
--[[ tiny little part from : Automated Database Cleanup 1.1 ]]--
local c = {
accounts = true , -- delete accounts that doenst contain players(same as deleting acc after the time down, as on deleting players that been inactive account will be emty so account will be deleted)
players = true, -- delete players who are inactive?(this must be enabled)
time = 60, -- in days
remove_all = true, -- remove all players data from data baase whe he is deleted?
log_File = true, -- make a log file state amount of player cleaned in every clean with their names?
print_console = true -- print amount of player and accounts deleted on each start up
}
local players = {}
local names = {}
function cleanPlayers()
local Info = db.getResult("SELECT players.id AS id , players.name AS name FROM players WHERE players.name NOT IN ('Account Manager','Druid Sample','Knight Sample','Paladin Sample','Sorcerer Sample') AND group_id < 2 AND lastlogin > 0 AND lastlogin < UNIX_TIMESTAMP() - '".. (c.time*24*60*60) .."' ;")
if (Info:getID() ~= -1) then
while true do
table.insert(players, Info:getDataInt("id"))
table.insert(names, Info:getDataString("name"))
if not Info:next() then
break
end
end
Info:free()
end
if #players > 0 then
db.executeQuery("DELETE FROM players WHERE players.id IN ("..table.concat(players,",")..") ;")
if c.remove_all == true then
db.executeQuery("DELETE FROM player_skills WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_items WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_depotitems WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_deaths WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_storage WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_killers WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_namelocks WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_spells WHERE player_id IN ("..table.concat(players,",")..") ;")
db.executeQuery("DELETE FROM player_viplist WHERE player_id IN ("..table.concat(players,",")..") ;")
end
if c.print_console == true then
print(">> [DB] : "..#players.." players have been removed for not loggin for long time.")
end
if c.log_File == true then
doWriteLogFile("data/logs/Database clean.txt"," : "..#players.." players cleaned --> (".. table.concat(names,", ")..") \n\n ")
end
end
end
local accounts = {}
function cleanDBAcc()
function getDB()
local result = db.getResult("SELECT COUNT(`id`) as `count` FROM `accounts`;")
local tmp = result:getDataInt("count")
result:free()
return tmp
end
local before = getDB()
local Info = db.getResult("SELECT accounts.id AS `id` FROM accounts INNER JOIN players ON accounts.id = players.account_id ;")
if (Info:getID() ~= -1) then
while true do
table.insert(accounts, Info:getDataInt("id"))
if not Info:next() then
break
end
end
Info:free()
end
db.executeQuery("DELETE FROM accounts WHERE accounts.id NOT IN("..table.concat(accounts,",")..");")
local new = before - getDB()
if c.print_console == true then
if new > 0 then
if c.print_console == true then
print("\n>>>>[DB] : "..new.." Accounts were deleted\n")
end
if c.log_File == true then
doWriteLogFile("data/logs/Database clean.txt"," : "..new.." accounts cleaned \n\n ")
end
end
end
return true
end
function onStartup()
cleanPlayers()
if c.accounts == true then
cleanDBAcc()
end
return true
end
Gloval Event - :
<globalevent name="db" type="startup" event="script" value="dbclean.lua"/>
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados