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

using the, Player types a chat message containing string, HELP!

Status
Not open for further replies.
Level 11
Joined
Nov 1, 2008
Messages
828
How do i record an integer from the message?
For example,


Event: Player says -mode 100

Where 100 is stored in to a variable and converted to integer for game purposes. All i have is Player says <Empty String> and it converts it to an integer. I don't know how to have what is said above. Thanks. +rep
 
Level 3
Joined
Sep 30, 2011
Messages
60
  • Events
    • Player - Player 1 (Red) types a chat message containing -mode 100 as An exact match
  • Conditions
  • Actions
    • Set i = (Integer((Substring(mode, 5, 8))))
like this? :D
 
should be like this
  • Events
    • Player - Player 1 (Red) types a chat message containing -mode as a substring
  • Conditions
    • Length of (entered chat string) greater than or equal to 6
    • subtring(entered chat string, 1, 5) is equal to -mode
  • Actions
    • Set i = (Integer((Substring(Entered Chat string, 7, Length of (entered chat string)))))
you use length of chat string as an upper bound so that it can take any possible length... :)

and we also check if it's greater than 6 so that we are sure that it has at least a single digit after the "-mode "
 
Level 11
Joined
Nov 1, 2008
Messages
828
should be like this
  • Events
    • Player - Player 1 (Red) types a chat message containing -mode as a substring
  • Conditions
    • Length of (entered chat string) greater than or equal to 6
    • subtring(entered chat string, 1, 5) is equal to -mode
  • Actions
    • Set i = (Integer((Substring(Entered Chat string, 7, Length of (entered chat string)))))
you use length of chat string as an upper bound so that it can take any possible length... :)

and we also check if it's greater than 6 so that we are sure that it has at least a single digit after the "-mode "

Wow thanks, Works perfect! :ogre_haosis:
 
Status
Not open for further replies.
Top