[Solved] Enable/Disable some tips with cmd

Status
Not open for further replies.
Level 11
Joined
Jun 20, 2017
Messages
380
How can I enable/disable them in 1 trigger instead of 4?!
  • Tips
    • Events
      • Player - Player 1 (Red) types a chat message containing -tips as An exact match
      • Player - Player 2 (Blue) types a chat message containing -tips as An exact match
      • Player - Player 3 (Teal) types a chat message containing -tips as An exact match
      • Player - Player 4 (Purple) types a chat message containing -tips as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -tips as An exact match
      • Player - Player 6 (Orange) types a chat message containing -tips as An exact match
      • Player - Player 7 (Green) types a chat message containing -tips as An exact match
      • Player - Player 8 (Pink) types a chat message containing -tips as An exact match
      • Player - Player 9 (Gray) types a chat message containing -tips as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -tips as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -tips as An exact match
      • Player - Player 12 (Brown) types a chat message containing -tips as An exact match
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (==) -tips on
        • Then - Actions
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (==) -tips off
            • Then - Actions
              • Game - Display to PlayerGroup_Humans the text: |cffffcc00Tip:|r |c...
            • Else - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (==) -tips on
        • Then - Actions
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
          • Wait 15.00 seconds
          • Sound - Play Hint <gen>
          • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (==) -tips off
            • Then - Actions
              • Game - Display to PlayerGroup_Vampires the text: |cffffcc00Tip:|r |c...
            • Else - Actions
 
Level 42
Joined
Feb 27, 2007
Messages
5,273
Your question is unclear, since you only posted one trigger. What four? What can't you figure out how to combine into a single trigger? Why is what you posted not sufficient? Your event is wrong, you should be listening for -tips on not -tips.

The way you have it written now if I spam -tips on multiple times in a row it will flood the screen with tips messages for every player, which could be used to troll them or make the screen unreadable; typing -tips off doesn't stop all the instances of this trigger that are in the middle of waiting. Realistically the tips should be shown on a per-player basis or even a per-team basis (right now anyone typing -tips on shows tips for all players on all teams) but I guess that's up to you. Use a timer and pause it if tips are turned off while displaying. Use some variables to make the tips modular; if you do want to make them shown on a per-player or per-team basis this will make that much easier.

  • Events
    • Time - Elapsed game-time is 0.00 seconds
  • Conditions
  • Actions
    • Set TipFrequency = 15.00
    • Set TipsTotal = 5
    • Set TipCounter = 1 //what tip to start on
    • -------- --------
    • Set HumanTipsOff = |cffffcc00Tip:|r |c...
    • Set HumanTips[1] = |cffffcc00Tip:|r |c...
    • Set HumanTips[2] = |cffffcc00Tip:|r |c...
    • Set HumanTips[3] = |cffffcc00Tip:|r |c...
    • Set HumanTips[4] = |cffffcc00Tip:|r |c...
    • Set HumanTips[5] = |cffffcc00Tip:|r |c...
    • -------- --------
    • Set VampireTipsOff = |cffffcc00Tip:|r |c...
    • Set VampireTips[1] = |cffffcc00Tip:|r |c...
    • Set VampireTips[2] = |cffffcc00Tip:|r |c...
    • Set VampireTips[3] = |cffffcc00Tip:|r |c...
    • Set VampireTips[4] = |cffffcc00Tip:|r |c...
    • Set VampireTips[5] = |cffffcc00Tip:|r |c...
  • Events
    • Player - Player 1 (Red) types a chat message containing -tips on as an exact match //note the event change
    • Player - Player 2 (Blue) types a chat message containing -tips on as an exact match
    • ...
  • Conditions
    • TipsOn equal to false
  • Actions
    • Sound - Play Hint <gen>
    • Game - Display to PlayerGroup_Humans the text HumanTips[TipCounter]
    • Game - Display to PlayerGroup_Vampires the text VampireTips[TipCounter]
    • Countdown Timer - Start TipsTimer as a repeating timer that will expire in TipFrequency seconds
  • Events
    • Player - Player 1 (Red) types a chat message containing -tips off as an exact match
    • Player - Player 2 (Blue) types a chat message containing -tips off as an exact match
    • ...
  • Conditions
    • TipsOn equal to true
  • Actions
    • Sound - Play Hint <gen>
    • Game - Display to PlayerGroup_Humans the text HumanTipsOff
    • Game - Display to PlayerGroup_Vampires the text VampireTipsOff
    • Countdown Timer - Pause TipsTimer
  • Events
    • Time - TipsTimer expires
  • Conditions
  • Actions
    • Set TipCounter = TipCounter + 1
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • TipCounter Greater than TipsTotal
      • Then - Actions
        • Set TipCounter = 1
      • Else - Actions
    • Sound - Play Hint <gen>
    • Game - Display to PlayerGroup_Humans the text HumanTips[TipCounter]
    • Game - Display to PlayerGroup_Vampires the text VampireTips[TipCounter]
 
