• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Timer help

Status
Not open for further replies.
Hi.
I have a function for adding extra time to a global timer; it looks like this:

JASS:
function wanted takes player p, real decay returns nothing
    local real timeleft 
    set timeleft = TimerGetRemaining(udg_Player_WantedTimers[GetPlayerId(p)])
    call PauseTimer(udg_Player_WantedTimers[GetPlayerId(p)])
    call TimerStart(udg_Player_WantedTimers[GetPlayerId(p)], timeleft+decay, false, null) 
    //return
endfunction

And then a trigger that looks like this:

  • WantExpire1
    • Events
      • Time - Player_WantedTimers[1] expires
    • Conditions
    • Actions
      • Player - Make Player 1 (Red) treat Player 2 (Blue) as an Neutral
      • Player - Make Player 1 (Red) treat Player 10 (Light Blue) as an Neutral
      • Player - Make Player 10 (Light Blue) treat Player 1 (Red) as an Neutral
      • Player - Make Player 2 (Blue) treat Player 1 (Red) as an Neutral
(there is a similar trigger for every player)

Thing is, it doesen't work. What am i doing wrong?
 
You never unpause the timer?
Also you can initialize locals to a value.
Thirdly make sure that you are using it only on player 2 blue (Player(1)) as that event will only work if you modify that timer not the timer for player 1 red (Player(0)).


I didn't really understand that..
Doesen't "TimerStart" automatically unpause the timer?

Though i tried to deal whith the undecleared timers by changing the function like this:

function wanted takes player p, real decay returns nothing
local real timeleft
if udg_Player_WantedTimers[GetPlayerId(p)] == null then
set udg_Player_WantedTimers[GetPlayerId(p)] = CreateTimer()
endif
call BJDebugMsg("TIMERS STARTING!")
set timeleft = TimerGetRemaining(udg_Player_WantedTimers[GetPlayerId(p)])
call PauseTimer(udg_Player_WantedTimers[GetPlayerId(p)])
call TimerStart(udg_Player_WantedTimers[GetPlayerId(p)], timeleft+decay, false, null)
//return
endfunction
 
Status
Not open for further replies.
Top