• 🏆 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!

Dialog Not Coming Up

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
        integer CurrentPlayers
        
        dialog array StartDialog[MAX_PLAYERS]
        button array NewCharacterButton[MAX_PLAYERS]
//
//**************************************************************//
    endglobals  
    
    private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        call BJDebugMsg("LoadRun")
        
            loop
            exitwhen loop1 > MAX_PLAYERS
                call BJDebugMsg("Loop #"+I2S(loop1)) 
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                    
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                endif
                
            set loop1 = loop1+1
            endloop
            set loop1 = 0
        call BJDebugMsg("LoadExecuted")
        call BJDebugMsg(I2S(CurrentPlayers))
    endfunction
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
        
        call TriggerRegisterTimerEventSingle( t, 0.01 )
        call TriggerAddAction(t, function LoadPlayers)
        set t = CreateTrigger()
        
        loop
        exitwhen loop1 > MAX_PLAYERS
        
            call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
            call TriggerAddAction(t, function NewSelection)
            
        set loop1 = loop1+1
        endloop
        
        // Environment Setup
        call FogEnableOff(  )
        call FogMaskEnableOff(  )
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
    endfunction
endlibrary

The dialog wont come up, any idea why?
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Sry about tht I'm on my phone I think I skipped past the first function. U shouldn't use the triggerregistertimereventsingle use the other one. Ill try to look at this more. Phones being a pain ATM tho

It might be because u create the local trigger t twice u should null it in the middle of them and call the function w the create dialog b4 u register them to the trigger.

Thts y it's not working u add the dialog button events b4 u create them u can put the second half of the bottom trigger the one were u create the trigger t and add the dialog buttons into the function tht u create the dialog buttons

If u don't understand what I mean I can fix it for u when i get home in about half an hr and relate it unless someone else does in the meantime.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
here u go. this should work.

JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
        integer CurrentPlayers
        
        dialog array StartDialog[MAX_PLAYERS]
        button array NewCharacterButton[MAX_PLAYERS]
//
//**************************************************************//
    endglobals  
    
    private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        local trigger t = CreateTrigger()
        call BJDebugMsg("LoadRun")
        
            loop
            exitwhen loop1 > MAX_PLAYERS
                call BJDebugMsg("Loop #"+I2S(loop1)) 
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                    
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                endif
                
            set loop1 = loop1+1
            endloop
            set loop1 = 0
        call BJDebugMsg("LoadExecuted")
        call BJDebugMsg(I2S(CurrentPlayers))
        set loop1 = 0
        loop
        exitwhen loop1 > MAX_PLAYERS
        
            call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
            call TriggerAddAction(t, function NewSelection)
            
        set loop1 = loop1+1
        endloop
    endfunction
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddAction(t, function LoadPlayers)
        // Environment Setup
        call FogEnable(false)
        call FogMaskEnable(false)
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
        set t = null // do not forget this
    endfunction
endlibrary
 
Level 11
Joined
Jun 30, 2008
Messages
580
I changed it to this;

JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
        integer CurrentPlayers
        
        dialog array StartDialog[MAX_PLAYERS]
        button array NewCharacterButton[MAX_PLAYERS]
//
//**************************************************************//
    endglobals  
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
    private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        local trigger t = CreateTrigger()
        
            loop
            exitwhen loop1 > MAX_PLAYERS 
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                    
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                    call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
                    call TriggerAddAction(t, function NewSelection)
                endif
                
            set loop1 = loop1+1
            endloop
            set loop1 = 0
    endfunction
    
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
        
        call TriggerRegisterTimerEventSingle( t, 0.01 )
        call TriggerAddAction(t, function LoadPlayers)
        
        // Environment Setup
        call FogEnableOff(  )
        call FogMaskEnableOff(  )
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
    endfunction
endlibrary

And it still doesn't work...
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
u have to show the dialog

here and i cleaned the bjs for u and the trigger leak

JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
        integer CurrentPlayers
        
        dialog array StartDialog[MAX_PLAYERS]
        button array NewCharacterButton[MAX_PLAYERS]
