Show a timer window to only one player

Discussion in 'World Editor Help' started by Mikecaos, Aug 3, 2007.

  1. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    It's just cause my both problem were timer problem, so i post in same topic...

    Though someone delete some post on this topic so my reference changed.

    My problem is on post 29.

    Sorry for the confusion...
     
  2. 3ICE

    3ICE Cool Member

    Ratings:
    +3 / 0 / -0
    W.E. Bug!

    :D Damn pesky World Editor Bugs :D
    The following two triggers don't work for multiplayer.
    It works fine for red, but the rest of the players don't see the actual time countdown.

    JASS:
    function x takes nothing returns nothing
    //locals
        local timer T
        local timerdialog TW=CreateTimerDialog(T)
    //endlocals
        call TimerStart(T,30.00,false,null) //Start 30 sec Countdown
        call TimerDialogSetTitle(TW,"TW") //Set title to TW :D
        if (GetLocalPlayer()==Player(0))then //This works :)
            call TimerDialogDisplay(TW,true) //Show to Red (Works Fine)
        endif
        if (GetLocalPlayer()==Player(1))then //nope :(
            call TimerDialogDisplay(TW,true) //Show to Blue
        endif //(But he cannot see the time because its bugged)
        call TriggerSleepAction(30.00) //Wait 30 sec for the timer to expire
        call DestroyTimerDialog(TW[i]) //Destroy Timer Window
    endfunction
    function InitTrig_x takes nothing returns nothing
        set gg_trg_x=CreateTrigger()
        call TriggerRegisterPlayerChatEvent(gg_trg_x,Player(0),"",false)
        call TriggerAddAction(gg_trg_x,function x)
    endfunction

    JASS:
    function X takes nothing returns nothing
    //locals
        local integer i=GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
    //Returns Player Number of Owner of Triggering Unit
        local timer array t
        local timerdialog array tw
    //endlocals
        if(GetUnitTypeId(GetTriggerUnit())=='Edem') then //Is Demon Hunter?
            call TimerStart(t[i],10.00,false,null) //Start the timer
            set tw[i]=CreateTimerDialog(t[i]) //Create Timer Window
            call TimerDialogSetTitle(tw[i],GetPlayerName(ConvertedPlayer(i)))
    //Set Timer Window Title
            if(GetLocalPlayer()==ConvertedPlayer(i))then //Get Player
                call TimerDialogDisplay(tw[i],true) //Show to Player
            endif
            call TriggerSleepAction(10.00) //Wait 10 sec for the timer to expire
            call DestroyTimerDialog(tw[i]) //Destroy Timer Window
        endif
    endfunction
    function InitTrig_X takes nothing returns nothing
        set gg_trg_X=CreateTrigger()
        call TriggerRegisterEnterRectSimple(gg_trg_X,gg_rct_X)
        call TriggerAddAction(gg_trg_X,function X)
    endfunction


    (Untested but im 90% sure that these triggers won't work for blue, teal, purple, etc)
     
  3. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    So in fact, it's my trigger, optimise and changed?

    Maybe the only solution would be to make a var for each player (timer and window)...
     
  4. Sooda

    Sooda Diversity enchants

    Ratings:
    +318 / 0 / -0
    I suggest you to get Warcraft TFT. Until that use this function:
    JASS:
    function RoC_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

    Place that function into your map header. You don' t know what is map header ? Well it is above all of your triggers and has your map name on it. It looks something like this:

    <YourMapName>.w3m

    and there is written into Custom Script Code Comment:
    Can' t find it still ? Use forum search and for search word "Map Header" (Without "").
    In Warcraft RoC you can' t use custom script lines ? If not convert your trigger to JASS and when you want to show timer window or hide for spesific player use this function call:
    JASS:
        call RoC_TimerDialogDisplayForPlayerBJ(udg_showTimerWindow,udg_whichTimerWindow,udg_whichPlayer)

    where:
    "udg_showTimerWindow" is boolean variable. When this variable is true it will show timer window specified. If false it will hide timer window specified.
    "udg_whichTimerWindow" is timer window variable and as you can guess your timer window.
    "udg_whichPlayer" is player variable to who will timer window shown or hidden.

    Keep in mind all variables need to have "udg_" (without "") prefix before your made variable name. If you would create player variable with name "MyMazePlayer" and want to show something to that player you would use it in function call as "udg_MyMazePlayer". All is case sensitive.
    Good way to implement this function call is to first make your trigger in GUI. Then when you have done convert it to custom script and add as a last function call RoC_TimerDialogDisplayForPlayerBJ.
     
  5. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    Hmm sooda... Read the post please. We are on Tft and we know all what you said...

    Also, you should convert your BJ to natives (if you don't do it, i suggest you to do it then)
    And UDG_ only makes the var global. If you wanna have a local var you don't need it.

    Also, the function you gave us is already implement in code and is not the problem actually.

    Anyway, next time, before helping others, make sure that what you are saying is answering the question.

    Though it is appreciate you tried to help, so don't take it personal and be mad. Your intention was right.
    If i miss understood something you said, then just correct me. It might happen since :
    -Slept only 3 hours last night
    -It is late and i am really tired
    -Had a 11 hours day, at work.
    -before that, i waited 2 hours To get my freakin book for school.

    Anyway, i got it working by using a timer var for each player. I will post my trigger later cause it isn't finish, though it takes lot more time than a simple array.

    Thank You.

    Mikechaos
     
  6. Sooda

    Sooda Diversity enchants

    Ratings:
    +318 / 0 / -0
    > Hmm sooda... Read the post please. We are on Tft and we know all what you said...

    You wan' t before. Thread started with question about RoC and within 3 pages nobody didn' t posted right code what would worked for RoC so I just took it from TFT. No hard feelings.

    > And UDG_ only makes the var global. If you wanna have a local var you don't need it.

    Where you read/ who told you that ? "udg_" is just a prefix (name, part of string) it hasn' t nothing to do with making it global or local. To get actual local variable (Not global) you have to write each variable at the start of your actions (Or you will get syntax errors.). It looks like this:
    JASS:
    local variableType variableName


    > Anyway, next time, before helping others, make sure that what you are saying is answering the question.

    It wasn' t wrong either. In TFT there is like a action to show timer window to only specific player.
     
  7. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    > You wan' t before. Thread started with question about RoC and within 3 pages nobody didn' t posted right code what would worked for RoC so I just took it from TFT. No hard feelings.

    There is on page two.
    And there in the post where I put My code (for my last question) (post #28 if it didn't change)
    And I had No hard feelings (and i know you didn't had either).

    > Where you read/ who told you that ? "udg_" is just a prefix (name, part of string) it hasn' t nothing to do with making it global or local. To get actual local variable (Not global) you have to write each variable at the start of your actions (Or you will get syntax errors.). It looks like this:

    Ya i know how to create local variable.
    And ya "udg_" is just a prefix. YOu missed understood what I was trying to say. "Udg_" doesn't make the var global, i mean, you can't create a local var, then add Udg_ in front of it and use it as a global.
    But it tell the world editor that that var is a global.
    Don't know if you get the difference between what I wanted to say (indeed, I just re read it and it was really confusing) and what you understood.

    > It wasn' t wrong either. In TFT there is like a action to show timer window to only specific player.

    And I didn't said it was wrong, It was not answering the question, that's it.
     
  8. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    Bumb..

    So i know i find out how to do it (just gotta Not use array)

    But exide, if i'm not mistaken, made it work.

    If you don't know what i'm talking about, I will explain it again.

    I want to create a timer that only one person can see (cause it is suppose to be secrete, so I can't show the window to everyone or people will know it)
    So i created arrays.
    The window is, indeed, being show to only one person. That was easy.
    But only the host, I think, can see the time. Other people see a window, but no time.
    Finaly, I discover that it was the timer array who was maybe bugged..
    So if anyone knows a way to do it with an timer array, it would be appreciate (in fact, it's just to know if there is a way to pass around that bug)

    Else, I will do it in jass, with local. Maybe it will work and will know force me to do a trigger for each simple player.
    Else, well I will do it with global, each player with his own timer var and an array timer window for all.

    This is like 2-3 weeks i asked that question and never got any answer. Only people that didn't read and answered question that were already answer.

    Thank you in advance.

    I will post my result with local when it will be done.
     
  9. Exide

    Exide I am amazingly focused right now!

    Ratings:
    +449 / 0 / -0
    The trigger I used shows only one timer to the owner of the dying unit, and removes it. -Only if one hero dies. My map only allowed 1 hero per player, though, so that wasn't a problem.

    This is what my trigger looks like:

    JASS:
    
    function Trig_Hero_Respawning_Func027C takes nothing returns boolean
        local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
        return id<5
    endfunction
    
    function Trig_Hero_Respawning_Conditions takes nothing returns boolean
        if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
            return true
        endif
        if ( Trig_Hero_Respawning_Func027C() ) then
            return true
        endif
        return false
    endfunction
    
    function Trig_Hero_Respawning_Actions takes nothing returns nothing
        local timer t = CreateTimer()
        local real time = 2.5
        local location loc = GetRectCenter(gg_rct_Hero_Respawn_Region)
        local player owner = GetOwningPlayer(GetTriggerUnit())
        local unit hero = GetTriggerUnit()
        local integer a = GetHeroLevel(hero)
        local integer time
    
        if a <= 9 then
            set time = 15+(5*a)  
        else
            set time = 60
        endif
    
        call DisplayTimedTextToForce( udg_All_Players, 10.00, " " )
        call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(owner) + "'s Hero has been killed!|r" ) ) )
        call DisplayTimedTextToForce( udg_All_Players, 10.00, ( "|cff32cd32" + ( GetPlayerName(owner) + ( "'s Hero will respawn in " + ( I2S( time) + " seconds!|r" ) ) ) ) )
        call TimerStart( t,time,false,null )
        call CreateTimerDialogBJ( t, ( "|cff32cd32" + "Hero respawn in:|r" ) )
        set udg_Timer_Window[GetConvertedPlayerId(owner)] = GetLastCreatedTimerDialogBJ()
        call TimerDialogDisplayBJ( false, GetLastCreatedTimerDialogBJ() )
        call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), owner)
        call TriggerSleepAction( I2R( time) )
        call TimerDialogDisplayForPlayerBJ( true, GetLastCreatedTimerDialogBJ(), owner)
        call DestroyTimerDialogBJ( udg_Timer_Window[GetConvertedPlayerId(owner)] )
        call PanCameraToTimedLocForPlayer( owner, loc, 0 )
        call ReviveHeroLoc( hero, loc, true )
        call RemoveLocation( loc)
        set loc = null
        set hero = null
        set owner = null
    endfunction
    
    //===========================================================================
    function InitTrig_Hero_Respawning takes nothing returns nothing
        set gg_trg_Hero_Respawning = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Respawning, EVENT_PLAYER_UNIT_DEATH )
        call TriggerAddCondition( gg_trg_Hero_Respawning, Condition( function Trig_Hero_Respawning_Conditions ) )
        call TriggerAddAction( gg_trg_Hero_Respawning, function Trig_Hero_Respawning_Actions )
    endfunction


    udg_Timer_Window
    is a global Timer window array. (One for each player).
     
  10. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    > The trigger I used shows only one timer to the owner of the dying unit, and removes it. -Only if one hero dies. My map only allowed 1 hero per player, though, so that wasn't a problem.

    Hmm I'm not sure i understood what you are saying.

    My map allows only one hero per player (it's a maze, if some know what they are).

    But, with that trigger, if two hero (different owner) die in same time, would it display one window, with a time, to both players? Cause that's what I want.
     
  11. Exide

    Exide I am amazingly focused right now!

    Ratings:
    +449 / 0 / -0
    >But, with that trigger, if two hero (different owner) die in same time, would it display one window, with a time, to both players? Cause that's what I want.

    Yes.
    As far as I know. I haven't tried this trigger in a long time, but I'm 99% sure it does. (That's what I wanted to, when I made it.) -Try and see for yourself. :p
     
  12. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    Nan. I trust you.

    So like i was saying, I think it's possible to make it with local since that's how this trigger seem to work.

    I'll try it and post back my code here (I don't know when, don't have much time for my self lately)

    Thank you.
     
  13. Ghan

    Ghan Administrator - Servers are fun Staff Member

    Ratings:
    +773 / 0 / -0
  14. Mikechaos

    Mikechaos Guest

    Ratings:
    +0 / 0 / -0
    Aha.

    Hmm in fact it's not really what i want to do, and like I said, I was pretty sure it was working with Locals.

    Anyway. Thank you
     

Share This Page