Level 11
Joined
Jun 20, 2017
Messages
380
Wow excellent, but when I typing (tips off) nothing happens, and the tips are still repeating! and I changed the tips for per player to avoid trolling(not sure ;d)

  • Tips
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Real_TipsFrequency = 15.00
      • Set Integer_TipsTotal = 5
      • Set Integer_TipsCounter = 1
      • -------- Human Tips --------
      • Set String_TipsHumansOff = |cffffcc00Tip:|r |cff0080ffTips were turned off, Type -tips on to enable tips.|r
      • Set Strings_TipsHumans[1] = tips1.
      • Set Strings_TipsHumans[2] = tips2.
      • Set Strings_TipsHumans[3] = tips3.
      • Set Strings_TipsHumans[4] = tips4.
      • Set Strings_TipsHumans[5] = tips5.
      • -------- Vampire Tips --------
      • Set String_TipsVampiresOff = |cffffcc00Tip:|r |cffff0000Tips were turned off, Type -tips on to enable tips.|r
      • Set Strings_TipsVampires[1] = tips1.
      • Set Strings_TipsVampires[2] = tips2.
      • Set Strings_TipsVampires[3] = tips3.
      • Set Strings_TipsVampires[4] = tips4.
      • Set Strings_TipsVampires[5] = tips5.
  • Tips2
    • Events
      • Time - Timer_Tips expires
    • Conditions
    • Actions
      • Set Integer_TipsCounter = (Integer_TipsCounter + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Integer_TipsCounter Greater than (>) Integer_TipsTotal
          • Then - Actions
            • Set Integer_TipsCounter = 1
          • Else - Actions
      • Sound - Play Hint <gen>
      • Game - Display to (Player group((Triggering player))) the text: Strings_TipsHumans[Integer_TipsCounter]
      • Game - Display to (Player group((Triggering player))) the text: Strings_TipsVampires[Integer_TipsCounter]
  • Tips On
    • Events
      • Player - Player 1 (Red) types a chat message containing -tips on as An exact match
      • Player - Player 2 (Blue) types a chat message containing -tips on as An exact match
      • Player - Player 3 (Teal) types a chat message containing -tips on as An exact match
      • Player - Player 4 (Purple) types a chat message containing -tips on as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -tips on as An exact match
      • Player - Player 6 (Orange) types a chat message containing -tips on as An exact match
      • Player - Player 7 (Green) types a chat message containing -tips on as An exact match
      • Player - Player 8 (Pink) types a chat message containing -tips on as An exact match
      • Player - Player 9 (Gray) types a chat message containing -tips on as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -tips on as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -tips on as An exact match
      • Player - Player 12 (Brown) types a chat message containing -tips on as An exact match
    • Conditions
      • Boolean_TipsOn Equal to (==) False
    • Actions
      • Sound - Play Hint <gen>
      • Game - Display to (Player group((Triggering player))) the text: Strings_TipsHumans[Integer_TipsCounter]
      • Game - Display to (Player group((Triggering player))) the text: Strings_TipsVampires[Integer_TipsCounter]
      • Countdown Timer - Start Timer_Tips as a Repeating timer that will expire in Real_TipsFrequency seconds
  • Tips Off
    • Events
      • Player - Player 1 (Red) types a chat message containing -tips off as An exact match
      • Player - Player 2 (Blue) types a chat message containing -tips off as An exact match
      • Player - Player 3 (Teal) types a chat message containing -tips off as An exact match
      • Player - Player 4 (Purple) types a chat message containing -tips off as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -tips off as An exact match
      • Player - Player 6 (Orange) types a chat message containing -tips off as An exact match
      • Player - Player 7 (Green) types a chat message containing -tips off as An exact match
      • Player - Player 8 (Pink) types a chat message containing -tips off as An exact match
      • Player - Player 9 (Gray) types a chat message containing -tips off as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -tips off as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -tips off as An exact match
      • Player - Player 12 (Brown) types a chat message containing -tips off as An exact match
    • Conditions
      • Boolean_TipsOn Equal to (==) True
    • Actions
      • Sound - Play Hint <gen>
      • Game - Display to (Player group((Triggering player))) the text: String_TipsHumansOff
      • Game - Display to (Player group((Triggering player))) the text: String_TipsVampiresOff
      • Countdown Timer - Pause Timer_Tips
 
Level 42
Joined
Feb 27, 2007
Messages
5,273
To both of you: Why not use as a substring? It seems way faster and it combines 2 triggers into one.
Could have done that but I thought it needed some nested if-blocks that sounded ugly to me. I was tired and wrong.
  • Events
    • Player - Player 1 (Red) types a chat message containing -tips as a substring
    • ...
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • Substring(Entered Chat String, 7, 8) equal to on
        • Boolean_TipsOn equal to false
      • Then - Actions
        • Sound - Play Hint <gen>
        • Game - Display to PlayerGroup_Humans the text String_HumanTips[TipCounter]
        • Game - Display to PlayerGroup_Vampires the text String_VampireTips[TipCounter
        • Countdown Timer - Start Timer_Tips as a repeating timer that will expire in Real_TipsFrequency seconds
      • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • Substring(Entered Chat String, 7, 9) equal to off
        • Boolean_TipsOn equal to true
      • Then - Actions
        • Sound - Play Hint <gen>
        • Game - Display to PlayerGroup_Humans the text String_HumanTipsOff
        • Game - Display to PlayerGroup_Vampires the text String_VampireTipsOff
        • Countdown Timer - Pause Timer_Tips
      • Else - Actions

  • Events
    • Player - Player 1 (Red) types a chat message containing -tips as a substring
    • ...
  • Conditions
  • Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • Boolean_TipsOn equal to false
      • Then - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • Substring(Entered Chat String, 7, 8) equal to on
          • Then - Actions
            • Sound - Play Hint <gen>
            • Game - Display to PlayerGroup_Humans the text String_HumanTips[TipCounter]
            • Game - Display to PlayerGroup_Vampires the text String_VampireTips[TipCounter
            • Countdown Timer - Start Timer_Tips as a repeating timer that will expire in Real_TipsFrequency seconds
          • Else - Actions
      • Else - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • Substring(Entered Chat String, 7, 9) equal to off
          • Then - Actions
            • Sound - Play Hint <gen>
            • Game - Display to PlayerGroup_Humans the text String_HumanTipsOff
            • Game - Display to PlayerGroup_Vampires the text String_VampireTipsOff
            • Countdown Timer - Pause Timer_Tips
          • Else - Actions
Pyrogasm: At moment your trigger affects all players, I'm not sure if that was intended or not. It was just an observation.
Realistically the tips should be shown on a per-player basis or even a per-team basis (right now anyone typing -tips on shows tips for all players on all teams) but I guess that's up to you. ... Use some variables to make the tips modular; if you do want to make them shown on a per-player or per-team basis this will make that much easier.


when I typing (tips off) nothing happens, and the tips are still repeating! and I changed the tips for per player to avoid trolling(not sure ;d)
You are erroneously using (Triggering Player) in triggers that do not have player events. They have timer events. Because TP doesn't exist the game returns Player(0) in JASS which is actually Player 1 in GUI; so the tips will appear to be working but really it's just showing things to Player 1 only. You are also not doing anything on a per-player basis right now. To do that you have two options:
  • Use a different timer and a different counter variable for each player. This is slightly more code but works exactly how you want it to.
  • Use 1 timer for all players but only show to specific players that have turned tips on when it expires. This has the downside of the tip not showing up instantly when you type -tips on, and since that timer runs ever 15 seconds it might be a while until you actually start seeing tips.
  • Use 1 timer for all players that times out every 1 second and shows for each player a tip when that player's timeout count goes up to 15. I think this is the best solution.
  • Tips
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Integer_TipsFrequency = 15 //this is now an integer
      • Set Integer_TipsTotal = 5
      • // Set Integer_TipsCounter = 1 //actually you don't need this any more and TipsCounter is now an array
      • Countdown Timer - Start Timer_Tips as a repeating timer that expires in 1.00 seconds
      • -------- Human Tips --------
      • Set String_TipsHumansOff = |cffffcc00Tip:|r |cff0080ffTips were turned off, Type -tips on to enable tips.|r
      • Set Strings_TipsHumans[1] = tips1.
      • Set Strings_TipsHumans[2] = tips2.
      • Set Strings_TipsHumans[3] = tips3.
      • Set Strings_TipsHumans[4] = tips4.
      • Set Strings_TipsHumans[5] = tips5.
      • -------- Vampire Tips --------
      • Set String_TipsVampiresOff = |cffffcc00Tip:|r |cffff0000Tips were turned off, Type -tips on to enable tips.|r
      • Set Strings_TipsVampires[1] = tips1.
      • Set Strings_TipsVampires[2] = tips2.
      • Set Strings_TipsVampires[3] = tips3.
      • Set Strings_TipsVampires[4] = tips4.
      • Set Strings_TipsVampires[5] = tips5.
  • Tips2
    • Events
      • Time - Timer_Tips expires
    • Conditions
    • Actions
      • Player Group - Remove all players from TempPlayerGroup[1] //this variable must have size >= 2 in the variable editor or just make multiple temp variables and don't worry about it, up to you
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • Boolean_TipsOn[(Player number of (Picked Player))] equal to true
            • Then - Actions
              • Player Group - Add (Picked Player) to TempPlayerGroup[1]
            • Else - Actions
      • Player Group - Pick every player in TempPlayerGroup[1] and do (Actions)
        • Loop - Actions
          • Set PNum = (Player number of (Picked Player))
          • Set Integer_TipsCounter[PNum] = (Integer_TipsCounter + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integer_TipsCounter[PNum] Greater than or equal to (>) Integer_TipsFrequency
            • Then - Actions
              • Set Integer_TipsCounter[PNum] = 0
              • Set Integer_TipsCurrent[PNum] = (Integer_TipsCurrent[PNum] + 1)
              • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
              • Sound - Play Hint <gen> //this line can be problematic because it will play the sound for all players, probably better to put in in a locals block like this
              • Custom script: endif
              • Player Group - Add Player(PNum) to TempPlayerGroup[2
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player(PNum) is in PlayerGroup_Humans) equal to true
                • Then - Actions
                  • Game - Display to TempPlayerGroup[2] the text: Strings_TipsHumans[Integer_TipsCurrent[PNum]]
                • Else - Actions
                  • Game - Display to TempPlayerGroup[2] the text: Strings_TipsVampries[Integer_TipsCurrent[PNum]]
              • Player Group - Remove all players from TempPlayerGroup[2]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TipsCurrent[PNum] greater than or equal to TipsTotal
                • Then - Actions
                  • Set TipsCurrent[PNum] = 0
                • Else - Actions
            • Else - Actions
  • Events
    • Player - Player 1 (Red) types a chat message containing -tips as a substring
    • Player - Player 2 (Blue) types a chat message containing -tips as a substring
    • Player - Player 3 (Teal) types a chat message containing -tips as a substring
    • ...
    • //note it's a substring event now and you don't need both tipson and tipsoff
  • Conditions
  • Actions
    • Set PNum = (Player number of (Triggering Player))
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • Substring(Entered Chat String, 7, 8) equal to on
        • Boolean_TipsOn[PNum] equal to false
      • Then - Actions
        • Set Boolean_TipsOn[PNum] = true
        • Set Integer_TipsCounter[PNum] = (Integer_TipsFrequency - 1) //so it shows the first tip in at most 1 second
      • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • Substring(Entered Chat String, 7, 9) equal to off
        • Boolean_TipsOn[PNum] equal to true
      • Then - Actions
        • Set Boolean_TipsOn[PNum] = false
        • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
        • Sound - Play Hint <gen>
        • Custom script: endif
        • Player Group - Add Player(PNum) to TempPlayerGroup[2]
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player(PNum) is in PlayerGroup_Humans) equal to true
          • Then - Actions
            • Game - Display to TempPlayerGroup[2] the text: Strings_TipsHumansOff
          • Else - Actions
            • Game - Display to TempPlayerGroup[2] the text: Strings_TipsVampriesOff
        • Player Group - Remove all players from TempPlayerGroup[2]
      • Else - Actions
 
Last edited:
Level 42
Joined
Feb 27, 2007
Messages
5,273
Because you didn't give TempPlayerGroup[] a size of 2+ like I said you needed to in my comment. Also if you ever call DestroyForce() on TempPlayerGroup[1 or 2] it will stop working because now there's no empty force (player group) in that force variable.
 
Level 11
Joined
Jun 20, 2017
Messages
380
Actually I did you can check, and as you said (this variable must have size >= 2 in the variable editor)
1.jpg

And I didn't clean the player group
 
Level 42
Joined
Feb 27, 2007
Messages
5,273
  • You are using (and showing the messages to) Player_Tips[Integer_Tips] but Player_Tips is never initialized. You would want to use Player(Integer_Tips), which shows up as 'convert player id to player' in GUI. The player array is unnecessary, that's the whole point of saving the player id into an integer variable; instead you can just have one variable which you assign as necessary: Player_Tips (which you already have in the map). I used this variable in both triggers.

  • You removed Player_Tips from PlayerGroups_Tips[1] when it should be removing ALL players from the group. I changed the on for _Tips[2] to use this method too instead of just removing the specific player.
Map is attached, working fine now.
 

Attachments

  • Human vs Vampire v1.b.w3x
    1.1 MB · Views: 23
Status
Not open for further replies.
Top