HE
pedido

[Globalevent] Save Server

Por Helflin, 23 de jan. de 2014 em Scripts

save server
save
globalevents
save.lua
resolvido
4
1.2k
HelflinH
23 de janeiro de 2014 às 17:03

Eu tenho esse "save.lua" no globalevents, ele avisa:

 

16:55 O Server será salvo em 120 segundos, cuidado, poderá travar por alguns segundos!

16:56 O Server será salvo em 30 segundos, cuidado, poderá travar por alguns segundos!

 

 

Eu queria que ele avisasse faltando 1 segundo para dar save, tipo uma mensagem assim:

 

16:56 Server Save !!

 

 

Meu SAVE.LUA:

 

 

 

local config = {
broadcast = {120, 30},
shallow = "no",
delay = 120,
events = 30
}

config.shallow = getBooleanFromString(config.shallow)

local function executeSave(seconds)
if(isInArray(config.broadcast, seconds)) then
local text = ""
if(not config.shallow) then
text = "O"
else
text = "S"
end

text = text .. " Server será salvo em " .. seconds .. " segundos, cuidado, poderá travar por alguns segundos!"
doBroadcastMessage(text)
end

if(seconds > 0) then
addEvent(executeSave, config.events * 1000, seconds - config.events)
else
doSaveServer(config.shallow)
end
end

function onThink(interval)
if(table.maxn(config.broadcast) == 0) then
doSaveServer(config.shallow)
else
executeSave(config.delay)
end

return true
end

 

 

23 de janeiro de 2014 às 17:14

Use Assim:

 

broadcast = {1},
    shallow = "no",
    delay = 1,
}

config.shallow = getBooleanFromString(config.shallow)

local function executeSave(seconds)
    if(isInArray(config.broadcast, seconds)) then
        local text = ""
        if(not config.shallow) then
            text = "O"
        else
            text = "S"
        end

        text = text .. " Server será salvo em " .. seconds .. " segundos, cuidado, poderá travar por alguns segundos!"
        doBroadcastMessage(text)
    end

    if(seconds > 0) then
        addEvent(executeSave, config.events * 1000, seconds - config.events)
    else
        doSaveServer(config.shallow)
    end
end

function onThink(interval)
    if(table.maxn(config.broadcast) == 0) then
        doSaveServer(config.shallow)
    else
        executeSave(config.delay)
    end

    return true
end
HelflinH
23 de janeiro de 2014 às 17:26

Esse ai não funciona, deu erro, VOU USAR UM OUTRO SAVE AQUI QUE EU ACHEI.

 

 

SAVE.LUA

function saveJP()
    doSaveServer()
    doBroadcastMessage("Server saved!")
    return TRUE
end
function onThink(interval, lastExecution)
    doBroadcastMessage("Server will be saved in 1 minute!")
    addEvent(saveJP, 60000)
    return TRUE
end

Podem fechar, resolvido.

zipter98Z
23 de janeiro de 2014 às 18:17

Tópico movido para a seção de dúvidas e pedidos resolvidos.