Why won't GetClickedButton work?

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Why won't GetClickedButton work?

Post by storyyeller »

I've been trying to add a vote system, but it won't work. The trigger executes just fine, but it can't detect which button was pressed because
GetClickedButton() always returns null for some reason. Does anyone know what is going on?

Here is what my code looks like

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])
  
  loop
    exitwhen i>5
    call DialogDisplay( Player(i), mydialog, true)
    set i=i+1
  endloop

Code: Select all

function funcDialog takes nothing returns nothing
    local integer i=0
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"A dialog was clicked")
    loop
        exitwhen i>3                 
        if GetClickedButton() == mybuttons[i] then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Button " + I2S(i) + " was selected")  
        endif
        set i=i+1
    endloop
endfunction
Last edited by storyyeller on April 5th, 2009, 6:39 pm, edited 1 time in total.
User avatar
Ken
Spice Pirate
Posts: 862
Joined: January 29th, 2009, 5:35 pm
Title: LHC
Location: Canada

Re: Why won't GetClickedButton work?

Post by Ken »

Code: Select all

  loop
    exitwhen i>5
    call DialogDisplay( Player(i), mydialog, true)
    set i=i+1
  endloopn
endloopn?
Spoiler:
xkiska wrote:BARTIMEAUS is more understandable then u
Senethior459 wrote:Wow, Dream Theatre reminds me of Dragonforce, but with real skill.
Ozzapoo wrote:We laughed, we cried. Trashed.
FatherSpace: You don't find smart chicks hawt?
GeorgeMots: not anymore, im fed up with that kind of girls
FatherSpace: lol
FatherSpace: What happened?
GeorgeMots: most smart girls find out that i date/do/see other girls....
FatherSpace: ...
FatherSpace: So monogamy is your enemy?
Bartimaeus: Hmm, well, I hope my sister hasn't been kidnapped.
FatherSpace: What happened, Bart?
Bartimaeus: She walked out of the house saying that she was going over to some friends, and it's been like two hours, and my mom is trying to get a hold of her, which she's been unable to.
Bartimaeus: I can also hear three car alarms going off.
GeorgeMots: how old is she?
Bartimaeus: I haven't a clue. Probably 17.
UndeadxAssassin: wut
AbusivePie: You don't know how old your sister is?
Bartimaeus: Nope.
UndeadxAssassin: Epic fail
GeorgeMots: is she cute??
Bartimaeus: So, uh, how about you get into the Christmas spirit and put that avatar on before I do it myself and take away your bloody avatar-changin' rights?
UndeadxAssassin: If I thought of a random one...
UndeadxAssassin: Like....
UndeadxAssassin: I'll get back to you on that
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

That's not in the actual map. (Obviously if it was, it wouldn't run at all)

I must have accidentally added that while pasting my code in here
User avatar
Ken
Spice Pirate
Posts: 862
Joined: January 29th, 2009, 5:35 pm
Title: LHC
Location: Canada

Re: Why won't GetClickedButton work?

Post by Ken »

I'm going to assume you do have a 'call TriggerAddAction' for this, right?

That's all I can see that would possibly be a problem... Or maybe changing the GetLocalPlayer() to GetTriggerPlayer().
Spoiler:
xkiska wrote:BARTIMEAUS is more understandable then u
Senethior459 wrote:Wow, Dream Theatre reminds me of Dragonforce, but with real skill.
Ozzapoo wrote:We laughed, we cried. Trashed.
FatherSpace: You don't find smart chicks hawt?
GeorgeMots: not anymore, im fed up with that kind of girls
FatherSpace: lol
FatherSpace: What happened?
GeorgeMots: most smart girls find out that i date/do/see other girls....
FatherSpace: ...
FatherSpace: So monogamy is your enemy?
Bartimaeus: Hmm, well, I hope my sister hasn't been kidnapped.
FatherSpace: What happened, Bart?
Bartimaeus: She walked out of the house saying that she was going over to some friends, and it's been like two hours, and my mom is trying to get a hold of her, which she's been unable to.
Bartimaeus: I can also hear three car alarms going off.
GeorgeMots: how old is she?
Bartimaeus: I haven't a clue. Probably 17.
UndeadxAssassin: wut
AbusivePie: You don't know how old your sister is?
Bartimaeus: Nope.
UndeadxAssassin: Epic fail
GeorgeMots: is she cute??
Bartimaeus: So, uh, how about you get into the Christmas spirit and put that avatar on before I do it myself and take away your bloody avatar-changin' rights?
UndeadxAssassin: If I thought of a random one...
UndeadxAssassin: Like....
UndeadxAssassin: I'll get back to you on that
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

