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
timerf instead of i_memory
Author Message
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #1
timerf instead of i_memory
Hello. Earlier i used old method to put timer to NPC or character, for example, i was creating memory item

[ITEMDEF i_action_timer]
id=i_memory
type=t_eq_script
name=timer

ON=@Timer
bla bla bla

so by that way i need to add new item to script, and add that item to character, to control his actions by timer. But now i found easier way. I can just write 1 function like

[FUNCTION f_action_timer]
bla bla bla
timerf 1, f_action_timer

and can loop that function. I just checked it on NPC and function seems no longer exists if NPC removed, so, seems it's ok. And now here is question - is it safe and ok to use loops of those timerf functions instead of old way with i_memory object?
09-10-2015 03:33 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: timerf instead of i_memory
Main difference between a timer item and timerf is that the former stops when a player logs out (or the sector that contains the npc goes in sleep mode).
09-10-2015 08:12 PM
Find all posts by this user Like Post Quote this message in a reply
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #3
RE: timerf instead of i_memory
You mean item timer stops, but timerf continues working? I just not sure how works 'stack' for those timerf functions. For items it's more controllable. You can see item, etc., but timerf function hovering somewhere in memory and can't see it or 'touch', and don't know how much of those timerf functions can work at same time Smile
09-10-2015 11:27 PM
Find all posts by this user Like Post Quote this message in a reply
azmanomer
Journeyman
*

Posts: 139
Likes Given: 4
Likes Received: 18 in 16 posts
Joined: Nov 2013
Reputation: 1



Post: #4
RE: timerf instead of i_memory
TIMERF CLEAR
TIMERF STOP, function
ISTIMERF.function - Returns the number of seconds left on the specified timerf if it exists.
09-10-2015 11:53 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #5
RE: timerf instead of i_memory
(09-10-2015 11:27 PM)Art Wrote:  You mean item timer stops, but timerf continues working? I just not sure how works 'stack' for those timerf functions. For items it's more controllable. You can see item, etc., but timerf function hovering somewhere in memory and can't see it or 'touch', and don't know how much of those timerf functions can work at same time Smile

When you make a save, timerf are saved in spheredata.scp in this way: (it's a sort of list structure)

Code:
[TIMERF]
CurTick=3  //always on the top of the list
TimerFCall=name ciao // function name and it's argument, called by see below
TimerFNumbers=1,1073749939,492 // I think it's a tick number, uid in decimal of the object, time left in seconds
TimerFCall=name hi
TimerFNumbers=2,1,499
TimerFCall=name hola
TimerFNumbers=3,1073750000,497
TimerFCall=name borp
TimerFNumbers=7,1073750005,495





Also notes that if you do like

Code:
timerf 10,str 100
timerf 20,str 100
timerf STOP,str 100
both timerf will be stopped.

instead

Code:
timerf 10,str 100
timerf 20,str 200
timerf STOP,str 200

Will stop only timerf 20,str 200

My opinion is that timerf are best used for "permanent" time based scripts (like a weather system?) and for short-term function that lasts for some minutes.

For NPCs, timerf doesn't stop when the sector the npc is in goes to sleep mode, so having a lot of NPCs with a lot of timerf function that runs constantly could be worst than a memory item installed in each npc.
(This post was last modified: 09-11-2015 12:41 AM by darksun84.)
09-11-2015 12:35 AM
Find all posts by this user Like Post Quote this message in a reply
pointhz
Journeyman
*

Posts: 148
Likes Given: 1
Likes Received: 55 in 28 posts
Joined: Oct 2013
Reputation: 1



Post: #6
RE: timerf instead of i_memory
Any idea why ISTIMERF never worked for me? You guys have any example of using this function you could share?
09-11-2015 12:42 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #7
RE: timerf instead of i_memory
Code:
[FUNCTION testTimerf]
timerf 100,testerFunction <str>,<dex>
sysmessage @70 Timerf left: <istimerf.testerFunction <str>,<dex>>

dex +=5
sysmessage @75 Timerf left: <istimerf.testerFunction <str>,<dex>> //This will return 0
[FUNCTION testerFunction]
sysmesage @70 Str: <str>, Dex: <dex>

When you use istimerf.functionname <arguments> the arguments must match the arguments you put the first time you called timerf.
09-11-2015 12:57 AM
Find all posts by this user Like Post Quote this message in a reply
pointhz
Journeyman
*

Posts: 148
Likes Given: 1
Likes Received: 55 in 28 posts
Joined: Oct 2013
Reputation: 1



Post: #8
RE: timerf instead of i_memory
Doesn't work for me dunno why.

Sphere version is 0.56b pre-release
09-11-2015 01:40 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #9
RE: timerf instead of i_memory
AHhh istimerf was added in 056c !
09-11-2015 01:50 AM
Find all posts by this user Like Post Quote this message in a reply
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #10
RE: timerf instead of i_memory
Oh wow, thanks for those answers. I want to use timerf not so globally, just for some cases like raid boss AI, where function works each second and checking some conditions and deciding what to do.
09-11-2015 02:32 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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