HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Timer

03-17-2007, 07:53 PM#1
OwnorzeD
I haven't really done these timer triggers before so I'll have to ask for help here. I'm currently trying to do an event that starts a timer, and my question is; how do I make so if the timer expires a player gets Defeat, and if they make it before the timer runs out the timer disappears.

The event that starts the timer is in another trigger than the one which will make the player Defeated if the timer expires, same with the victory one.
03-17-2007, 08:40 PM#2
FatalError
I'm going to go ahead and assume you're using JASS. You can do this two ways:
1) Make a global timer that triggers a separate trigger when it expires.
2) Create and expire the timer all in one trigger.
For your purposes let's go number 1. ;]

First, start out with a trigger that starts a global timer (I'll use udg_Timer). I trust you know how to create and start timers.
Collapse JASS:
set udg_Timer = CreateTimer()
// Replace 240. with your timeout, I just used 4 minutes as an example
call TimerStart(udg_Timer, 240., false, null)
Here's the trigger that fires on expiration:
Collapse JASS:
function Trig_TimerExpires_Actions takes nothing returns nothing
    call RemovePlayer(udg_SomePlayer, PLAYER_GAME_RESULT_DEFEAT)
endfunction

function InitTrig_TimerExpires takes nothing returns nothing
    set gg_trg_TimerExpires = CreateTrigger()
    call TriggerRegisterTimerExpireEvent(gg_trg_TimerExpires, udg_Timer)
    call TriggerAddAction(gg_trg_TimerExpires, function Trig_TimerExpires_Actions)
endfunction
As for the "disappearing" part, just add these two lines whenever you want the timer to "disappear":
Collapse JASS:
call PauseTimer(udg_Timer)
call DestroyTimer(udg_Timer)
03-17-2007, 09:38 PM#3
OwnorzeD
Actually I don't use JASS. Not really familiar with it, but I suppose I could learn it as it seems to not be too hard.

Quote:
I trust you know how to create and start timers.

Yes I know how to create and start timers. :)