Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new mytimer = 0, somecounter = 0;
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate == PLAYER_STATE_DRIVER)
- {
- // If a player has left its vehicle successfully
- // Add your additional check here...
- somecounter = 0;
- if(mytimer != 0) KillTimer(mytimer); // If the timer was not being killed, gets killed properly...
- mytimer = SetTimerEx("blahblah", 1000, true, "i", playerid); // Sets a repeating timer, and stores the timer ID into some global variable
- }
- //...
- if(newstate == PLAYER_STATE_DRIVER)
- {
- // If a player has entered a vehicle successfully
- // Add your additional checks here
- if(mytimer != 0) KillTimer(mytimer); // Kills the timer
- mytimer = 0; // Resets value
- }
- }
- forward blahblah(playerid);
- public blahblah(playerid) // Our callback
- {
- // Add your code here
- somecounter++;
- // Add your checks here, and if the counter has exceeded...
- if(mytimer != 0) KillTimer(mytimer); // Kill the timer to prevent calling this callback once more accidently
- mytimer = 0; // Resets the value, of course
- somecounter = 0; // Resets the counter
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement