Advertisement
BigETI

Ehh

Apr 7th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.09 KB | None | 0 0
  1. new mytimer = 0, somecounter = 0;
  2.  
  3. public OnPlayerStateChange(playerid, newstate, oldstate)
  4. {
  5.     if(oldstate == PLAYER_STATE_DRIVER)
  6.     {
  7.         // If a player has left its vehicle successfully
  8.         // Add your additional check here...
  9.         somecounter = 0;
  10.         if(mytimer != 0) KillTimer(mytimer); // If the timer was not being killed, gets killed properly...
  11.         mytimer = SetTimerEx("blahblah", 1000, true, "i", playerid); // Sets a repeating timer, and stores the timer ID into some global variable
  12.     }
  13.     //...
  14.     if(newstate == PLAYER_STATE_DRIVER)
  15.     {
  16.         // If a player has entered a vehicle successfully
  17.         // Add your additional checks here
  18.         if(mytimer != 0) KillTimer(mytimer); // Kills the timer
  19.         mytimer = 0; // Resets value
  20.     }
  21. }
  22.  
  23. forward blahblah(playerid);
  24. public blahblah(playerid) // Our callback
  25. {
  26.     // Add your code here
  27.     somecounter++;
  28.     // Add your checks here, and if the counter has exceeded...
  29.     if(mytimer != 0) KillTimer(mytimer); // Kill the timer to prevent calling this callback once more accidently
  30.     mytimer = 0; // Resets the value, of course
  31.     somecounter = 0; // Resets the counter
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement