| 08-12-2006, 04:33 PM | #1 | |
MrApple's Guide to Chat Event Triggers Introduction This Tutorial is to teach peoples how to make things happen in game by typing a chat message. -----Part 1 – Basic Stuff----- Well first of all, you create a new trigger, and since there is no Generic Player Events, you must have an event for each player able to do this. Such as to give Access to All Players, and you have 12 players, it would look like this. Trigger: My First Chat Trigger
Now say if I wanted to make it so every time a player typed Blah Blah, they would get one gold, I would add on this action which is already in the above trigger. Player - Add 1 to (Triggering player) Current gold
(Triggering Player) is used to respond to this Event.-----Part 2 – Exact Match and Substrings----- Exact Match Exact Match means that it will only happen if the player types that message exactly. Add anything else and it will not work. Substrings Substrings are more fun, because if the player typed the text Anywhere in the chat message, it would happen! Say you don’t want anyone saying "ass" in your map, cause its usually used as a naughty word. You would put this event. Trigger: Ha, now you will catch those naughty people, but wait, this picks up ass anywhere in the message, so what if someone said a word that contained "ass"? Quote:
That would be bad wouldn't it? However, there is a solution! By adding spaces onto the ends of "ass" makes it "_ass_” and a separate word. But unfortunately, an anti-curse system can’t be perfect cause there will always be some way around it. -----Part 3 – Reacting Actions----- -Parts of Substring Comparison (Substring(Entered chat string), 7, (Length of (Entered chat string)) (Substring(The string in question), The first character # of the substring, (The last character number of the substring) Example- Message- I Eat Pie (Substring(Message), 7, (Length of (Message)) = Pie TIP: Length of Message is an integer that determines how many characters (spaces included) were in the message The P in Pie is the 7th Character in the Message, while the e in Pie is the 9th(Total Length of Message) -------------- Ok, say you wanted to make a trigger that would let people ally and unally through chat. You would think about it and probably come up with 12 triggers like this. Trigger: As you think to yourself, "Jeez, 12 triggers just to let people ally each-other through chat? There must be a better way!” Well there is, and there’s a few of them! Better Way #1 Trigger: Ally using Confusing Numbers
![]() 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
![]() Conditions
![]() ![]() (Substring((Entered chat string), 1, 5)) Equal to -ally
![]() ![]() (Integer((Substring((Entered chat string), 7, 8)))) Greater than or equal to 1
![]() ![]() (Integer((Substring((Entered chat string), 7, 8)))) Less than or equal to 12
![]() Actions
![]() ![]() -------- Get the above conditions by Integer Comparison, Convert String to Integer, Substring --------
![]() ![]() Player - Make (Triggering player) treat (Player((Integer((Substring((Entered chat string), 7, 8)))))) as an Ally with shared vision
![]() ![]() -------- Convert Player to Player Index for this action, and then the rest just like the conditions. --------[/center] What this does. -Checks if the chat message contained -ally in it. -Checks if the first 5 letters in the chat message = -ally -Checks if the 6 and 7th (Length of String is an integer in this case its 7) characters of the entered chat message are within 1 and 12(The Player Numbers of possible actual people players.) -Forces the Triggering Player to ally the Player matching the Player Number converted from the 6th and 7th characters.(1= Player 1, 2= Player 2...) Better Way #2 You can also do it by -ally PlayerNameHere Trigger: Ally using Player Names
![]() 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
![]() Actions
![]() ![]() Set StringVariable = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
![]() ![]() Set PlayerGroupVariable = (All players matching ((Name of (Matching player)) Equal to StringVariable))
![]() ![]() Player - Make (Triggering player) treat (Random player from PlayerGroupVariable) as an Ally with shared vision-Checks if the chat message contains -ally -Checks if the first 5 letters in the chat message = -ally -Creates a Player Group(Memory Leak, see a tutorial to fix this) where the only possible player in it would be the player whose name matches. -Forces the triggering player to ally a random player from that player group, and since there is only 1, it works the same as allying that player directly. Now you know how to do Chat Event Triggers, yay! -----Part 4 – Extra Stuff and Given Triggers----- I thought I would add in some cool things you can do with Chat Events! ---Boot Trigger---
Trigger: ---Continue your Education---
You can continue your education on Chat Event Triggers with my new tutorial on Playing with Player Names. Learn Renaming, fixing Capitalization in condtions, Coloring Names, and a whole bunch more!Please comment on how this tutorial can be improved, if you find anything that you find confusing, or may be confusing to others, please post it. I remind you that if you find a tutorial or post that is helpful to you to give the Author good rep. |
| 08-12-2006, 09:32 PM | #2 |
Again, Trigger Tags, not images. |
| 08-12-2006, 09:56 PM | #3 |
Using bold, italic or underlined text is a lot better than colored text - It fits better with the different themes. |
| 08-12-2006, 10:18 PM | #4 |
I don't even have the triggers on file for this one, delete it if you must. |
| 08-12-2006, 10:40 PM | #5 |
Can't you just re-create them? Shouldn't take extremly long time. |
| 08-15-2006, 08:47 AM | #6 |
Yes, these triggers shouldn't take too long to recreate and trigger tags are a requirement for it to be approved. EDIT: Your other tutorial has been approved btw. |
| 08-19-2006, 10:21 AM | #8 |
Thanks, TideHunter for the triggers. I've replaced the images, removed the color tags and approved the tutorial. |
