SU
pedido

(GlobalEvents) Script "Save" sem texto.

Por Superion, 17 de nov. de 2013 em Scripts

resolvido
script
5
1.5k
SuperionS
17 de novembro de 2013 às 17:05

Bom, como eu programei no globalevents.xml pro Save ocorrer a cada 30 minutos, gostaria de retirar o texto que o Script manda na tela In-Game.

Porque para muitos, esse texto fdp atrapalha a visão. HUSAUHSA'

 

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 = "Full s"
else
text = "S"
end

text = text .. "erver save within " .. seconds .. " seconds, please mind it may freeze!"
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

 

Enfim, no aguardo.

Editado Novembro 17 por Superion

ScythePhantomS
17 de novembro de 2013 às 18:55

Bom, como eu programei no globalevents.xml pro Save ocorrer a cada 30 minutos, gostaria de retirar o texto que o Script manda na tela In-Game.

Porque para muitos, esse texto fdp atrapalha a visão. HUSAUHSA'

 

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 = "Full s"

else

text = "S"

end

 

text = text .. "erver save within " .. seconds .. " seconds, please mind it may freeze!"

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

 

Enfim, no aguardo.

 

Champz usa esse, é mais "compacto" e simples:

 

local savingEvent = 0
function onThink(interval, lastExecution, thinkInterval)
doSaveServer()
return true
end
function save(delay)
doSaveServer()
if(delay > 0) then
savingEvent = addEvent(save, delay, delay)
end
end
Tag:
<globalevent name="save" interval="1800000" event="script" value="save.lua"/>
Espero ter o ajudado.
SuperionS
17 de novembro de 2013 às 19:09

Vlw brow, funfou legal.

REP+

ScythePhantomS
17 de novembro de 2013 às 19:12

Pronto, fico feliz champz.

 

Reportado para que movam.

2 meses depois...
zipter98Z
15 de janeiro de 2014 às 21:44

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