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

[Trigger] Voting Trigger With String (no dialog boxes)

Status
Not open for further replies.
Level 1
Joined
Feb 10, 2020
Messages
3
Hello, I need help with a trigger that would require the players to type something like -activatemode or -am at any point in the game. This would then begin a vote that can last indefinitely, doesn't have to expire. This is a 12-person map, and after an over 50% vote, the mode would turn on. I'm having trouble finding out how to prevent the player from voting on it multiple times and to find the most efficient way to create the whole system. I know that it takes two triggers, one for the votes and the checks. Any help showing the triggers would be greatly appreciated!
 
Level 39
Joined
Feb 27, 2007
Messages
5,031
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types ACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types DEACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types YES_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types NO_VOTE_STRING as an exact match)
  • Events
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Entered chat string) equal to ACTIVATE_MODE_VOTE_STRING
      • Then - Actions
        • Set ModeVote = True
      • Else - Actions
        • Set ModeVote = False
  • Events
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Entered chat string) equal to YES_VOTE_STRING
      • Then - Actions
        • Set PlayerVote[(Player number of (Triggering Player))] = 1
      • Else - Actions
        • Set PlayerVote[(Player number of (Triggering Player))] = 0
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • ModeVote equal to False
      • Then - Actions
        • Skip remaining actions
      • Else - Actions
    • Set VoteTotal = 0
    • Set VoteYes = 0
    • For each (Integer A) from 1 to 24 do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Player(Integer A)) slot status equal to Is Playing
            • (Player(Integer A)) controller equal to User //this might be unnecessary if you don't loop over numbers that are computers
          • Then - Actions
            • Set VoteTotal = (VoteTotal + 1)
            • Set VoteYes = (VoteYes + PlayerVote[(Integer A)])
          • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (VoteYes x 2) greater than or equal to VoteTotal
      • Then - Actions
        • Trigger - Turn off SECOND TRIGGER
        • Trigger - Turn off THIRD TRIGGER
        • -------- do mode start stuff here --------
      • Else - Actions
 
Level 1
Joined
Feb 10, 2020
Messages
3
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types ACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types DEACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types YES_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types NO_VOTE_STRING as an exact match)
  • Events
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Entered chat string) equal to ACTIVATE_MODE_VOTE_STRING
      • Then - Actions
        • Set ModeVote = True
      • Else - Actions
        • Set ModeVote = False
  • Events
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (Entered chat string) equal to YES_VOTE_STRING
      • Then - Actions
        • Set PlayerVote[(Player number of (Triggering Player))] = 1
      • Else - Actions
        • Set PlayerVote[(Player number of (Triggering Player))] = 0
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • ModeVote equal to False
      • Then - Actions
        • Skip remaining actions
      • Else - Actions
    • Set VoteTotal = 0
    • Set VoteYes = 0
    • For each (Integer A) from 1 to 24 do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Player(Integer A)) slot status equal to Is Playing
            • (Player(Integer A)) controller equal to User //this might be unnecessary if you don't loop over numbers that are computers
          • Then - Actions
            • Set VoteTotal = (VoteTotal + 1)
            • Set VoteYes = (VoteYes + PlayerVote[(Integer A)])
          • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • (VoteYes x 2) greater than or equal to VoteTotal
      • Then - Actions
        • Trigger - Turn off SECOND TRIGGER
        • Trigger - Turn off THIRD TRIGGER
        • -------- do mode start stuff here --------
      • Else - Actions
Thank you so much! Just a few questions.

  • Actions
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types ACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to SECOND_TRIGGER the event (Player - (Picked player) types DEACTIVATE_MODE_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types YES_VOTE_STRING as an exact match)
        • Trigger - Add to THIRD_TRIGGER the event (Player - (Picked player) types NO_VOTE_STRING as an exact match)
What exactly does this do?

To turn on the mode, I have the command the same as the one to start the vote, so it would be -activatemode or -am. Can I just replace this:

  • (Entered chat string) equal to YES_VOTE_STRING
with -activatemode or -am and it would still work fine?

  • For each (Integer A) from 1 to 24 do (Actions)
Should this be 1 to 12 since it's a 12 person map? There is two observers sometimes and I was thinking observers might bug this.

  • (VoteYes + PlayerVote[(Integer A)])
Lastly, Would this this cause it to only activate after 50%? Was just curious how it works, thanks!
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,031
The 2nd and 3rd triggers above don’t have any events; they are added by the first trigger. I did it this way because the chat events don’t have a generic “a player types...” event and they have to be written manually for all players. Doing it as a loop saves editor time but is functionally the same as writing out all 24 events per trigger.

Things like YES_VOTE_STRING I intended for you to replace with whatever chat message you wanted to use.

Yes you should change the loop to be 1-12.

The reason I wrote it like that is that integer division truncates and doesn’t round. 7/10 = 0 in integer division, thus doing VoteYes/VoteTotal wouldn’t give you the percentage. To get that you’d have to convert one of them to a real first and I think that looks ugly. Multiplying by two and comparing it is the same operation.
 
Level 1
Joined
Feb 10, 2020
Messages
3
The 2nd and 3rd triggers above don’t have any events; they are added by the first trigger. I did it this way because the chat events don’t have a generic “a player types...” event and they have to be written manually for all players. Doing it as a loop saves editor time but is functionally the same as writing out all 24 events per trigger.

Things like YES_VOTE_STRING I intended for you to replace with whatever chat message you wanted to use.

Yes you should change the loop to be 1-12.

The reason I wrote it like that is that integer division truncates and doesn’t round. 7/10 = 0 in integer division, thus doing VoteYes/VoteTotal wouldn’t give you the percentage. To get that you’d have to convert one of them to a real first and I think that looks ugly. Multiplying by two and comparing it is the same operation.
Thank you. The PlayerVote array should just be size 1? Also, if I wanted to embed a text to announce how many votes are needed to enable the mode, how would I go about doing that?
 
Status
Not open for further replies.
Top