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
 
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
 
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?
 
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.
 
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.
 
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.
 
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
 
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?
 
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'.
 
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?
 
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.
 
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.
 
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...?
 
I didnt see the post between mine and moridin.
I believe the concept you were talking about will work. GL with your map.
 
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.
 
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 The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      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