• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Script Problem - Help [TFS 1.0]

Sweveh

New Member
Joined
Mar 26, 2014
Messages
38
Reaction score
3
Otlanders, I've got a problem with the "Save script" a script that basically should autosave each 30m, using the script from (Printers Datapack).

I recieve this error:
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface : : luaAddEvent(). callback parameter should be a function.
stack traceback:
              [C]: in function 'addEvent'
              data/globalevent/scripts/save.lua:2 in function <data/scripts/save.lua:1>

Script:
Code:
local function executeSave1(save1)
    addEvent(executeSave, 1*1000, save)
    broadcastMessage("The server is now saving, please be patient.", MESSAGE_EVENT_ADVANCE)
end

local function executeSave(save)
    saveServer()
end

function onThink(interval)
    broadcastMessage("Server save within 30 seconds, please mind it may freeze!", MESSAGE_EVENT_ADVANCE)
    addEvent(executeSave1, 30*1000, save1)
    return true
end
 
Code:
local function executeSave(save)
    saveServer()
end

local function executeSave1(save1)
    addEvent(executeSave, 1*1000, save)
    broadcastMessage("The server is now saving, please be patient.", MESSAGE_EVENT_ADVANCE)
end

function onThink(interval)
    broadcastMessage("Server save within 30 seconds, please mind it may freeze!", MESSAGE_EVENT_ADVANCE)
    addEvent(executeSave1, 30*1000, save1)
    return true
end

I guess you know that variables save1 and save are always nil here.
 
Maybe it helps

globalevents.xml

Code:
<globalevent name="Server Save" interval="1800" script="serversave.lua"/>

Code:
local shutdownAtServerSave = false
local cleanMapAtServerSave = true

local function serverSave()
  if shutdownAtServerSave then
  Game.setGameState(GAME_STATE_SHUTDOWN)
  end
  if cleanMapAtServerSave then
  cleanMap()
  end
  saveServer()
end

local function secondServerSaveWarning()
  broadcastMessage("Server is saving game in one minute. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
  broadcastMessage("Server is saving game in 3 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  addEvent(secondServerSaveWarning, 120000)
end

function onThink(interval)
  broadcastMessage("Server is saving game in 5 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  Game.setGameState(GAME_STATE_STARTUP)
  addEvent(firstServerSaveWarning, 120000)
  return not shutdownAtServerSave
end


EDIT: Ow sorry you wanted it every 30mins :eek:
 
Last edited:
I guess you know that variables save1 and save are always nil here.

Thanks for the help but now I get another error:
vqbyto.jpg
 
Last edited:
Try this if you use latest TFS 1.0 it should work.

Every 25min's Broadcast a Message "Server save in 5min" and every 27min "Server Save in 3min" and at 30min "Server is saving game."

Globalevents.lua

Code:
 <globalevent name="Server Save" interval="1500000" script="save.lua"/>



C:\Server\data\globalevents\scripts/save.lua

Code:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
  if shutdownAtServerSave then
  Game.setGameState(GAME_STATE_SHUTDOWN)
  end
  if cleanMapAtServerSave then
  cleanMap()
  end
  saveServer()
end

local function secondServerSaveWarning()
  broadcastMessage("Server is saving game in one minute. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
  broadcastMessage("Server is saving game in 3 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  addEvent(secondServerSaveWarning, 120000)
end

function onThink(interval)
  broadcastMessage("Server is saving game in 5 minutes. Please go to a safe place.", MESSAGE_STATUS_WARNING)
  Game.setGameState(GAME_STATE_STARTUP)
  addEvent(firstServerSaveWarning, 120000)
  return not shutdownAtServerSave
end


(Currently Testing it takes 30min) for serious testing^^

If not just playaround with interval (millsecound)
 
Last edited:
Try this if you use latest TFS 1.0 it should work.

Every 25min's Broadcast a Message "Server save in 5min" and every 27min "Server Save in 3min" and at 30min "Server is saving game."

C:\Server\data\globalevents\scripts/save.lua

(Currently Testing it takes 30min) for serious testing^^

If not just playaround with interval (millsecound)

Thanks for you're efforts but I want a script that saves each 30 minutes not a full globalserversave ;x
 
What this script saves every 30min dont know what you mean xD

And the script you posted up is the same globalevent oO

@EvilSkillz maybe you can help out here^^




EDIT: Work's. Just need's some change's at interval.

Proof:

2jewm6b.jpg
 
Last edited:
Try changing the order of the functions - put executeSave() before executeSave1().

I think (not 100% sure) that Lua uses a single-pass parse - that would generate the kind of parser message you posted.


PS: I tested on standalone Lua - 99% certain this is your problem.
 
Last edited:
EDIT: Work's. Just need's some change's at interval.

Proof:

Try to login during this time, wont allow you to. 0-5 minutes

Try changing the order of the functions - put executeSave() before executeSave1().

I think (not 100% sure) that Lua uses a single-pass parse - that would generate the kind of parser message you posted.


PS: I tested on standalone Lua - 99% certain this is your problem.

Tried it, does not work. Thanks anyway!
 
Last edited:
yep just remove this line:
Code:
 Game.setGameState(GAME_STATE_STARTUP)


Should work than.


But you should leave it as it is because, if someone logs in at Server Save, can cause more lags and isn't that good at all.
 
yep just remove this line:
Code:
 Game.setGameState(GAME_STATE_STARTUP)


Should work than.


But you should leave it as it is because, if someone logs in at Server Save, can cause more lags and isn't that good at all.
Which is also another reason why I want another script.
 
Than just remove it, i guess there is no other Version of this kind of Script or just Request one, maybe a better scripter can do it.
I'am not scripting that much :eek:
 
What script are you using now?

And what message(s) are you getting?

This script:
Code:
local function executeSave(save)
    saveServer()
end

local function executeSave1(save1)
    addEvent(executeSave, 1*1000, save)
    broadcastMessage("The server is now saving, please be patient.", MESSAGE_EVENT_ADVANCE)
end

function onThink(interval)
    broadcastMessage("Server save within 30 seconds, please mind it may freeze!", MESSAGE_EVENT_ADVANCE)
    addEvent(executeSave1, 30*1000, save1)
    return true
end
Errors:
vqbyto.jpg
 
That's a new one for me - my bad though - I see you posted it earlier

Stack overflow usually means you're looping and ran out of an internal resource, though I can't be sure here.

It's in saveServer(), not the code you posted.

"[C ] in function '--index'" suggests saveServer() is Lua code.

If I was betting I'd go with it looping through a table, and the "stopping rule" for the loop isn't doing its job :)

Anyway check that it's Lua, and post the code here. BTW I think we're getting close now :)

-----------

Update: here's something else to check from a new support post:
http://otland.net/threads/globalevent-spam-on-server-start.212482/

If you've used a config value from an earlier OT version you might have asked for several thousand saves. Or not ... but it will only take a few seconds to check.
 
Last edited:
Back
Top