Hi all -
So I'm working on a 1v1 melee-mod map and am trying to set up separate timers for each player. And then if that player performs certain actions it will reset his/her timer.
I can do this for 1 player no problem...ez pz. The issue I'm facing is that the timer is universal and so both players have the same timer. This makes me sad :(
So, is there any way I can get this done?
You will have to create a timer based per player and save them into an array based on the player. If the map only has a few players timers will work fine but if you need to use a very large amount of timers you will want to lookin to threads definitions and loops to get track everything while keeping it simple.
When I want your opinion...I'll give it to you!
Thanks for the reply hobbidude. I think I see what you're saying about saving the values into an array. However (and forgive my ignorance here) I'm not entirely sure how that will solve the issue I'm working with.
Basically here's the scenario:
- After 6 minutes of game time a timer starts for both players (5 minutes == 300 seconds)
- If a player builds an expansion then it restarts the timer
- If the timer expires then the player loses half their workers and the timer resets
And that's it.
The issue I'm running into (again ignorant) is that when creating a timer, I don't see how I can create it specifically for one player. As it is, there's just 1 universal timer that resets if either player builds the expansion. The timer creation triggers don't have any mechanism (insofar as I can tell) to specify the trigger is only applicable to player 1 or 2.
I'm definitely open to any other suggestions, ideas, or elaboration if the array setup is the way to go.
Variable Timer type with  array enough to check for all players in the game. Pick each Active Player and start the timer for him. Trigger with events of expired timer and kill everything you want.
Yeah, arrays are what you want. But it sounds like you are unfamilliar with arrays.
I would recomend just looking up tutorials on how to use arrays. Then once you know how to use them this task will be easy
It sounds actually like for this particular scenario you would want to do this in a threaded loop instead of timers which generally are more of a one shot sort of deal. Granted a threaded loop requires a bit more knowledge it is much better and more flexible to interruptions. You will want one trigger to yet an boolen global array for each player on when they expand and in another trigger check for the time event and then run a threaded action definition for each player. Within the action defintion have a local variable for time and run a repeat forever action. Then use a while loop to check if the local variable is met; within in it put an if then to check the previous boolean and if true set the local variable back to 0 and the global boolean back to false for the player. Make sure you put a 1 sec wait after the if then. Outside the while loop after put the actions to kill half the works and set the local variable again back to zero.
And back to the timers, no they are not specifically set per player but if you use an array you save the timer equal to the player integer; therefore for each player.
You must login to post a comment. Don't have an account? Register to get one!