Cumulative Timer
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 delayed, like killing 3 players simultaneously will give you 10 + 10 + 10 seconds before resetting instead of resetting earlier. This is a script example - For Left 4 Dead 2: PHP Code:
PHP Code:
|
Re: Cumulative Timer
Quote:
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 ) |
Re: Cumulative Timer
if there is 2 Eyals life would be much easier
Thanks man |
Re: Cumulative Timer
Create a player float array
Set the value with GetEngineTime() + 10.0 Create a 1.0 timer to check if any client has the value if it has, resets otherwise goes next |
Re: Cumulative Timer
What kind of disaster I'm doing here :oops: ?
I created the float PHP Code:
PHP Code:
PHP Code:
|
Re: Cumulative Timer
I would create a single timer of 1.0 seconds and do a loop through all clients where AbilityStart[client] = true
PHP Code:
also don't forget to reset on player death, round restart, etc There are a lot of plugins with similar cooldown features, just need to search a bit and check their code. |
Re: Cumulative Timer
Awwww
Thanks Marttt, I will test it right now |
Re: Cumulative Timer
Quote:
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)] |
Re: Cumulative Timer
Thank you Eyal, you will find multiple mistakes in the script obviously
I just started reading about scripts like 1 month ago, and trying to replicate some lines that I saw other ppl do Its still getting me crazy tbh, its need a while to make it right and understand the timer concept you guys explaining Thanks anyway, I will keep trying and testing |
| All times are GMT -4. The time now is 00:58. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.