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

Text Commands

Status
Not open for further replies.
Level 4
Joined
Aug 14, 2007
Messages
66
Im trying to make a way for players to ally/unally/allow vision of eachother in game without making lots of triggers...:bored:

I've never really been sure exactly how to take apart what people typed and use it in a trigger.

Oh yeah and I mean for people to be able to vision eachother regardless of their current allied status.

Im using WEU (world editor unlimited)

When i tried this vision seemed fine but I dont have any way to know for sure if it worked but when I try to unally people the game has a critical error.

  • Vision
    • Events
      • Player - Player 1 (Red) types a chat message containing vision as A substring
      • Player - Player 2 (Blue) types a chat message containing vision as A substring
      • Player - Player 3 (Teal) types a chat message containing vision as A substring
      • Player - Player 4 (Purple) types a chat message containing vision as A substring
      • Player - Player 5 (Yellow) types a chat message containing vision as A substring
      • Player - Player 6 (Orange) types a chat message containing vision as A substring
      • Player - Player 7 (Green) types a chat message containing vision as A substring
      • Player - Player 8 (Pink) types a chat message containing vision as A substring
      • Player - Player 9 (Gray) types a chat message containing vision as A substring
      • Player - Player 10 (Light Blue) types a chat message containing vision as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is an ally of Player[(Integer((Substring((Entered chat string), 8, 9))))]) Equal to True
        • Then - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 8, 9))))] as an Ally with shared vision
        • Else - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 8, 9))))] as an Enemy with shared vision
  • Ally
    • Events
      • Player - Player 1 (Red) types a chat message containing ally as A substring
      • Player - Player 2 (Blue) types a chat message containing ally as A substring
      • Player - Player 3 (Teal) types a chat message containing ally as A substring
      • Player - Player 4 (Purple) types a chat message containing ally as A substring
      • Player - Player 5 (Yellow) types a chat message containing ally as A substring
      • Player - Player 6 (Orange) types a chat message containing ally as A substring
      • Player - Player 7 (Green) types a chat message containing ally as A substring
      • Player - Player 8 (Pink) types a chat message containing ally as A substring
      • Player - Player 9 (Gray) types a chat message containing ally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing ally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is giving Player[(Integer((Substring((Entered chat string), 6, 7))))] Shared vision) Equal to True
        • Then - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 6, 7))))] as an Ally with shared vision
        • Else - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 6, 7))))] as an Ally

  • Unally
    • Events
      • Player - Player 1 (Red) types a chat message containing unally as A substring
      • Player - Player 2 (Blue) types a chat message containing unally as A substring
      • Player - Player 3 (Teal) types a chat message containing unally as A substring
      • Player - Player 4 (Purple) types a chat message containing unally as A substring
      • Player - Player 5 (Yellow) types a chat message containing unally as A substring
      • Player - Player 6 (Orange) types a chat message containing unally as A substring
      • Player - Player 7 (Green) types a chat message containing unally as A substring
      • Player - Player 8 (Pink) types a chat message containing unally as A substring
      • Player - Player 9 (Gray) types a chat message containing unally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing unally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is giving Player[(Integer((Substring((Entered chat string), 8, 9))))] Shared vision) Equal to True
        • Then - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 8, 9))))] as an Enemy with shared vision
        • Else - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 8, 9))))] as an Enemy
 
Level 6
Joined
Feb 2, 2005
Messages
205
ye for sure it gice you an critical you fire the ally and the unally Trigger

Since it say contains substring "ally" and the other is "unally" just change the containing substring to "-ally" and "-unally" then those trigger will work fine
 
Level 4
Joined
Aug 14, 2007
Messages
66
That got it to work fine but ive discovered a potential problem. At first typing 1 symbol more then 2 symbols for instance -ally 002 would crash the game. So i changed the triggers a bit

  • Unally
    • Events
      • Player - Player 1 (Red) types a chat message containing -unally as A substring
      • Player - Player 2 (Blue) types a chat message containing -unally as A substring
      • Player - Player 3 (Teal) types a chat message containing -unally as A substring
      • Player - Player 4 (Purple) types a chat message containing -unally as A substring
      • Player - Player 5 (Yellow) types a chat message containing -unally as A substring
      • Player - Player 6 (Orange) types a chat message containing -unally as A substring
      • Player - Player 7 (Green) types a chat message containing -unally as A substring
      • Player - Player 8 (Pink) types a chat message containing -unally as A substring
      • Player - Player 9 (Gray) types a chat message containing -unally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -unally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is giving Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] Shared vision) Equal to True
        • Then - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] as an Enemy with shared vision
        • Else - Actions
          • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] as an Enemy
