CLEAN AUTOMÁTICO
data/globalevents/scripts/clean.lua
function executeClean(interval)
doCleanMap()
doBroadcastMessage("Game map cleaned, next clean in " .. table.concat(string.timediff(interval / 1000)) .. ".")
return true
end
function onThink(interval)
doBroadcastMessage("Game map cleaning within 30 seconds, please pick up your items!")
addEvent(executeClean, 240000, interval)
return true
end
globalevents.xml
<globalevent name="clean" interval="7200000" event="script" value="clean.lua"/>
SAVE AUTOMÁTICO
globalevents/scripts/save.lua
local config = {
broadcast = {120, 30},
flags = 13,
delay = 120,
events = 30
}
local function executeSave(seconds)
if(isInArray(config.broadcast, seconds)) then
doBroadcastMessage("Server save within " .. seconds .. " seconds, please mind it may freeze!")
end
if(seconds > 0) then
addEvent(executeSave, config.events * 1000, seconds - config.events)
else
doSaveServer(config.flags)
end
end
function onThink(interval)
if(table.maxn(config.broadcast) == 0) then
doSaveServer(config.flags)
else
executeSave(config.delay)
end
return true
end
globalevents.xml
<globalevent name="save" interval="900000" event="script" value="save.lua"/>
SAVE POR COMANDO
talkactions/scripts/save.lua
local savingEvent = 0
function onSay(cid, words, param, channel)
local tmp = tonumber(param)
if(tmp ~= nil) then
stopEvent(savingEvent)
save(tmp * 60 * 1000)
elseif(param:trim() == '') then
doSaveServer(13)
else
local tid = getPlayerByNameWildcard(param)
if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
else
doPlayerSave(tid)
end
end
return true
end
function save(delay)
doSaveServer(13)
if(delay > 0) then
savingEvent = addEvent(save, delay, delay)
end
end
talkactions.xml
<talkaction log="yes" group="4" access="3" words="/save" event="script" value="save.lua"/>