The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
f_onserver_timer
Author Message
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #1
f_onserver_timer
sphere.ini:

Code:
// Amount of minutes to call f_onserver_timer (0 disables this, default)
TimerCall=10

spheretriggers:

Code:
[FUNCTION f_onserver_timer]

LOCAL.TODAY = <serv.rtime.format %w>
LOCAL.HOUR  = <serv.rtime.format %H>

IF (<LOCAL.HOUR> == 13)
SERV.B TEST_TEST_TEST
ENDIF

This works, but multiply times on server time 13:00. (like 13:12, 13:45, 13:25)...

The time seems to be pretty random too.
The message came after 12, 13 and 15 minutes more or less, never exactly 10 minutes as stated on the .ini

I want this to make some functions automated on the server.
Can someone help me to improve this?

I would like it to be at some exact time, but no clue on how to do that.

Thanks everyone!
11-22-2013 12:40 AM
Find all posts by this user Like Post Quote this message in a reply
Runcuks
Journeyman
*

Posts: 179
Likes Given: 5
Likes Received: 3 in 3 posts
Joined: Nov 2012
Reputation: 0



Post: #2
RE: f_onserver_timer
try to set TimerCall=1 and than test, becouse if you start server for example 12:58, it will trigger only at 13:08 maybe that could solve your problem ^^
11-22-2013 03:13 AM
Find all posts by this user Like Post Quote this message in a reply
pinku
Journeyman
*

Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4



Post: #3
RE: f_onserver_timer
This way I would get messages every minute, according to what I posted.. (13:01, 13:02, 13:03...)
That's not exactly what I am looking for. haha

Thanks anyway!
11-22-2013 04:26 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #4
RE: f_onserver_timer
The server itself does not run according to a real-time clock... it uses its own timekeeping system called "ticks". Sometimes a tick takes a long time, sometimes short, which explains why it doesn't follow the real-time clock very closely. In the sphere ini file there are a bunch of settings that are described as "time it takes (in seconds) for..." In reality, those are all measured in "ticks" not "seconds".

The ONLY functions in the server that are aware of the real-time clock are RTICKS and RTIME:

RTICKS (Returns the real-world time, as a timestamp.)
RTIME (Returns the real-world time, as a formatted string.)

So if you need to time things in your game to a real-time clock, you need to use a scheduled timer (either f_onserver_timer or a TIMERF function - both of which are based on "ticks") and in your function, test the real-time clock and adapt accordingly depending on the precision you want.
11-22-2013 05:10 AM
Find all posts by this user Like Post Quote this message in a reply
[+] 2 users Like RanXerox's post
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)