Quote:
Originally Posted by alasfourom
What kind of disaster I'm doing here  ?
I created the float
PHP Code:
float f_AbilityStart [MAXPLAYERS+1];
The cumulative timer here
PHP Code:
public Action CumulativeEffect (int client)
{
f_AbilityStart[0] = GetEngineTime() + 10.0;
if (AbilityStart [client])
{
if (f_AbilityStart [client])
{
CreateTimer(0.1, StopTimer, client);
}
}
else AbilityStart [client] = true;
return Plugin_Continue;
}
Timer Stop
PHP Code:
public Action StopTimer(Handle timer, any client)
{
/*I stopped everything here*/
AbilityStart [client] = false;
}
|
For a start, AbilityStart is a lie. IsAbilityActive, bAbilityActive, AbilityActive are all acceptable names for the variable that asks
If the ability is active
Second, f_AbilityStart[0] does absolutely nothing. If you were to try [1] by accident, it would work only for the first player that entered the server, and nobody else, so it's like every player in the server would contribute to the timer of the first player in the server, and nobody would get the ability except him.
When you do f_AbilityStart[x], where x is a constant number (1, 2, 3, 4, 5, 6, 7) you will assign that variable to a constant slot, which will ignore who did the action.
When you use f_AbilityStart[client] you are giving the client's "unique"* index the responsibility to hold his time, so it works.
* It's not totally unique if a client disconnects and another client joins, as client indexes can be stolen. User ID cannot be stolen, and therefore User ID is unlimited in size ( which is bad for programming if you tried something like:
float f_AbilityStart[32767] with f_AbilityStart[GetClientUserId(client)]
__________________
I am available to make plugins for pay.
Discord: Eyal282#1334