• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Chat System

Status
Not open for further replies.
Level 7
Joined
Jul 20, 2009
Messages
295
I have absolutely no idea why the following trigger does not work. =/
I need your help, please.

  • Chat System
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
      • Player - Player 2 (Blue) types a chat message containing <Empty String> as A substring
      • Player - Player 3 (Teal) types a chat message containing <Empty String> as A substring
      • Player - Player 4 (Purple) types a chat message containing <Empty String> as A substring
      • Player - Player 5 (Yellow) types a chat message containing <Empty String> as A substring
      • Player - Player 6 (Orange) types a chat message containing <Empty String> as A substring
      • Player - Player 7 (Green) types a chat message containing <Empty String> as A substring
      • Player - Player 8 (Pink) types a chat message containing <Empty String> as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-, 1, 1))
        • Then - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(<Empty String>, 1, 999))
        • Then - Actions
          • Unit Group - Pick every unit in (Units within 1000.00 of (Position of Hero[(Player number of (Triggering player))])) and do (Actions)
            • Loop - Actions
              • Game - Display to (Player group((Owner of (Picked unit)))) the text: ((Player_Colour[(Player number of (Triggering player))] + ((Name of (Triggering player)) + :|r )) + (Substring(<Empty String>, 1, 999)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-whisper , 1, 9))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (Substring(1 , 10, 11))
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) the text: ((|cffD843E9To|r + ((Player_Colour[1] + (Name of Player 1 (Red))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 12, 999)) + |r)))
              • Game - Display to (Player group(Player 1 (Red))) the text: ((|cffD843E9From|r + ((Player_Colour[(Player number of (Triggering player))] + (Name of (Triggering player))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 12, 999)) + |r)))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (Substring(2 , 10, 11))
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) the text: ((|cffD843E9To|r + ((Player_Colour[2] + (Name of Player 2 (Blue))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 12, 999)) + |r)))
              • Game - Display to (Player group(Player 2 (Blue))) the text: ((|cffD843E9From|r + ((Player_Colour[(Player number of (Triggering player))] + (Name of (Triggering player))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 12, 999)) + |r)))
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-w , 1, 3))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (Substring(1 , 4, 5))
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) the text: ((|cffD843E9To|r + ((Player_Colour[1] + (Name of Player 1 (Red))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 6, 999)) + |r)))
              • Game - Display to (Player group(Player 1 (Red))) the text: ((|cffD843E9From|r + ((Player_Colour[(Player number of (Triggering player))] + (Name of (Triggering player))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 6, 999)) + |r)))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (Substring(2 , 4, 5))
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) the text: ((|cffD843E9To|r + ((Player_Colour[2] + (Name of Player 2 (Blue))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 6, 999)) + |r)))
              • Game - Display to (Player group(Player 2 (Blue))) the text: ((|cffD843E9From|r + ((Player_Colour[(Player number of (Triggering player))] + (Name of (Triggering player))) + :|r|cffD843E9(Whisper)|r )) + (|cffD843E9 + ((Substring(<Empty String>, 6, 999)) + |r)))
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-party , 1, 6))
        • Then - Actions
          • Game - Display to Party[(Player number of (Triggering player))] the text: ((Player_Colour[(Player number of (Triggering player))] + ((Name of (Triggering player)) + :|r|cff00FFFF(Party)|r )) + (Substring(<Empty String>, 7, 999)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-p , 1, 3))
        • Then - Actions
          • Game - Display to Party[(Player number of (Triggering player))] the text: ((Player_Colour[(Player number of (Triggering player))] + ((Name of (Triggering player)) + :|r|cff00FFFF(Party)|r )) + (Substring(<Empty String>, 4, 999)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-shout , 1, 7))
        • Then - Actions
          • Game - Display to (All players) the text: ((Player_Colour[(Player number of (Triggering player))] + ((Name of (Triggering player)) + :|r|cffFF8000(Shout)|r )) + (Substring(<Empty String>, 8, 999)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(-s , 1, 3))
        • Then - Actions
          • Game - Display to (All players) the text: ((Player_Colour[(Player number of (Triggering player))] + ((Name of (Triggering player)) + :|r|cffFF8000(Shout)|r )) + (Substring(<Empty String>, 4, 999)))
        • Else - Actions
Hero = A unit owned by a player
PlayerColour = Just a string e.g. |cffff0000
Party = Player Group (Arrayed)
(I have set Players 1-3 to be in Party Numbers 1-3 each in order to check if it works if I join another player other than player 1)


Here is how I want it to be:
*If "-" is typed with something else, no Game Display shows. (e.g. "-roll")

*If anything is typed except "-" at start, all that is typed is showed to players that have their units near the Player's Hero that typed of distance 1000. (e.g. "Hello there")

*If "-party"/"-p" Only Shows the text after "-party"/"-p" to Player Group, Party. (e.g. "-party Come guys, follow me.")

*If "-shout"/"-s" Shows Game Display to everyone containing the text typed after "-shout"/"-s". (e.g. "-shout I will help you all in few seconds")

*If "-whisper (Player Number)"/"-w (Player Number)" shows the text typed after "-whisper (Player Number)"/"-w (Player Number)" as Game Display only to the player's number entered and shows to the typer also the message has received and what he/she typed. (e.g. "-w 3 come on teal.. hurry up before time is up")

The problem is:
*No Game Display shows for each type of Chat, e.g -whisper/-shout...

+2 Rep for the helper. If anything is not explained well, please ask. If Colour is annoying you, I'll change it. :D
 
All of the conditions are wrong. You are comparing (Entered chat string), which is something like "hello man" to a substring from something like "-", "-whisper", or "". Obviously, "hello man" will never be equal to "-" or "", so these conditions will always fail.
The correct way to do this would be:
  • Conditions
    • (Substring (Entered chat string), 1, 9 ) Equal to "-whisper"
instead of
  • Conditions
    • (Entered chat string) Equal to (Substring(-whisper , 1, 9))
Simillary for all other conditions.
 
btw your first if/than/else actions are not needed and your events should be

Player - Player X types a chat message containing "-" as A substring


and when you want to check something check from 2 to x
for example

  • Conditions
    • (Substring (Entered chat string), 2, 9 ) Equal to "-whisper"
[/trigger]

AND

if/than/else actions should be like this


IF
THAN
ELSE-> IF
______THAN
______ELSE-> IF
____________THAN
____________ELSE

and i suggest you learn how to use this

go to tutorial section
https://www.hiveworkshop.com/forums/tutorials/

you need to learn about:

Variables !
Array Variables !
Hash tables are also very good (they are 2d Arrays)
and so called Fake Multi-Array variables would be good too (1-12,13-24,25-36....)
to use from 1 to 12
1 x 12 - 11 <-----> 1 x 12
to use from 13 to 24
2 x 12 - 11 <-----> 2 x 12
to use from 25 to 36
3 x 12 - 11 <-----> 3 x 12
-for example if you need save that TriggeringPlayer likes SomePlayer xD
make Boolean Array Variable - Like[X]
set Like[((Number of Triggering Player x 12) - 11) + (Player Number of (SomePlayer))] = True


Use Pick Every Player/Unit/Item... and do actions
loop - do something about Picked Player/Unit/Item...


IF/THAN/ELSE actions are really needed
they are very good and with it you can make all triggers with same event in one trigger

For each integer A from X to X
loop - your actions


For each integer B from X to X
loop - your actions

(integer B actions are used if you need to put it in loop of integer A actions)

sub strings X,X are good for command triggers (and array-string variables are good for it too,if you want player color detect or something like that)
(you should also have all command triggers in one trigger,and only event player types "-" as a sub string
than you check what is the rest of it (for example)
sub string(entered cheat string) 2,6 Equal to "kick " (6 because of space)

Removing Memory Leaks (i think you don't really need to remove player group leaks,i never did and nothing happens,maybe after 1.000.000 times -.-)

it is good to know for Events - Unit issued targeting an object/point/no target

but to stop TriggeringUnit on that events you need to do this:
(i think it is best combination for it)

-turn off this trigger
-pause TriggeringUnit
-unpause TriggeringUnit
-order TriggeringUnit to stop
-turn on this trigger


and some more :D
 
^^ I already master the basics of triggering. It is just that this was my first time I use, "Substrings" I usally use things like, "Player - chat messages "-roll" as an exact match" etc...

Also for the, "Player - Player X types a chat message containing "-" as A substring", I also need a Normal Chat which is like this: "*If anything is typed except "-" at start, all that is typed is showed to players that have their units within 1000 distance of the Player's Hero that has typed. (e.g. "Hello there")"
 
^^ I already master the basics of triggering. It is just that this was my first time I use, "Substrings" I usally use things like, "Player - chat messages "-roll" as an exact match" etc...

Also for the, "Player - Player X types a chat message containing "-" as A substring", I also need a Normal Chat which is like this: "*If anything is typed except "-" at start, all that is typed is showed to players that have their units within 1000 distance of the Player's Hero that has typed. (e.g. "Hello there")"
you don't know all those i posted....

learn how to use "if/than/else" actions,you are doing it on wrong way
 
Status
Not open for further replies.
Back
Top