Yeah I have all that. You can also safely assume that I declared all my variables and stuff like that. Like I said, the trigger runs perfectly.

The problem is that GetClickedButton() is returning NULL for some reason
User avatar
Ken
Spice Pirate
Posts: 862
Joined: January 29th, 2009, 5:35 pm
Title: LHC
Location: Canada

Re: Why won't GetClickedButton work?

Post by Ken »

This is a guess based on looking at a map...

Code: Select all

call DialogAddButton(mydialog,"Don't Care",13)
set mybuttons[0]=GetLastCreatedButtonBJ()
And do that for each of the buttons. Or try TriggerRegisterDialogEvent.
Spoiler:
xkiska wrote:BARTIMEAUS is more understandable then u
Senethior459 wrote:Wow, Dream Theatre reminds me of Dragonforce, but with real skill.
Ozzapoo wrote:We laughed, we cried. Trashed.
FatherSpace: You don't find smart chicks hawt?
GeorgeMots: not anymore, im fed up with that kind of girls
FatherSpace: lol
FatherSpace: What happened?
GeorgeMots: most smart girls find out that i date/do/see other girls....
FatherSpace: ...
FatherSpace: So monogamy is your enemy?
Bartimaeus: Hmm, well, I hope my sister hasn't been kidnapped.
FatherSpace: What happened, Bart?
Bartimaeus: She walked out of the house saying that she was going over to some friends, and it's been like two hours, and my mom is trying to get a hold of her, which she's been unable to.
Bartimaeus: I can also hear three car alarms going off.
GeorgeMots: how old is she?
Bartimaeus: I haven't a clue. Probably 17.
UndeadxAssassin: wut
AbusivePie: You don't know how old your sister is?
Bartimaeus: Nope.
UndeadxAssassin: Epic fail
GeorgeMots: is she cute??
Bartimaeus: So, uh, how about you get into the Christmas spirit and put that avatar on before I do it myself and take away your bloody avatar-changin' rights?
UndeadxAssassin: If I thought of a random one...
UndeadxAssassin: Like....
UndeadxAssassin: I'll get back to you on that
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Why won't GetClickedButton work?

Post by storyyeller »

FatherSpace wrote:This is a guess based on looking at a map...

Code: Select all

call DialogAddButton(mydialog,"Don't Care",13)
set mybuttons[0]=GetLastCreatedButtonBJ()
And do that for each of the buttons. Or try TriggerRegisterDialogEvent.
Actually, that wouldn't work because DialogAddButton does not set bj_lastCreatedButton, so mybuttons[] would end up as null.
You were probably thinking of DialogAddButtonBJ, in which case, you would omit the last argument

Anyway, that is just a more complicated and inefficient way of doing the same thing my code does already.


As for TriggerRegisterDialogEvent, I already tried that
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Why won't GetClickedButton work?

Post by Risen »

Actually, I kinda wrote a dialog library a few mins ago, Here's the pastebin for it, It works completely so just rename it or w/e.
http://pastebin.com/d2de352a5
http://pastebin.com/d5abeaa3a
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 »

I tried your code, and it didn't work either
Not terribly surprising, since it is very similar to what I wrote

As far as I can tell, neither TriggerRegisterDialogEvent, nor GetButtonClicked are working

Edit: I attached the war3map.j file in case it helps
You do not have the required permissions to view the files attached to this 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 »

Show us your TriggerReisterEventButtonClicked line.
Visit Ozzapoo.net, my blog and the home of AutoCP and Cheatpack Detector!
AutoCP3 now available for free!