Why won't GetClickedButton work?

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Why won't GetClickedButton work?

Post by Risen »

The only problem I can point out in your "example" would be the trigger itself, you're doing...

Code: Select all

  set mydialog = DialogCreate()
  call DialogSetMessage(mydialog,"You now have 30 seconds\n to vote on game modes")
  set mybuttons[0]=DialogAddButton(mydialog,"Don't Care",13)
  set mybuttons[1]=DialogAddButton(mydialog,"Normal Mode",78)
  set mybuttons[2]=DialogAddButton(mydialog,"Nuke Mode",75)
  set mybuttons[3]=DialogAddButton(mydialog,"Space Mode",83)
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[0])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[1])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[2])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[3])
  
You call the Event in another trigger, in that other trigger do..

Code: Select all

function init takes nothing returns nothing
local trigger t = CreateTrigger()
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[0])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[1])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[2])
  call TriggerRegisterDialogButtonEvent( TrigDialogClick, mybuttons[3])//Dunno why you're doing the buttonevents, You can //do    call TriggerRegisterDialogEvent( TrigDialogClick, mydialog ) and it works just fine
  call TriggerAddAction( Whatever function you want, then in that function just do a button check (if b == GetClickedButton) ) and do actions
endfunction
Then just modify the dialoginit trigger to..

Code: Select all

function dialoginit takes nothing returns nothing
The only problem I can point out in your "example" would be the trigger itself, you're doing...
[code]  set mydialog = DialogCreate()
  call DialogSetMessage(mydialog,"You now have 30 seconds\n to vote on game modes")
  set mybuttons[0]=DialogAddButton(mydialog,"Don't Care",13)
  set mybuttons[1]=DialogAddButton(mydialog,"Normal Mode",78)
  set mybuttons[2]=DialogAddButton(mydialog,"Nuke Mode",75)
  set mybuttons[3]=DialogAddButton(mydialog,"Space Mode",83)
  loop
    exitwhen i>5
    call DialogDisplay( Player(i), mydialog, true)
    set i=i+1
  endloop
endfunction
Oh, Make sure you init the variables AFTER init.
Image
Wanna learn to hack maps? --> Guide
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

Risen wrote:Dunno why you're doing the buttonevents, You can //do call TriggerRegisterDialogEvent( TrigDialogClick, mydialog ) and it works just fine
Like I said before, TriggerRegisterDialogEvent isn't working.

As for the rest, I'm not really sure what you are saying.
The first section of code (the one where the buttons are created and the dialogs displayed) is in a function that executes .2 seconds after the game starts

I uploaded the entire script if you want to look at it
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

Ozzapoo wrote:Show us your TriggerReisterEventButtonClicked line.
That's not even a valid function
If you meant TriggerRegisterDialogButtonEvent, then that's in the first post
User avatar
Ozzapoo
The Flying Cow!
Posts: 2196
Joined: November 2nd, 2007, 10:34 pm
Location: Melbourne

Re: Why won't GetClickedButton work?

Post by Ozzapoo »

Just upload the entire script.
Visit Ozzapoo.net, my blog and the home of AutoCP and Cheatpack Detector!
AutoCP3 now available for free!
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

I already uploaded it on page 1, but i guess I'll upload it again
You do not have the required permissions to view the files attached to this post.
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: Why won't GetClickedButton work?

Post by Aero »

Hard to get good help, isn't it storyyeller >.>.
Don't worry, I know you know what you're talking about.

Anyway, your problem was TriggerRegisterDialogButtonEvent.
GetClickedButton will return null.

You need to use TriggerRegisterDialogEvent.
I made a test map using it and it works 100%.

Code: Select all

globals
dialog mydialog
button array mybuttons
endglobals

function funcDialog takes nothing returns nothing
    local integer i=0
    local button b=GetClickedButton()
    loop
        exitwhen i>3                 
        if b == mybuttons[i] then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Button " + I2S(i) + " was selected") 
        endif
        set i=i+1
    endloop
    set b=null
endfunction

function Trig_Melee_Initialization_Actions takes nothing returns nothing
  local trigger t=CreateTrigger()
  local integer i=0
  set mydialog = DialogCreate()
  call DialogSetMessage(mydialog,"You now have 30 seconds\n to vote on game modes")
  set mybuttons[0]=DialogAddButton(mydialog,"Don't Care",13)
  set mybuttons[1]=DialogAddButton(mydialog,"Normal Mode",78)
  set mybuttons[2]=DialogAddButton(mydialog,"Nuke Mode",75)
  set mybuttons[3]=DialogAddButton(mydialog,"Space Mode",83)
  call TriggerRegisterDialogEvent(t,mydialog)
  call TriggerAddAction(t,function funcDialog)
  loop
    exitwhen i>5
    call DialogDisplay( Player(i), mydialog, true)
    set i=i+1
  endloop
  set t=null
endfunction

//===========================================================================
function InitTrig_Melee_Initialization takes nothing returns nothing
    set gg_trg_Melee_Initialization = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Melee_Initialization, 5 )
    call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
endfunction
You do not have the required permissions to view the files attached to this post.
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

Ok I got it working now. Thanks for the help

I think the problem was that I had accidentally gotten things out of order and was trying to add the event before I actually created the dialog.
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Why won't GetClickedButton work?

Post by Risen »

That's what I was saying... Lol, Wierd though, You used my version of it and it never worked...?
Image
Wanna learn to hack maps? --> Guide