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

Chat trriggers help

Status
Not open for further replies.
Level 4
Joined
Nov 22, 2004
Messages
62
ive been having headaches to discover how do you do this thing:

like a triger that (example) when i write -gold X ill get X ammounnt of gold. how do i do that?
 
Level 3
Joined
Dec 4, 2004
Messages
46
I can help, but I don't rember off the top of my head. LEt me load up my map.
Bloody hell, WE isn't working...
I think it is something like "Event: player types a chat message -gold 100 as an exact match." Action: "Give triggering player 100 gold."
Please correct me if I am wrong.
 
Level 9
Joined
Sep 8, 2004
Messages
633
LoneSlayer said:
I can help, but I don't rember off the top of my head. LEt me load up my map.
Bloody hell, WE isn't working...
I think it is something like "Event: player types a chat message -gold 100 as an exact match." Action: "Give triggering player 100 gold."
Please correct me if I am wrong.

That is correct, although this way, you can only give yourself 100 gold. I believe this sir needs to define X, whereas when you do give X gold, it takes X and gives that much gold.

Since i'm going to implement a similar feature in my map (gold transfers between allies) i'll get back on this later, i don't know how to do this yet, but i will soon. :)
 
Level 2
Joined
Nov 11, 2005
Messages
7
Code:
Gold
    Events
        Player - Player 1 (Red) types a chat message containing -gold as A substring
    Conditions
    Actions
        Player - Set [(Player number of (Triggering player))] gold to (Integer((Substring((Entered chat string), 7,12))))



That alows for up to 5 didgit amounts of gold.. just change the 12 to how ever much you think it needs to be for your needs...


Now if you wanted it for resource trading.. it would be a little more complex.

Code:
give1
    Events
        Player - Player 1 (Red) types a chat message containing -give1 as A substring
    Conditions
        ((Player((Player number of (Triggering player)))) Current gold) Greater than or equal to (Integer((Substring((Entered chat string), 8, 12))))
    Actions
        Player - Add (Integer((Substring((Entered chat string), 8, 12)))) to Player 1 (Red) Current gold
        Player - Add (Integer((- + (Substring((Entered chat string), 8, 12))))) to Player 1 (Red) Current gold
        Game - Display to (Player group((Player((Player number of (Triggering player)))))) the text: (you gave  + ((Name of Player 1 (Red)) + (  + ((Substring((Entered chat string), 8, 12)) +  Gold.))))

creating one of these for each avaliable player slot.. i havent tested this but it should work.
 
Level 9
Joined
Sep 8, 2004
Messages
633
i was nearly at what you explained, but i couldn't figure out the use of the substring format:
(string, 1, 5)

Can you explain that to me? thanks in advance.

Edit: And as i posted this it suddenly occured to me, its the position of the entered substring.
I'm gonna fix my code now, thanks mate, you're great
 
Level 9
Joined
Sep 8, 2004
Messages
633
I'm afraid i ran into a problem anyway.
Although i'm not sure about wheter or not it transfers the resources, i know for a fact that the text doesn't display correctly. It will only display if i enter "-give ally " (note, there's a space behind ally) it then states "0" as the value. For each other entry, it won't display anything at all, not numbers, nothing.
Here's the code:
Code:
Resource giving system
    Events
        Player - Player 1 (Red) types a chat message containing -give ally  as An exact match
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 2 (Blue) slot status) Equal to Is playing
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Triggering player) Current gold) Greater than or equal to (Integer((Substring((Entered chat string), 12, 17))))
                    Then - Actions
                        Player - Add (Integer((Substring((Entered chat string), 12, 17)))) to Player 2 (Blue) Current gold
                        Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - (Integer((Substring((Entered chat string), 12, 17)))))
                        Game - Display to Player 2 (Blue), at offset (0.00, 0.00) for 8.00 seconds the text: (|cffc5dbffYou recieved |cffffcc00 + ((String((Integer((Substring((Entered chat string), 12, 17)))))) + ( |cffc5dbffresources from  + (PlayerColors[1] + (Name of Player 1 (Red))))))
                        Game - Display to Player 1 (Red), at offset (0.00, 0.00) for 8.00 seconds the text: (|cffc5dbffYou transferred |cffffcc00 + ((String((Integer((Substring((Entered chat string), 12, 17)))))) + ( |cffc5dbffresources to  + (PlayerColors[2] + (Name of Player 2 (Blue))))))
                    Else - Actions
            Else - Actions

Please take a look at it for me.
 
Level 2
Joined
Nov 11, 2005
Messages
7
You basically nailed it.. but for your player event you want it to be a substing not an exact match.

Code:
Player - Player 1 (Red) types a chat message containing -give ally  as A substring

also.. as for the message display. i'd try something like this

Code:
Game - Display to Player Group - Player 1 (Red) the text: ((|cffc5dbffYou received |cffffcc00 + ((Substring((Entered chat string), 12, 17)) + |cffc5dbff resources from )) + (PlayerColors[1] + (Name of Player 1 (Red)))
 
Level 9
Joined
Sep 8, 2004
Messages
633
Maldarian said:
You basically nailed it.. but for your player event you want it to be a substing not an exact match.

Code:
Player - Player 1 (Red) types a chat message containing -give ally  as A substring

also.. as for the message display. i'd try something like this

Code:
Game - Display to Player Group - Player 1 (Red) the text: ((|cffc5dbffYou received |cffffcc00 + ((Substring((Entered chat string), 12, 17)) + |cffc5dbff resources from )) + (PlayerColors[1] + (Name of Player 1 (Red)))

How stupid of me to look over that... I did try the second code you posted, but i had the wrong event there, so i'll retry.
I knew about the substring event, just looked over it entirely, thanks for pointing it out.

Edit:

I've got it fixed now, works entirely.
Thanks for the help. All i have to do now is cnp and fix it for the other players. Here's the code, for any interested people:

Code:
Resource giving system
    Events
        Player - Player 1 (Red) types a chat message containing -give ally  as A substring
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Player 2 (Blue) slot status) Equal to Is playing
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Integer((Substring((Entered chat string), 12, 17)))) Greater than 0
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Triggering player) Current gold) Greater than or equal to (Integer((Substring((Entered chat string), 12, 17))))
                            Then - Actions
                                Player - Add (Integer((Substring((Entered chat string), 12, 17)))) to Player 2 (Blue) Current gold
                                Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - (Integer((Substring((Entered chat string), 12, 17)))))
                                Game - Display to Player 2 (Blue), at offset (0.00, 0.00) for 8.00 seconds the text: (|cffc5dbffYou recieved |cffffcc00 + ((String((Integer((Substring((Entered chat string), 12, 17)))))) + ( |cffc5dbffresources from  + (PlayerColors[1] + (Name of Player 1 (Red))))))
                                Game - Display to Player 1 (Red), at offset (0.00, 0.00) for 8.00 seconds the text: (|cffc5dbffYou transferred |cffffcc00 + ((String((Integer((Substring((Entered chat string), 12, 17)))))) + ( |cffc5dbffresources to  + (PlayerColors[2] + (Name of Player 2 (Blue))))))
                            Else - Actions
                                Advanced - For (Triggering player) display (Error: You do not have  + ((String((Integer((Substring((Entered chat string), 12, 17)))))) +  resources.)) as error message
                    Else - Actions
                        Advanced - For (Triggering player) display Error: Invalid value. as error message
            Else - Actions
                Advanced - For (Triggering player) display Error: Ally not ingame. as error message
 
Status
Not open for further replies.
Top