Here is a way to easily create effective ward timers. Rather than just one large timer that always runs even when not needed these times are created and killed on demand. Callback and heper functions make this very clean and easy to use (requires zero stocks):
Global:
Code:
//For multiple wards per player add [x] where x is the number of wards at once allowed for the client
new Handle:WardTimer[MAXPLAYERS+1];
new Handle:WardLoopTimer[MAXPLAYERS+1];
//For multiple wards per player add [x] before [3] where x is the number of wards at once allowed for the client
new Float:WardLocation[MAXPLAYERS+1][3];
In Method:
Code:
//End any existing sparks first
//END SPARKS TIMER
new Handle:Timer;
//End Sparks Timer
Timer = WardTimer[client];
if(Timer != INVALID_HANDLE)
{
KillTimer(Timer);
Timer = INVALID_HANDLE;
}
//Sparks Timer
Timer = WardLoopTimer[client];
if(Timer != INVALID_HANDLE)
{
KillTimer(Timer);
Timer = INVALID_HANDLE;
}
War3_CachedPosition(client,WardLocation[client]);
WardTimer[client] = CreateTimer(10.0, EndSparks, client);
WardLoopTimer[client] = CreateTimer(0.14, Sparks, client, TIMER_REPEAT);
Required Methods:
Code:
public Action:EndSparks(Handle:timer,any:client)
{
//END TIMER
WardTimer[client] = INVALID_HANDLE;
//END SPARKS TIMER
new Handle:Timer;
Timer = WardLoopTimer[client];
if(Timer != INVALID_HANDLE)
{
KillTimer(Timer);
Timer = INVALID_HANDLE;
}
}
public Action:Sparks(Handle:timer,any:client)
{
CalculateWard(client,WardLocation[client],260.0);
}
//This function is a customizable call back to allow for you to preform anything on any client found within the ward!
public WardTargetCallback(client, target)
{
if(War3_DealDamage(target,1,client,DMG_ENERGYBEAM,"death_sparks",_,W3DMGTYPE_MAGIC))
{
//Damage suscess
}
}
This code of <50 lines replaces the existing methods of over 85 lines of code and 4 for loops with 1 single loop. Replaces single permanent global looping timers with multiple temporary on demand timers. Uses less variables and is easier to control and customize on a user by user and method call by method call basis.