• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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