• 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.

How to gain X gold with chat trigger?

Status
Not open for further replies.
Level 1
Joined
Aug 3, 2010
Messages
5
Hi everyone! I am making my map and i don`t know how to make the trigger, where anyone could type in chat for example 2000 and 2000 would become value of some variable?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here's waht DSG said in a trigger:

  • Untitled Trigger 038
    • Events
      • Player - Player 1 (Red) types a chat message containing -gold as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 5)) Equal to -gold
    • Actions
      • Set i1 = (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
Typing -gold 1000 would set the value of i1 to 1000.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I think we should avoid using "Variable" in this case, don't you think so, Maker ?

This trigger will let it work for all players in the map
  • Setup For MPI
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to Types <gen> the event (Player - (Player((Integer A))) types a chat message containing -gold as A substring)
This is the main trigger for the "-gold XXX" to work
  • Types
    • Events
    • Conditions
    • Actions
      • Player - Add (Integer((Substring((Entered chat string), 7, 999)))) to (Triggering player) Current gold
 
why use an init trigger when you could add them at the trigger itself?

defskull said:
I think we should avoid using "Variable" in this case, don't you think so, Maker ?

this:
BenQuick said:
Hi everyone! I am making my map and i don`t know how to make the trigger, where anyone could type in chat for example 2000 and 2000 would become value of some variable?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
You should rather use a force enum of all human players who are playing than all 12 player slots. This would avoid redundant event generation and save on some code execution.

Only humans can type game messages. Even if AI could be brought to do this via triggers, it would be far better to execute the command actions directly.
Only humans that are playing can send chat messages. Not all 12 slots may contain humans and out of those not all of them may be playing (started without a full house or droppers).

Only in this case would a chat event binding system be useful to save game resources. Such a system should prety much be 1 function call though with the same parameters as the chat event but without a specified player slot.
 
You should rather use a force enum of all human players who are playing than all 12 player slots. This would avoid redundant event generation and save on some code execution.

Only humans can type game messages. Even if AI could be brought to do this via triggers, it would be far better to execute the command actions directly.
Only humans that are playing can send chat messages. Not all 12 slots may contain humans and out of those not all of them may be playing (started without a full house or droppers).

Only in this case would a chat event binding system be useful to save game resources. Such a system should prety much be 1 function call though with the same parameters as the chat event but without a specified player slot.
Well I used all 12 to show him example, same can work with force and so on!

When I think about it you can check if player play before throwing him into trigger event with simple if the else function :)
This way you will generate events only for playing players :)

So yes, using 1 additional trigger should become your addiction/habit :)
 
Status
Not open for further replies.
Top