• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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