Skip to content

Instantly share code, notes, and snippets.

@Marahin
Created January 12, 2016 14:58
Show Gist options
  • Save Marahin/fa191088209bb5c4bd4a to your computer and use it in GitHub Desktop.
Save Marahin/fa191088209bb5c4bd4a to your computer and use it in GitHub Desktop.
[Warning - Event::checkScript] Event onThink not found. scripts/serversave.lua
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
<globalevent type="startup" name="ServerStartup" script="startup.lua" />
<globalevent type="record" name="PlayerRecord" script="record.lua" />
<globalevent name="Server Save" interval="3600000" script="serversave.lua" />
<!--
<globalevent name="timer_example" time="12:00:00" script="my_script.lua" />
-->
</globalevents>
local shutdownAtServerSave = false
local cleanMapAtServerSave = true
local function serverSave()
if shutdownAtServerSave then
Game.setGameState(GAME_STATE_SHUTDOWN)
else
Game.setGameState(GAME_STATE_CLOSED)
if cleanMapAtServerSave then
cleanMap()
end
Game.setGameState(GAME_STATE_NORMAL)
end
end
local function secondServerSaveWarning()
broadcastMessage("Zapis stanu gry oraz czyszczenie za minute. Prosimy o wylogowanie sie w bezpiecznym miejscu.", MESSAGE_STATUS_WARNING)
addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
broadcastMessage("Zapis stanu gry oraz czyszczenie mapy za trzy minuty. Prosimy o wylogowanie sie w bezpiecznym miejscu.", MESSAGE_STATUS_WARNING)
addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
broadcastMessage("Za 5 minut nastapi zapis stanu gry. Prosimy o przejscie do bezpiecznego miejsca i wylogowanie sie.", MESSAGE_STATUS_WARNING)
Game.setGameState(GAME_STATE_STARTUP)
addEvent(firstServerSaveWarning, 120000)
return not shutdownAtServerSave
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment