Online Players Dialog

futeki

Active Member
Reaction score
4
Considering my other post was misunderstood awhile ago, I'm re-addressing this issue. I want the triggering player to be able to pick from a list of the online players (excluding themselves) and have that choice show.

This trigger works fine the first time it's launched, but for some reason, it shows 2 messages the second time, 3 the third. Perhaps I'm going about this the wrong way?

Trigger:
  • Dialog
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Rod Stewart's Hair Piece
    • Actions
      • Set OnlinePlayers = (All players matching (((Matching player) slot status) Equal to Is playing))
      • Set PlayersUser = (All players controlled by a User player)
      • Dialog - Clear PlayerDialog
      • Dialog - Change the title of PlayerDialog to Players
      • Player Group - Pick every player in OnlinePlayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) is in OnlinePlayers) Equal to True
              • ((Picked player) is in PlayersUser) Equal to True
              • (Picked player) Not equal to (Triggering player)
            • Then - Actions
              • Dialog - Create a dialog button for PlayerDialog labelled (Name of (Picked player))
              • Set PlayerDialogButton[(Player number of (Picked player))] = (Last created dialog Button)
            • Else - Actions
              • Do nothing
      • Dialog - Create a dialog button for PlayerDialog labelled Cancel
      • Dialog - Show PlayerDialog for (Triggering player)
      • Trigger - Add to Clicked <gen> the event (Dialog - A dialog button is clicked for PlayerDialog)
      • Item - Remove (Item being manipulated)

