Quote:
Originally Posted by alasfourom
Hello guys
How is it possible to prolong timer if something is checked
For example, I'm trying to make a plugin if you killed someone, you will have some abilities and after a period of time, it will be turning off.
After killing someone you will have like 10 seconds of these abilities then it will go back to normal.
What I want to do is, if I killed more players, the time to rest to normal will be increase, like killing 3 players simultaneously will give you 10 + 10 + 10 seconds before resetting.
This is a script example - For Left 4 Dead 2:
PHP Code:
public void Event_InfectedDeath (Event event, const char[] name, bool dontBroadcast)
{
int victim = GetClientOfUserId (event.GetInt("userid")); if (IsClient (victim))
{
int team = GetClientTeam (victim); if (team == TEAM_INFECTED)
{
int attacker = GetClientOfUserId (event.GetInt("attacker"));
if (IsValidClient (attacker, TEAM_SURVIVOR)) if (!IsFakeClient (attacker))
/*I'm doing some long stuff here, didnt want to bother*/
/*bluh bluh bluh*/
/*bluh bluh bluh*/
/*I created timer to stop the abilities after 10 seconds*/
CreateTimer (GetConVarFloat(10.0), StopTimer, attacker);
}
}
return;
}
|
Hello. I would do the following:
1. Because I want to let him know how much time is left at real time, I would make a 0.1 repeat timer to count down his time. Then the time left is a variable ( either set expiration by GetGameTime() or just make a time left var to 10 and decrease by 0.1 each time the timer arrives )
This allows you to both increment it whenever you like, and let the client track it.
Note that with the best way in L4D2 ( which I know you use ) you need to send an empty message or wait a bit, otherwise you will have bugs if you spam those hints ( PrintHintText )
__________________
I am available to make plugins for pay.
Discord: Eyal282#1334