• 🏆 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] Chat Event / Substring

Status
Not open for further replies.
Level 5
Joined
Sep 10, 2006
Messages
185
I'm trying to figure out the whole substring thing for my map. I'm trying to make a command that when typed, will give the amount of gold to the player, providing the typer has the amount of gold. First, I'm trying to figure out how to use the substring stuff. This is what I tried.

(If you're wondering, for right now I made it give gold to myself so that I could test it myself)
  • Gold
    • Events
      • Player - Player 1 (Red) types a chat message containing -gold 02 as An exact match
    • Conditions
    • Actions
      • Set GOLDINT = (Substring((Entered chat string), 8, 9))
      • Player - Add (Integer(GOLDINT)) to Player 1 (Red) Current gold
I want it so that -gold 02 05 for example would give player 2, 5 gold.
Also, I'm not sure how to check if player 1 has enough gold to give to blue.

ty for any help :)
 
Level 17
Joined
Apr 13, 2008
Messages
1,597
If you are not sure how SubString works then make a sandbox map:
Show the string Substring(("123456789"), 8, 9) on the screen ;)

If you want to specify the amount of gold and the player too you'll need to use a chat command like this:
-gold p01 550 (gives 550 gold to red)
OR
-gold red 550 (does the same)
or something like that.

To check if player blue has enough gold or not:
Gold amount is an integer hard coded variable. You can find it under Integer Comparision / Player Property.
 
Level 5
Joined
Sep 10, 2006
Messages
185
TY, got the chat part of it working.

:)

Edit: ok here's what I got. It works for Red every time I use it so far, but does anyone see any problems that could occur with it?
  • Red Give Gold
    • Events
      • Player - Player 1 (Red) types a chat message containing -give 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 02
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Set GOLDINT = (Substring((Entered chat string), 10, 12))
          • Set GoldAmount[1] = (Player 1 (Red) Current gold)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldAmount[1] Greater than or equal to (Integer(GOLDINT))
            • Then - Actions
              • Player - Add ((Integer(GOLDINT)) x -1) to Player 1 (Red) Current gold
              • Player - Add (Integer(GOLDINT)) to Player 2 (Blue) Current gold
              • Game - Display to Player Group - Player 1 (Red) the text: (You gave + ((Name of Player 2 (Blue)) + ( + (GOLDINT + gold!))))
              • Game - Display to Player Group - Player 2 (Blue) the text: ((Name of Player 1 (Red)) + ( has given you + (GOLDINT + gold!)))
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: You don't have enou...
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 7, 8)) Equal to 03
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Set GOLDINT = (Substring((Entered chat string), 10, 12))
          • Set GoldAmount[1] = (Player 1 (Red) Current gold)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldAmount[1] Greater than or equal to (Integer(GOLDINT))
            • Then - Actions
              • Player - Add ((Integer(GOLDINT)) x -1) to Player 1 (Red) Current gold
              • Player - Add (Integer(GOLDINT)) to Player 3 (Teal) Current gold
              • Game - Display to Player Group - Player 1 (Red) the text: (You gave + ((Name of Player 3 (Teal)) + ( + (GOLDINT + gold!))))
              • Game - Display to Player Group - Player 3 (Teal) the text: ((Name of Player 1 (Red)) + ( has given you + (GOLDINT + gold!)))
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: You don't have enou...
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 7, 8)) Equal to 04
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Set GOLDINT = (Substring((Entered chat string), 10, 12))
          • Set GoldAmount[1] = (Player 1 (Red) Current gold)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GoldAmount[1] Greater than or equal to (Integer(GOLDINT))
            • Then - Actions
              • Player - Add ((Integer(GOLDINT)) x -1) to Player 1 (Red) Current gold
              • Player - Add (Integer(GOLDINT)) to Player 4 (Purple) Current gold
              • Game - Display to Player Group - Player 1 (Red) the text: (You gave + ((Name of Player 4 (Purple)) + ( + (GOLDINT + gold!))))
              • Game - Display to Player Group - Player 4 (Purple) the text: ((Name of Player 1 (Red)) + ( has given you + (GOLDINT + gold!)))
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: You don't have enou...
        • Else - Actions
          • Do nothing
 
Last edited:
Level 5
Joined
Sep 10, 2006
Messages
185
Remove the Do Nothing's.
Change 0X (player number) to X and then put it all into a loop, no need to create a new copy for each player.
Change the money checker (10-12) to 10 - Length of the string.

What's bad about do nothings? JW.

waste of space / not needed?
 
Status
Not open for further replies.
Top