• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] SetTimer looping through players with gettime() function
#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


Messages In This Thread
RE: SetTimer looping through players with gettime() function - by fusez - 2019-07-23, 11:10 PM

Forum Jump: