• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    Mantener la base de datos limpio

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1Mantener la base de datos limpio Empty Mantener la base de datos limpio Miér Dic 16, 2015 1:33 pm

    Krapula

    Krapula
    Miembro
    Miembro
    Buenas amigos aqui les muestro 1 pegueño script para mantener nuestras bases de datos limpias configurables no eh podido testear xq la acabo de instalar asi q mañana les digo si funicono o no Very Happy

    Primero vamos a Globalevent.xml y colocan esto adentro
    Código:
     <globalevent name="db" type="startup" event="script" value="db.lua"/>

    Luego van a Globalevent/script copian cualquier archivo le cambian el nombre x "db"

    y colocan esto dentro

    Código:
    --[[ Advanced Auto-DB Clean By >>Doggynub<< ]]--
    --[[ tiny little part from : Automated Database Cleanup 1.1 //By Cybermaster ]]--
    -- [[ credits for a better loop through database get result to :SpiderOt ]] --

    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 = 45, -- 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

    Agradecimiento a Doggynub

    Mantener la base de datos limpio 29vjnnd
    TIBIAFACE



    Última edición por Krapula el Lun Dic 21, 2015 2:53 am, editado 2 veces

    3 participantes
    https://www.facebook.com

    2Mantener la base de datos limpio Empty Re: Mantener la base de datos limpio Miér Dic 16, 2015 2:42 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    buen aporte +1 :(MG):



    Mantener la base de datos limpio YNU5B25
    3 participantes
    http://www.tibiaface.com

    3Mantener la base de datos limpio Empty Re: Mantener la base de datos limpio Miér Dic 16, 2015 9:32 pm

    Juan Carlos

    Juan Carlos
    Miembro
    Miembro
    Ahhh provar Wink gracias por el aporte

    3 participantes
    http://dybbuk.jimdo.com/

    4Mantener la base de datos limpio Empty Re: Mantener la base de datos limpio Dom Dic 20, 2015 9:21 pm

    Krapula

    Krapula
    Miembro
    Miembro
    Yo les dije q no podia ver si funcionaba xq estaba comenzado pero encontre otra base de datos que tenia guardada y le puse el script y funciona

    Mantener la base de datos limpio 2vuatxk

    3 participantes
    https://www.facebook.com

    Contenido patrocinado


    3 participantes

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).