FE

Serve Save

Por felipejf, 21 de fev. de 2012 em Scripts

10
1.7k
felipejfF
21 de fevereiro de 2012 às 16:09

Utilizo esse serve save aqui:

 

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 = "[Auto Save]"

else

text = "O"

end

text = text .. " Serve irá salvar em " .. seconds .. " segundos, porfavor aguarde!"

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

 

 

 

Queria duas coisa em mudar nele:

A primeira é colocar apos ele salvar os dados mandar uma mensagem escrito: [Auto Save] Dados salvo com sucesso!

E a segunda e colocar ele para salvar a cada 5 horas.

Editado Fevereiro 21 por Felipejf

ZmovirZ
21 de fevereiro de 2012 às 16:44
local config = {

broadcast = "no"

}

 

config.broadcast = getBooleanFromString(config.broadcast)

local function executeSave(seconds)

if(seconds == 0) then

doSaveServer()

return true

end

 

if(seconds == 120 or seconds == 30) then

doBroadcastMessage("[AVISO] Server ira salver daki " .. seconds .. " segundos, por favor fique em local seguro!")

end

 

seconds = seconds - 30

if(seconds >= 0) then

addEvent(executeSave, 30 * 1000, seconds)

doBroadcastMessage("[AVISO] Servidor salvado com sucesso!")

end

end

 

function onThink(interval, lastExecution, thinkInterval)

if(not config.broadcast) then

doSaveServer()

return true

end

 

executeSave(120)

return true

end

tenta esse mano nao deu tempo de testar
felipejfF
21 de fevereiro de 2012 às 19:03

Não funciono, ele nem manda a msg tb.

ZmovirZ
21 de fevereiro de 2012 às 21:20

Tente esse

 

function executeSave()

doSaveServer()

doBroadcastMessage("[AUTO MESSAGE] Server salvo.")

return true

end

 

function onThink(interval, lastExecution, thinkInterval)

doBroadcastMessage("[AUTO MESSAGE] Server vai ser salvo")

addEvent(executeSave, 30000)

return true

end

 

ou esse

 

function executeSave(seconds)

doSaveServer()

doBroadcastMessage("[AUTO MESSAGE] Server salvo.")

return true

end

 

function onThink(interval, lastExecution, thinkInterval)

doBroadcastMessage("[AUTO MESSAGE] Save server daki " .. seconds .. " segundos, ")

addEvent(executeSave, 30 * 1000, seconds)

return true

end

Editado Fevereiro 21 por Zmovir

felipejfF
22 de fevereiro de 2012 às 22:15

Também não deu, queria mesmo mudar aquele script que postei.

ZmovirZ
22 de fevereiro de 2012 às 23:21

Ultimata tentativa tenta esse aki

 

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 = "[Auto Save]"

else

text = "O"

end

text = text .. " Serve irá salvar em " .. seconds .. " segundos, porfavor aguarde!"

doBroadcastMessage(text)

end

if(seconds > 0) then

addEvent(executeSave, config.events * 1000, seconds - config.events)

else

doSaveServer(config.shallow)

doBroadcastMessage("[AVISO] Servidor salvado com sucesso!")

end

end

function onThink(interval)

if(table.maxn(config.broadcast) == 0) then

doSaveServer(config.shallow)

else

executeSave(config.delay)

end

 

return true

end

jhon992J
26 de fevereiro de 2012 às 13:06

local config = {
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 = "[Auto Save]"
else
text = "O"
end
text = text .. " Serve irá salvar em " .. seconds .. " segundos, porfavor aguarde!"
doBroadcastMessage(text)
end
if(seconds > 0) then
addEvent(executeSave, config.events * 1000, seconds - config.events)
else
doSaveServer(config.shallow)
addEvent(doBroadcastMessage, 3000, "[Auto Save] Dados salvo com sucesso!")
end
end

function onThink(interval)
if(table.maxn(config.broadcast) == 0) then
doSaveServer(config.shallow)
addEvent(doBroadcastMessage, 3000, "[Auto Save] Dados salvo com sucesso!")
else
executeSave(config.delay)
end

return true
end

 

Esse /\ éh pra aparecer a msg e para salvar a cada 5 hras, altera no globalevents.xml:

<globalevent name="save" interval="18000" event="script" value="save.lua"/>

Editado Fevereiro 26 por Jhon992

felipejfF
26 de fevereiro de 2012 às 14:59

Irei testar aqui, jaja edito.

 

EDIT

 

Funcionado perfeitamente, so que ele manda o [Auto Save] Dados salvo com sucesso! antes de da o save. É possível colocar apos o save?

 

Obrigado.

Editado Fevereiro 26 por Felipejf

jhon992J
26 de fevereiro de 2012 às 17:41

Editei ali em cima, vai mandar a msg após 3 segundos depois que o salve começa a ser executado, se quiser mais segundos troque o "3000" por +.

felipejfF
26 de fevereiro de 2012 às 18:24

Obrigado.