• 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.

[JASS] Need help getting a player

Status
Not open for further replies.
Level 2
Joined
Jan 6, 2009
Messages
18
I am making a trigger that is called hero revive ...
I create a Timer Dialog for my Timer ...
I want to show the timer dialog only for the owner of the hero ..
I used this but its not working it shows the dialog to all players .. any help ?

JASS:
local timerdialog td = CreateTimerDialogBJ( t,"Your hero revive in" )
call TimerDialogDisplayForPlayerBJ(true , td , GetOwningPlayer(GetTriggerUnit()))


-----------------------------------------------------
Never mind i found the answer :

JASS:
local timerdialog td = CreateTimerDialogBJ( t,"Your hero revive in" )
    call TimerDialogDisplay(td , false)
    call TimerDialogDisplayForPlayerBJ(true , td , GetOwningPlayer(GetTriggerUnit()))
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Don't use "BJ" functions they simply call natives. The natives that you want to concern yourself with here are:

JASS:
native CreateTimerDialog takes timer t returns timerdialog
native TimerDialogDisplay takes timerdialog whichDialog, boolean display returns nothing

This is the native; the BJ that you were using does the following:

JASS:
function CreateTimerDialogBJ takes timer t, string title returns timerdialog
    set bj_lastCreatedTimerDialog = CreateTimerDialog(t)
    call TimerDialogSetTitle(bj_lastCreatedTimerDialog, title)
    call TimerDialogDisplay(bj_lastCreatedTimerDialog, true)
    return bj_lastCreatedTimerDialog
endfunction

As you can see, this native already calls TimerDialogDisplay. This means that you call many functions unnecessarily, there is no reason to call TimerDialogDisplay(dialog, true) only to do TimerDialogDisplay(dialog, false) after.

I re-wrote your trigger:

JASS:
local timerdialog td=CreateTimerDialog(t)
    call TimerDialogSetTitle(td, "Your Hero Revives In...")
    call TimerDialogDisplay(td, GetLocalPlayer( )==GetOwningPlayer(GetTriggerUnit()))

By the way, this is what the TimerDialogDisplayForPlayerBJ looks like:

JASS:
function TimerDialogDisplayForPlayerBJ takes boolean show, timerdialog td, player whichPlayer returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call TimerDialogDisplay(td, show)
    endif
endfunction

As you can see, I've simply substituted the if-statement directly into the boolean parameter.
 
Status
Not open for further replies.
Top