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

Vote for Share Control as Ref/Obs

Status
Not open for further replies.
Level 5
Joined
Jul 18, 2007
Messages
110
Need help with a vote that allows a Referee/Observer to enter the game through share control with the leaving player. They type -enter # and then there is 60% of votes required to pass it (-yes/-no). Also having some issues to not allow a player to vote more than once/spam command.

The trigger is not going past RTPercent Greater than or equal to 0.60 and the test string below it. This is in GUI, but JASS would work. I can only provide screenshots, currently, but I will update this ASAP. Thank you for the help, much appreciated.

  • Enter Spec Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Enter Spec 2 <gen> the event (Player - (Picked player) types a chat message containing -yes as An exact match)
          • Trigger - Add to Enter Spec 2 <gen> the event (Player - (Picked player) types a chat message containing -no as An exact match)

  • Enter Spec
    • Events
      • Player - Player 21 (Coal) types a chat message containing -enter as A substring
      • Player - Player 22 (Snow) types a chat message containing -enter as A substring
      • Player - Player 23 (Emerald) types a chat message containing -enter as A substring
      • Player - Player 24 (Peanut) types a chat message containing -enter as A substring
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 24, do (Set VariableSet HasVoted[(Integer A)] = False)
      • Set VariableSet PlayerWhoMightBeSwapped = (Integer((Substring((Entered chat string), 8, 9))))
      • Set VariableSet TempPlayer = (Triggering player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Player(PlayerWhoMightBeSwapped)) slot status) Equal to Is playing
        • Then - Actions
          • Game - Display to (All players) for 6.00 seconds the text: ((Name of (Player(PlayerWhoMightBeSwapped))) + |cff92BBCF's slot is still occupied.|r)
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player number of TempPlayer) Equal to PlayerWhoMightBeSwapped) or ((PlayerWhoMightBeSwapped Less than 1) or (PlayerWhoMightBeSwapped Greater than 12))
        • Then - Actions
          • Game - Display to (All players) for 6.00 seconds the text: |cFFA40000Not a val...
        • Else - Actions
          • Game - Display to (All players) for 6.00 seconds the text: ((Name of TempPlayer) + (|cff92BBCF has initialized a vote to enter the game as a spectator for |r + ((Name of (Player(PlayerWhoMightBeSwapped))) + |cff92BBCF Type -yes to allow the vote and -no to deny it. You have 30 seconds remaining.|r)))
          • Set VariableSet ShowText = True
          • Trigger - Turn on Enter Spec 2 <gen>
          • Trigger - Turn off (This trigger)
          • Wait 30.00 seconds
          • Trigger - Turn off Enter Spec 2 <gen>
          • Trigger - Turn on (This trigger)
  • Enter Spec 2
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HasVoted[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 6.00 seconds the text: |cff92BBCFSorry, yo...
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -yes
        • Then - Actions
          • Set VariableSet NumVotes[PlayerWhoMightBeSwapped] = (NumVotes[PlayerWhoMightBeSwapped] + 1)
          • Set VariableSet HasVoted[(Player number of (Triggering player))] = True
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -no
        • Then - Actions
          • Set VariableSet HasVoted[(Player number of (Triggering player))] = True
        • Else - Actions
      • Set VariableSet RefPercent = ((Real(NumVotes[PlayerWhoMightBeSwapped])) / (Real(NumPlayersInteger)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RefPercent Less than 0.60
        • Then - Actions
          • Game - Display to (All players) for 6.00 seconds the text: ((String(VoteYes)) + (|cff92BBCF out of |r + ((String(VoteTotal)) + (|cff92BBCF votes have been cast for the spectator to enter the game. |r + ((String((Max(0, ((VoteTotal / 2) - VoteYes))))) + |cff92BBCF more enable votes are required. Please type -yes and -
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RefPercent Greater than or equal to 0.20
        • Then - Actions
          • Player - Make (Player(PlayerWhoMightBeSwapped)) treat TempPlayer as an Ally with shared vision
          • Player - Make TempPlayer treat (Player(PlayerWhoMightBeSwapped)) as an Ally with shared vision
          • Player - For TempPlayer, turn Full shared units On toward (Player(PlayerWhoMightBeSwapped))
          • Player - For (Player(PlayerWhoMightBeSwapped)), turn Full shared units On toward TempPlayer
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(PlayerWhoMightBeSwapped)) is in Force1.) Equal to True
            • Then - Actions
              • Player Group - Pick every player in Force1 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Ally with shared vision
                  • Player - Make TempPlayer treat (Picked player) as an Ally with shared vision
              • Player Group - Pick every player in Force2 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Enemy
                  • Player - Make TempPlayer treat (Picked player) as an Enemy
            • Else - Actions
              • Player Group - Pick every player in Force2 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Ally with shared vision
                  • Player - Make TempPlayer treat (Picked player) as an Ally with shared vision
              • Player Group - Pick every player in Force1 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Enemy
                  • Player - Make TempPlayer treat (Picked player) as an Enemy
          • Game - Display to (All players) the text: ((Name of TempPlayer) + (|CFF007E00 has entered the game for + (Name of (Player(PlayerWhoMightBeSwapped)))))
          • Trigger - Turn off Enter Spec 2 <gen>
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Everything looks fine aside from this variable: NumPlayersInteger

Unless this is set in another trigger, it isn't being set to anything. You're probably dividing your Yes Votes by 0.

Another thing, I'm assuming if a player doesn't vote then their vote is defaulted to No (0). If this is the case then you need to reset everyone's vote back to 0 after you've calculated the RTPercent. You should also reset HasVoted to False as well. This way in future votes all players will be back to their default values.

For debugging in the future, when you know exactly where the trigger breaks then it's easy to display some text messages of the associated variables to find your problem. If you display RTPercent after setting it, and it comes up with some weird result, then you know something went wrong in the calculation.
 
Last edited:
Level 5
Joined
Jul 18, 2007
Messages
110
Everything looks fine aside from this variable: NumPlayersInteger

Unless this is set in another trigger, it isn't being set to anything. You're probably dividing your Yes Votes by 0.

Another thing, I'm assuming if a player doesn't vote then their vote is defaulted to No (0). If this is the case then you need to reset everyone's vote back to 0 after you've calculated the RTPercent. You should also reset HasVoted to False as well. This way in future votes all players will be back to their default values.

For debugging in the future, when you know exactly where the trigger breaks then it's easy to display some text messages of the associated variables to find your problem. If you display RTPercent after setting it, and it comes up with some weird result, then you know something went wrong in the calculation.
Yeah, NumPlayersInteger is set in another trigger and I also fixed the reset thing as well but forgot to post the edit. The issue was still that it isn't running that test string and subsequent actions under the greater than 60% percent check. I will try to display the number beforehand.
 
Level 5
Joined
Jul 18, 2007
Messages
110
So a new update, I was able to get everything to work, except the share control. For some reason, it will just share and unshare and I have no idea why, I updated the triggers in the first post but I will post that part here:


  • Enter Spec 2
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HasVoted[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 6.00 seconds the text: |cff92BBCFSorry, yo...
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -yes
        • Then - Actions
          • Set VariableSet NumVotes[PlayerWhoMightBeSwapped] = (NumVotes[PlayerWhoMightBeSwapped] + 1)
          • Set VariableSet HasVoted[(Player number of (Triggering player))] = True
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -no
        • Then - Actions
          • Set VariableSet HasVoted[(Player number of (Triggering player))] = True
        • Else - Actions
      • Set VariableSet RefPercent = ((Real(NumVotes[PlayerWhoMightBeSwapped])) / (Real(NumPlayersInteger)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RefPercent Less than 0.60
        • Then - Actions
          • Game - Display to (All players) for 6.00 seconds the text: ((String(VoteYes)) + (|cff92BBCF out of |r + ((String(VoteTotal)) + (|cff92BBCF votes have been cast for the spectator to enter the game. |r + ((String((Max(0, ((VoteTotal / 2) - VoteYes))))) + |cff92BBCF more enable votes are required. Please type -yes and -
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RefPercent Greater than or equal to 0.20
        • Then - Actions
          • Player - Make (Player(PlayerWhoMightBeSwapped)) treat TempPlayer as an Ally with shared vision
          • Player - Make TempPlayer treat (Player(PlayerWhoMightBeSwapped)) as an Ally with shared vision
          • Player - For TempPlayer, turn Full shared units On toward (Player(PlayerWhoMightBeSwapped))
          • Player - For (Player(PlayerWhoMightBeSwapped)), turn Full shared units On toward TempPlayer
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(PlayerWhoMightBeSwapped)) is in Force1.) Equal to True
            • Then - Actions
              • Player Group - Pick every player in Force1 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Ally with shared vision
                  • Player - Make TempPlayer treat (Picked player) as an Ally with shared vision
              • Player Group - Pick every player in Force2 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Enemy
                  • Player - Make TempPlayer treat (Picked player) as an Enemy
            • Else - Actions
              • Player Group - Pick every player in Force2 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Ally with shared vision
                  • Player - Make TempPlayer treat (Picked player) as an Ally with shared vision
              • Player Group - Pick every player in Force1 and do (Actions)
                • Loop - Actions
                  • Player - Make (Picked player) treat TempPlayer as an Enemy
                  • Player - Make TempPlayer treat (Picked player) as an Enemy
          • Game - Display to (All players) the text: ((Name of TempPlayer) + (|CFF007E00 has entered the game for + (Name of (Player(PlayerWhoMightBeSwapped)))))
          • Trigger - Turn off Enter Spec 2 <gen>
        • Else - Actions
I've tried removing and limiting the Share Controls to one each as well. Any help would be greatly appreciated!
 
Level 5
Joined
Jul 18, 2007
Messages
110
Figured it out, the duplicating pick force 1/2 to ally everyone was causing an error and briefly unsharing control to break the code. I simply took the swapping player out of the respective force before I allied them.
 
Last edited:
Status
Not open for further replies.
Top