• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] SetTimer looping through players with gettime() function
#1
-delete
  Reply
#2
1. first Checker call time - second Checker call time != 1.

2. i think the result will be changed as initial value of TickChecker[0].

gettime() | TickChecker[0]
[23:08:45] 1562681325 1562681327
[23:08:45] [dbg] Sent checkertick
[23:08:46] 1562681326 1562681327
[23:08:46] [dbg] Sent checkertick
[23:08:47] 1562681327 1562681328
[23:08:47] [dbg] Sent checkertick
[23:08:48] 1562681328 1562681329
[23:08:48] [dbg] Sent checkertick
[23:08:49] 1562681329 1562681330
[23:08:49] [dbg] Sent checkertick
[23:08:50] 1562681330 1562681331
[23:08:50] [dbg] Sent checkertick
[23:08:52] 1562681332 1562681332
[23:08:53] 1562681333 1562681332
[23:08:54] 1562681334 1562681332
[23:08:55] 1562681335 1562681332
[23:08:56] 1562681336 1562681332
[23:08:58] 1562681337 1562681332
[23:08:58] 1562681338 1562681332

this happens because next TickChecker[0]`s value is based on pre gettime(), and this not mean seconds
  Reply
#3
(2019-07-09, 01:54 PM)Cada Wrote: gettime(&hour=0,&minute=0,&second=0)



your function usage is wrong



No it is not wrong, if not using the syntax inside the function it returns the year,hour,month,second,day in seconds e.g 15206501548
  Reply
#4
Anyone?
  Reply
#5
You have a 0 element array. I'm surprised that code even compiles.
  Reply
#6
(2019-07-13, 06:38 PM)Y_Less Wrote: You have a 0 element array. ?I'm surprised that code even compiles.



I have tried without a 0 element array although, still having the same problem. :(
  Reply
#7
It could be crashing. It's hard to say without the rest of the code. Have you run this with crashdetect active?
  Reply
#8
This is how i would solve the problem.

I didn't try compiling it but it should work, let me know.



Code:
#define CHECKER_EXEC_INTERVAL_S? ? ?2

#define CHECKER_TIMER_INTERVAL_MS 1000



new nextCheckerTime;



public OnGameModeInit()

{

? ?SetTimer("Checker", CHECKER_TIMER_INTERVAL_MS, true);

}



forward Checker();

public Checker()

{

? ?prinft("[DEBUG] Checker(): gettime() = %i, nextCheckerTime = %i", gettime(), nextCheckerTime);



? ?if( gettime() >= nextCheckerTime )

? ?{

? ? ? ?print("[DEBUG] Checker(): gettime() >= nextCheckerTime");

? ? ? ?// do shit here..

? ? ? ?nextCheckerTime = gettime()  CHECKER_EXEC_INTERVAL_S ; // Apply the next time value to this variable. When gettime() exceeds or equals this value the code within these brackets will be called again.

? ?}

}
  Reply


Forum Jump: