HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

new problem with WaitForPlayerEvent

07-26-2006, 12:01 AM#1
Linera
Why is this code giving an error for invalid integer?

Here is the call function:
Trigger:
Custom script: call WaitForPlayerEvent(ConvertedPlayer(udg_tempnumber), EVENT_PLAYER_END_CINEMATIC, 'true', 1.00)
Here is the jass code:
Collapse JASS:
function WaitForPlayerEvent_H2P takes handle h returns player
    return h
endfunction

function WaitForPlayerEvent_H2F takes handle h returns force
    return h
endfunction

function WaitForPlayerEvent_PE2I takes playerevent p returns integer
    if true then
        return p
    endif
    return 0
endfunction

function WaitForPlayerEvent_Enum takes nothing returns nothing
    call TriggerRegisterPlayerEvent(bj_delayedSuspendDecayTrig, GetEnumPlayer(), ConvertPlayerEvent(bj_forceCountPlayers))
endfunction

function WaitForPlayerEvent takes handle whichForceOrPlayer, playerevent whichPlayerEvent, boolexpr condition, real interval returns nothing
    local trigger bj_temp = bj_delayedSuspendDecayTrig
    local trigger t
    local triggercondition c
    local player whichPlayer = WaitForPlayerEvent_H2P(whichForceOrPlayer)
    local force whichForce = WaitForPlayerEvent_H2F(whichForceOrPlayer)
    if whichForceOrPlayer == null or whichPlayerEvent == null then
        set whichForce = null
        return
    elseif interval < 0 then
        set interval = 0
    endif
    set t = CreateTrigger()
    set bj_delayedSuspendDecayTrig = t
    set bj_forceCountPlayers = WaitForPlayerEvent_PE2I(whichPlayerEvent)
    call ForForce(whichForce, function WaitForPlayerEvent_Enum)
    call TriggerRegisterPlayerEvent(bj_delayedSuspendDecayTrig, whichPlayer, whichPlayerEvent)
    if condition != null then
        set c = TriggerAddCondition(bj_delayedSuspendDecayTrig, condition)
    endif
    set bj_delayedSuspendDecayTrig = bj_temp
    loop
        call TriggerSleepAction(interval)
        exitwhen GetTriggerExecCount(t) != 0
    endloop
    if condition != null then
        call TriggerRemoveCondition(t, c)
        set c = null
    endif
    call DestroyTrigger(t)
    set t = null
    set whichForce = null
endfunction
07-26-2006, 12:09 AM#2
EveningStar
I say don't even use that; if you need to wait for a player event, then do something like this:

Collapse JASS:

function main_action_part_one takes nothing returns nothing
  local trigger t = CreateTrigger() 
  // do something here.........

  call TriggerRegisterAnyPlayerEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
  call TriggerAddCondition(t, Condition(function is_spellcaster_me))
  call TriggerAddAction(t, function main_action_part_two)

  set t = null
endfunction

function main_action_part_two takes nothing returns nothing
  //the remaining things you want to do after the event occured

  call DestroyTrigger(GetTriggeringTrigger()) //destroy it after it's done
endfunction
07-26-2006, 09:45 AM#3
The)TideHunter(
EveningStar, that would give you errors, the actions need to be declared before the Init_Trig
But yes, thats the method.