• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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