//
//**************************************************************//
    endglobals  
    
    private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        local trigger t = CreateTrigger()
        call BJDebugMsg("LoadRun")
        
            loop
            exitwhen loop1 > MAX_PLAYERS
                call BJDebugMsg("Loop #"+I2S(loop1)) 
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                    
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                    
                    call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
                    call TriggerAddAction(t, function NewSelection)
                    call DialogDisplay( Player[Loop1], StartDialog[Loop1], true)
                endif
                
            set loop1 = loop1+1
            endloop
            set loop1 = 0
        call BJDebugMsg("LoadExecuted")
        call BJDebugMsg(I2S(CurrentPlayers))
        set t = null
    endfunction
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddAction(t, function LoadPlayers)
        // Environment Setup
        call FogEnable(false)
        call FogMaskEnable(false)
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
        set t = null // do not forget this
    endfunction
endlibrary
 
Level 11
Joined
Jun 30, 2008
Messages
580
Still nothing...

JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
                integer CurrentPlayers
                       
                dialog array StartDialog[MAX_PLAYERS]
                button array NewCharacterButton[MAX_PLAYERS]     
//
//**************************************************************//
    endglobals  
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
   private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        local trigger t = CreateTrigger()
       
            loop
            exitwhen loop1 > MAX_PLAYERS
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                   
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                    call DialogDisplay(Player(loop1), StartDialog[loop1], true)
                    call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
                    call TriggerAddAction(t, function NewSelection)
                endif
               
            set loop1 = loop1+1
            endloop
            set loop1 = 0
    endfunction
   
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
       
        call TriggerRegisterGameLoadedEventBJ(t)
        call TriggerAddAction(t, function LoadPlayers)
       
        // Environment Setup
        call FogEnableOff(  )
        call FogMaskEnableOff(  )
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
    endfunction
endlibrary

I tried changing the time elasped event to gameloaded event and still nothing...
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
i think i found the problem u didnt initialize the current players variable

here u go try this

JASS:
library GameInit initializer GameInitialization

    globals
//**************************************************************//
//                          Constants                           //
//**************************************************************//
        constant integer MAX_PLAYERS        = 9
        constant real TIMER_TIMEOUT         = 0.04
//
//**************************************************************//
//                          Variables
        integer CurrentPlayers = 0
        
        dialog array StartDialog[MAX_PLAYERS]
        button array NewCharacterButton[MAX_PLAYERS]
//
//**************************************************************//
    endglobals  
    
    private function LoadPlayers takes nothing returns nothing
        local integer loop1 = 0
        local trigger t = CreateTrigger()
        call BJDebugMsg("LoadRun")
        
            loop
            exitwhen loop1 > MAX_PLAYERS
                call BJDebugMsg("Loop #"+I2S(loop1)) 
                if (GetPlayerController(Player(loop1)) == MAP_CONTROL_USER ) then
                    set CurrentPlayers = CurrentPlayers+1
                    
                    set StartDialog[loop1] = DialogCreate()
                    set NewCharacterButton[loop1] = DialogAddButton(StartDialog[loop1], "New Character", 0)
                    
                    call TriggerRegisterDialogButtonEvent(t, NewCharacterButton[loop1])
                    call TriggerAddAction(t, function NewSelection)
                    call DialogDisplay( Player[Loop1], StartDialog[Loop1], true)
                endif
                
            set loop1 = loop1+1
            endloop
        call BJDebugMsg("LoadExecuted")
        call BJDebugMsg(I2S(CurrentPlayers))
    endfunction
    
    private function NewSelection takes nothing returns nothing
        local CHARDATA temp = CHARDATA.create(GetTriggerPlayer())
        call temp.ActivateCharacter(CreateUnit(GetTriggerPlayer(), 'CHAR', GetRectCenterX(gg_rct_Start), GetRectCenterY(gg_rct_Start), 0))
    endfunction
    
    private function GameInitialization takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer loop1 = 0
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddAction(t, function LoadPlayers)
        // Environment Setup
        call FogEnable(false)
        call FogMaskEnable(false)
        call SetSkyModel("Environment\\Sky\\Sky\\SkyLight.mdl")
        set t = null // do not forget this
    endfunction
endlibrary
 
Status
Not open for further replies.
Top