|
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
|
06-16-2015
, 09:14
Re: Timer problems
|
#4
|
Here's another example of working with timers you want to execute only if certain conditions apply... like resetting every round_start event
code
PHP Code:
new Handle:GodOff = INVALID_HANDLE; new Handle:GiveBeacon = INVALID_HANDLE;
public Action:Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast) { ClearTimer(GiveBeacon); ClearTimer(GodOff); for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i) && IsPlayerAlive(i)) { SetEntProp(i, Prop_Data, "m_takedamage", 0, 1); } } GodOff = CreateTimer(60.0, GodOff) }
public Action:GodOff(Handle:timer) { if (GodOff != INVALID_HANDLE) { GodOff = INVALID_HANDLE; for (new i = 1; i <= MaxClients; i++) { SetEntProp(i, Prop_Data, "m_takedamage", 2, 1); } GiveBeacon = CreateTimer(90.0, GiveBeacon); } }
public Action:GiveBeacon(Handle:timer) { if (GiveBeacon != INVALID_HANDLE) { GiveBeacon = INVALID_HANDLE; ServerCommand("sm_beacon @all"); CreateTimer(90.0, blabla...); } }
/** * Function to clear/kill the timer and set to INVALID_HANDLE if it's still active * * @param timer Handle of the timer * @noreturn */ ClearTimer(&Handle:timer) { if (timer != INVALID_HANDLE) { KillTimer(timer); timer = INVALID_HANDLE; } }
__________________
|
|
|
|