• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Write server info to file error

Wiw3K

New Member
Joined
Apr 16, 2008
Messages
371
Reaction score
3
-edit-
Error in 3rd post.


Hiho, i have managed to add server info to Znote AAC and it works but it looks like it can get the values from socket once for five minutes.

x = number

First time or after five minutes+- i refresh page, it shows correct:

Code:
Server Online
Players: x
Uptime: xh xm

but then i refresh page or go to another sub page it changes to:
Code:
Server Online
Players:
Uptime: 0h 0m

How to fix that ? i have to add delay between updates ? or what? How to do that in php.
Thanks.
 
Last edited:
Send the request to the server, store the response in a file (or database), then compare the modified file timestamp (or last modified database column) with the current timestamp, if X minutes has passed, re-send the request and override the existing file (or database information) with the new, updated response.
 
yesterday i found possible solution before i went to bed, ok so wouldn't be better if my server creates file with variables and i just read it in php? :)

-edit-
i have written a globalevent and created script to it:

globalevent.xml
Code:
<globalevent name="serverstatus" interval="60" event="script" value="status.lua"/>

and then script named status.lua:
so the effect is that it writes to file those variables but i have an error in console everytime it writes:
Code:
> Global address: x.x.x.x
> Local ports: 7171    7172
>> All modules were loaded, server is starting up...
>> x server Online!

[Error - GlobalEvents::think] Couldn't execute event: serverstatus
[Error - GlobalEvents::think] Couldn't execute event: serverstatus
[Error - GlobalEvents::think] Couldn't execute event: serverstatus
[Error - GlobalEvents::think] Couldn't execute event: serverstatus

What is going on?
 
Last edited:
I'm not sure what is causing the event to fail, but instead of using a ton of if statements to format the hours, minutes and seconds with a leading zero, something like this should probably do:

LUA:
local lottery = string.format("%02d:%02d:%02d", hours, minutes, second)

Another thing you could do, maybe less substantial, but possible nevertheless, is to declare e.g. the time variables at the same line:

LUA:
local hours, minutes, seconds = 0, 0, 0
 
Last edited:
i have write
I'm not sure what is causing the event to fail, but instead of using a ton of if statements to format the hours, minutes and seconds with a leading zero, something like this should probably do:

LUA:
local lottery = string.format("%02d:%02d:%02d", hours, minutes, second)

Another thing you could do, maybe less substantial, but possible nevertheless, is to declare e.g. the time variables at the same line:

LUA:
local hours, minutes, seconds = 0, 0, 0
Ohh i didnt know lua supports string.format, thanks :) soo this works like charm but still i have error in my console no idea Whyy :O
Code:
[Error - GlobalEvents::think] Couldn't execute event: serverstatus

-edit-
Fixed, forgot to add return true server didnt know it passed well or what happened so gave me error :) Thanks again for helping.
 
Last edited:
Back
Top