so that they all look like that..the numbers I mean. But now the problem is if they type something like -ally 222222222222222222222222222 that also crashes the game. Is there a way to reverse this?

By the way Player[] is an array player variable where Player[1] = Player 1 (red) and so on.
 
Level 6
Joined
Feb 2, 2005
Messages
205
ye sure you can, just do this
  • Actions
    • Set test = Integer(Integer((Substring((Entered chat string), 9, 1000000000))))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • test greater or equal 12
      • Then - Actions
        • do ally stuff
      • Else - Actions
        • Do Nothing
you can also give out an error messag instead of nothing, this is not perfect solution to make it fully MUI change the test Variable into an array so each player has its own.
 
Level 4
Joined
Aug 14, 2007
Messages
66
I tried that but still typing -unally 2222222222222222222222222222222222 crashed the game. I also tried it without the variable and it didnt work :sad:

  • Unally
    • Events
      • Player - Player 1 (Red) types a chat message containing -unally as A substring
      • Player - Player 2 (Blue) types a chat message containing -unally as A substring
      • Player - Player 3 (Teal) types a chat message containing -unally as A substring
      • Player - Player 4 (Purple) types a chat message containing -unally as A substring
      • Player - Player 5 (Yellow) types a chat message containing -unally as A substring
      • Player - Player 6 (Orange) types a chat message containing -unally as A substring
      • Player - Player 7 (Green) types a chat message containing -unally as A substring
      • Player - Player 8 (Pink) types a chat message containing -unally as A substring
      • Player - Player 9 (Gray) types a chat message containing -unally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -unally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Substring((Entered chat string), 9, 1000000000)))) Greater than 10
        • Then - Actions
          • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is giving Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] Shared vision) Equal to True
            • Then - Actions
              • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] as an Enemy with shared vision
            • Else - Actions
              • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 1000000000))))] as an Enemy
 
Level 9
Joined
Jun 26, 2007
Messages
659
well, if integer are store in 8 bytes like everywhere else, they can only store a value between
-9223372036854775808 and +9223372036854775807; so read the substring from 9 to 27 instead of 1000000000

PS: without the variable, that's stored in a temporary integer, so that the same problem
 
Last edited:
Level 4
Joined
Aug 14, 2007
Messages
66
I didnt completely understand what you meant about the variable..but i did try going to 27 instead of 100000000 and it seems to be working fine, but I stumbled across yet another problem :bored:

I accidentally didnt type anything but -unally and it caused another critical error. so i tried this (see trigger), but it still causes a critical error if I do -unally with a lot of spaces after it. :angry:

  • Unally
    • Events
      • Player - Player 1 (Red) types a chat message containing -unally as A substring
      • Player - Player 2 (Blue) types a chat message containing -unally as A substring
      • Player - Player 3 (Teal) types a chat message containing -unally as A substring
      • Player - Player 4 (Purple) types a chat message containing -unally as A substring
      • Player - Player 5 (Yellow) types a chat message containing -unally as A substring
      • Player - Player 6 (Orange) types a chat message containing -unally as A substring
      • Player - Player 7 (Green) types a chat message containing -unally as A substring
      • Player - Player 8 (Pink) types a chat message containing -unally as A substring
      • Player - Player 9 (Gray) types a chat message containing -unally as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -unally as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Integer((Substring((Entered chat string), 9, 27)))) Greater than 10
              • (Substring((Entered chat string), 9, 27)) Equal to Empty String
        • Then - Actions
          • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering player) is giving Player[(Integer((Substring((Entered chat string), 9, 27))))] Shared vision) Equal to True
            • Then - Actions
              • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 27))))] as an Enemy with shared vision
            • Else - Actions
              • Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 27))))] as an Enemy
 
Last edited:
Level 9
Joined
Jun 26, 2007
Messages
659
well, in fact, any time someone will make an uncorrect command, it will crash

to prevent this, you should verifie that the string is correct on each point:
if (lenght(entered chat string)>10) skip remaining actions
if (substring(entered chat string,1,8)!="-unally ") skip remaining actions
if (substring(entered chat string,9,9)!="0" and "1" and "2" ... and "9") skip remaining actions
if (substring(entered chat string,10,10)!="0".........
etc etc

and after all these test, you're sure that the command is correctly formated
so you can do your
Player - Make (Triggering player) treat Player[(Integer((Substring((Entered chat string), 9, 10))))] as ...

Nb: and for the integer tips, you were asking wc3 to store a hudge value in a small variable
try to write a whole book on an A4 sheet, you can't, that's the same
variable are limited, infinity doesn't exist in computers

EDIT: != means "not equal to"
 
Status
Not open for further replies.
Top