Second Trigger:
Trigger:
  • Clicked
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to PlayerDialogButton[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) the text: (You've chosen: + (Name of (Player((Integer A)))))
            • Else - Actions
 

Tyman2007

Ya Rly >.
Reaction score
74
Second Trigger:
Trigger:
  • Clicked
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to PlayerDialogButton[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) the text: (You've chosen: + (Name of (Player((Integer A)))))
            • Else - Actions

The problem lies in this trigger.

You see, every time this trigger is ran, it adds in a new event to a trigger. For every event that's ran, the actions will be ran.

So, if you have 5 of the same events, it will run the actions 5 times if the event has happened and the condition is met.

Unfortunately, WC3's limitation is that you cannot remove events. T.T
 

futeki

Active Member
Reaction score
4
The problem lies in this trigger.

You see, every time this trigger is ran, it adds in a new event to a trigger. For every event that's ran, the actions will be ran.

So, if you have 5 of the same events, it will run the actions 5 times if the event has happened and the condition is met.

Unfortunately, WC3's limitation is that you cannot remove events. T.T

So what's a solution? Should I be doing this differently?
 

Moridin

Snow Leopard
Reaction score
144
One way you could do it is, use a boolean condition to make sure that the event is only added once?

Replace this line:

Trigger - Add to Clicked <gen> the event (Dialog - A dialog button is clicked for PlayerDialog)

with this:

Code:
If (All conditions are true) then do (then actions) else do (else actions)
   If - Conditions
        Boolean_Event Equal to False
   then - actions
        Trigger - Add to Clicked <gen> the event (Dialog - A dialog button is clicked for PlayerDialog)
        Set Boolean_Event = True
   else - actions

You have to make sure that boolean variable is not used anywhere else.
 

futeki

Active Member
Reaction score
4
One way you could do it is, use a boolean condition to make sure that the event is only added once?
I wanted to make sure this was the best way possible to find the player clicked:
Trigger:
  • Clicked
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to PlayerDialogButton[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) the text: (You&#039;ve chosen: + (Name of (Player((Integer A)))))
            • Else - Actions

Using a conditional statement makes it unusable to another player down the road. This is a trigger that might be run 40-50 times during a game.
 

Moridin

Snow Leopard
Reaction score
144
Well, your current triggers should work fine :S. It should be able to run as many times as you want, as long as you use the same dialog variable.

The conditional statement won't make it unusable. It will only limit the number of events created. Because your event is a generic "A dialog button is clicked for PlayerDialog", as long as you keep using "PlayerDialog" it'll work fine.

Edit: Does it not work for some reason? :S

Also, yes that is the best way to find the dialog button clicked.
 

futeki

Active Member
Reaction score
4
Upon [expletive] around with it more, the solution was rather simple. Remove the manner in which the second trigger was fired.

Remove this in the Dialog trigger:
Trigger:
  • Trigger - Add to Clicked &lt;gen&gt; the event (Dialog - A dialog button is clicked for PlayerDialog)


Replace with this in the Clicked trigger:
Trigger:
  • Events
    • Dialog - A dialog button is clicked for PlayerDialog

Fires only once, no more double or triple firing, and now I can sleep peacefully tonight.

EDIT: type-toes
 

futeki

Active Member
Reaction score
4
What's a good way to use the dialog for other triggers?

I notice there's really no way to pass multiple variables through a single click, or is there that I'm missing?
 

Moridin

Snow Leopard
Reaction score
144
What's a good way to use the dialog for other triggers?
Could you elaborate? I don't exactly understand what you mean by this. What do you want to achieve?

I notice there's really no way to pass multiple variables through a single click, or is there that I'm missing?
Again, I don't know what you mean by 'passing multiple variables'.
 

futeki

Active Member
Reaction score
4
Could you elaborate? I don't exactly understand what you mean by this. What do you want to achieve?
For instance, say I want to reuse the Dialog of all online players for another trigger so I need to differentiate between the Clicked trigger and another trigger, say, Clicked 2 so that it doesn't fire off Clicked along with Clicked 2.

By what they're choosing here:
Trigger:
  • Then - Actions
    • Dialog - Create a dialog button for PlayerDialog labelled (Name of (Picked player))
    • Set PlayerDialogButton[(Player number of (Picked player))] = (Last created dialog Button)

It's passing the variable (Player Number) of that dialog button to the Clicked trigger. What if I want to use the dialog again for an entirely separate trigger? Make sense?
 

GenDeath

New Member
Reaction score
6
What's a good way to use the dialog for other triggers?
Assuming I understood what you meant.
I think dialog menus are good for "settings" I also find it a convenient route for managing alliances especially in a map with unique alliance settings.
 

futeki

Active Member
Reaction score
4
Assuming I understood what you meant.
I think dialog menus are good for "settings" i also find it a convenient route for managing alliances especially in a map with unique alliances
I meant to say "What's a good way to reuse the dialog for other triggers?"

But needless to say, I think it seems smarter to simply create new dialog variables rather than try reusing those dialog variables.
 

Moridin

Snow Leopard
Reaction score
144
It's passing the variable (Player Number) of that dialog button to the Clicked trigger. What if I want to use the dialog again for an entirely separate trigger? Make sense?
Yeah I get what you mean. You could switch off Clicked and switch on Clicked 2? There must be some condition which you can use to differentiate between using Clicked and Clicked 2...?
 

GenDeath

New Member
Reaction score
6
I didnt see the post between mine and moridin.
I believe the concept you were talking about will work. GL with your map.
 

futeki

Active Member
Reaction score
4
Yeah I get what you mean. You could switch off Clicked and switch on Clicked 2? There must be some condition which you can use to differentiate between using Clicked and Clicked 2...?
The turning off isn't going to work.

I've been trying to think of a way to set a condition, but that's where I'm drawing blanks. My first idea was to create another dialog button variable, set that to 1 and then look for that in the Clicked trigger, but there's obviously a big issue, the loop. It would reset the variable for each player as it goes through all of the players, making it a waste of time.

The other ideas I had would involve more variables than the 2 it takes every time I create another online players dialog, and considering I would at most use the dialog 3-4 more times it just doesn't seem worth it.
 

Moridin

Snow Leopard
Reaction score
144
You could create another dialog variable while using the same dialog buttons? That way you have seperate events?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top