HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Splitting Chat Strings in GUI

01-26-2008, 03:39 PM#1
Centreri
How would you split a chat string in GUI? For example, a player says in chat '-zoom {insertrandomnumberhere}', and I find what the number is and set the camera distance to that. Thank you in advance.
01-26-2008, 03:55 PM#2
Tide-Arc Ephemera
Use substrings.

Code:
Here's how it's numbered
substring
|||||||||
123456789

It corresponds to the position of the number-letter (badly worded from me)

Substring 4 to 7 in my example would give you "stri"

GRUNT
|||||
12345

Substring 2 to 4 would be RUN
01-26-2008, 08:59 PM#3
Salbrismind
Just as he said, all you need to do is find the first number's substring value which should be 7:
Code:
-zoom 56
||||||||
12345678

Then just take the length of the chat string and use it as the upper bound:

Trigger:
Chat
Collapse Events
Player - Player 1 (Red) types a chat message containing -zoom as A substring
Conditions
Collapse Actions
Set string = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
Camera - Set Player 1 (Red)'s camera Distance to target to (Real(string)) over 0.00 seconds

Notice it said "as A substring" in the event. Also notice you need to convert the string value you get to a real number to put it in the action for the camera distance.