• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Resource send via command non-numerical issue

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2020
Messages
86
I have created a system to send gold/lumb to players via commands: "-gg <gold amount> <player color>" but if they type it with a non-numerical value ie, "-gg -10000 red" it will cause the system to ignore its conditions.

What condition would solve this?

  • sendgold
    • Events
      • Player - Player 1 (Red) types a chat message containing -gg as A substring
      • Player - Player 2 (Blue) types a chat message containing -gg as A substring
      • Player - Player 3 (Teal) types a chat message containing -gg as A substring
      • Player - Player 4 (Purple) types a chat message containing -gg as A substring
      • Player - Player 5 (Yellow) types a chat message containing -gg as A substring
      • Player - Player 6 (Orange) types a chat message containing -gg as A substring
      • Player - Player 7 (Green) types a chat message containing -gg as A substring
      • Player - Player 8 (Pink) types a chat message containing -gg as A substring
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • For each (Integer A) from 5 to (Length of (Entered chat string)), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Entered chat string), (Integer A), (Integer A))) Equal to
            • Then - Actions
              • Set VariableSet playerGold = (Integer((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string))))))
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to red) then do (Set VariableSet playerGold = 1) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to blue) then do (Set VariableSet playerGold = 2) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to teal) then do (Set VariableSet playerGold = 3) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to purple) then do (Set VariableSet playerGold = 4) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to yellow) then do (Set VariableSet playerGold = 5) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to orange) then do (Set VariableSet playerGold = 6) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to green) then do (Set VariableSet playerGold = 7) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to pink) then do (Set VariableSet playerGold = 8) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to gray) then do (Set VariableSet playerGold = 9) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to light blue) then do (Set VariableSet playerGold = 10) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to dark green) then do (Set VariableSet playerGold = 11) else do (Do nothing)
              • If ((Substring((Entered chat string), ((Integer A) + 1), (Length of (Entered chat string)))) Equal to brown) then do (Set VariableSet playerGold = 12) else do (Do nothing)
              • Set VariableSet amountGold = (Integer((Substring((Entered chat string), 5, (Integer A)))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering player) Current gold) Greater than or equal to amountGold
                  • ((Triggering player) is an ally of (Player(playerGold)).) Equal to True
                  • ((Player(playerGold)) slot status) Equal to Is playing
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • GoldLimit[PN] Less than or equal to 25000
                    • Then - Actions
                      • Game - Display to (Player group((Triggering player))) the text: (You gave + ((String(amountGold)) + ( |cffffff00gold|r to player + (Name of (Player(playerGold))))))
                      • Player - Add amountGold to (Player(playerGold)).Current gold
                      • Player - Add (amountGold x -1) to (Triggering player).Current gold
                      • Set VariableSet GoldLimit[PN] = (GoldLimit[PN] + amountGold)
                      • Game - Display to (Player group((Triggering player))) the text: (Gold send limit + ((String(GoldLimit[PN])) + /25000))
                      • Game - Display to (Player group((Player(playerGold)))) the text: (<Empty String> + ((Name of (Triggering player)) + ( sent you |cffffff00 + ((String(amountGold)) + gold|r))))
                    • Else - Actions
                      • Game - Display to (Player group((Triggering player))) the text: Gold send limit rea...
                • Else - Actions
                  • Game - Display to (Player group((Triggering player))) the text: You havent got that...
              • Skip remaining actions
            • Else - Actions
 
Level 23
Joined
Apr 3, 2018
Messages
460
As I understand you want to convert substring from the entered message to playercolor comparison.

On initialization, make two arrays as database for player colors and their strings, then when command is entered compare your substring to the arrays.
String Array1 "red" "blue"...
Playercolor Array2 corresponding to the above strings from array1

On message:
For A...If substring == stringarray1[A] then
For B...If player(B) color=colorarray2[A] then send resources.
 
Level 5
Joined
Jan 23, 2020
Messages
86
@biridius

Thanks, but the system works, that's not the issue.. what the issue is, is if I use the symbol "-" in the value, it ignores the conditions. So I can send players 1,000,000 gold just typing "-gg -100000 <playercolor>" even if I don't have the gold, to begin with.

So I need a condition that checks if there is a non-numerical value in the gold amount and stop the rest of the trigger process.

Hope that makes more sense.
 
Status
Not open for further replies.
Top