Trigger Request: Gold/Lumber Giving System

Status
Not open for further replies.
Level 2
Joined
Mar 20, 2015
Messages
14
Hello guys!!! I know you is a pro Maker!!!So, can you help me? I have some request :) Hey, I am gonna to make a map and i want add a command: -gg/-gl @ -givegold/-givelumber. I want make it ( -gg <Amount> ) and then it will create a dialog which show all ally of player, when click a player name , that <Amount> of gold will give to the Selected Player( Button ) But, i don't know how to make it, can anyone help with me? I will credit The Helper very much:vw_wtf:
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Create a trigger that will be used for every single "console" command
  • Console Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
      • Player - Player 2 (Blue) types a chat message containing - as A substring
      • Player - Player 3 (Teal) types a chat message containing - as A substring
      • Player - Player 4 (Purple) types a chat message containing - as A substring
    • Conditions
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempString = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(TempString, 1, 1)) Not equal to -
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
(Add the events for all players.)

Now you want to create a case system where you have one case that is for "Give Gold" and one case that is for "Give Lumber"
(Cases are simply a list of If/Then/Else functions with code inside it and a "Skip Remaining Actions" at the end to improve performance.)

But to the triggering.
You want a case where a player typed -gg or -give gold
So you create an If/Then/Else function with an Or condition and add both in it.
(I use substring to make the difference between "-gg" and "-fqofwoinfq -gg".)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Substring(TempString, 1, 3)) Equal to -gg
          • (Substring(TempString, 1, 10)) Equal to -give gold
    • Then - Actions
      • -------- Do actions here --------
      • Skip remaining actions
    • Else - Actions
Now to the point where you have to give the gold.
The concept that BloodDrunk said is indeed a bit better at the point where you are thinking about user friendly stuff... and easier triggering.

Now you want to have a second string... TempString2 that will be the remainder of the entered string.
Because you have 2 commands, you have to check which command was given.
Lucky for you we have only 2 because then you can simply use the Then and Else as the two different ones. Otherwise you have to create a new Case inside your caught case.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Substring(TempString, 1, 3)) Equal to -gg
    • Then - Actions
      • Set TempString2 = (Substring(TempString, 4, (Length of TempString)))
    • Else - Actions
      • Set TempString2 = (Substring(TempString, 11, (Length of TempString)))
Now that we have the remainder of the string which is "<space><number1><space><number2>"
number1 is a 1 or 2 digit number and number2 is a 1+ digit number.

Now you check for the string from spot 2 until spot 3.
first digit of number1 and second digit of number1 OR
first digit of number1 and the space.
Now you save that amount in an integer.
  • Set TempInteger = (Integer((Substring(TempString2, 2, 3))))
Now you check for the remainder of the string.
You set that amount in a new integer.
  • Set TempInteger2 = (Integer((Substring(TempString2, 4, (Length of TempString2)))))
Now you add TempInteger2 as gold for Player with id "TempInteger".
  • Player - Add TempInteger2 to (Player(TempInteger)) Current gold
Now your trigger is like this:
  • Console Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
    • Conditions
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempString = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(TempString, 1, 1)) Not equal to -
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Substring(TempString, 1, 3)) Equal to -gg
              • (Substring(TempString, 1, 10)) Equal to -give gold
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(TempString, 1, 3)) Equal to -gg
            • Then - Actions
              • Set TempString2 = (Substring(TempString, 4, (Length of TempString)))
            • Else - Actions
              • Set TempString2 = (Substring(TempString, 11, (Length of TempString)))
          • Set TempInteger = (Integer((Substring(TempString2, 2, 3))))
          • Set TempInteger2 = (Integer((Substring(TempString2, 4, (Length of TempString2)))))
          • Player - Add TempInteger2 to (Player(TempInteger)) Current gold
          • Skip remaining actions
        • Else - Actions
Now to make the Lumber part, you copy and paste the If/Then/Else function of Gold and you paste it right under it.
Now you change the Add Gold to Add Lumber and "-gg" and "-give gold" to "-gl" and "-give lumber"
Be aware that you now have a longer string check and have to change the substring bounds as well from 10 to 12 and the remainder first character from 11 to 13.

There is one problem.
If you enter a wrong number... for example a character. The game will crash because it will add gold or lumber to "f" or "a" or "[" or whatever.
So you check if the number is not equal to 0 to make sure that it is a valid number.

Here is the complete trigger:
  • Console Commands
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
    • Conditions
    • Actions
      • Set TempPlayer = (Triggering player)
      • Set TempString = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(TempString, 1, 1)) Not equal to -
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Substring(TempString, 1, 3)) Equal to -gg
              • (Substring(TempString, 1, 10)) Equal to -give gold
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(TempString, 1, 3)) Equal to -gg
            • Then - Actions
              • Set TempString2 = (Substring(TempString, 4, (Length of TempString)))
            • Else - Actions
              • Set TempString2 = (Substring(TempString, 11, (Length of TempString)))
          • Set TempInteger = (Integer((Substring(TempString2, 2, 3))))
          • Set TempInteger2 = (Integer((Substring(TempString2, 4, (Length of TempString2)))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempInteger Not equal to 0
              • TempInteger2 Not equal to 0
            • Then - Actions
              • Player - Add TempInteger2 to (Player(TempInteger)) Current gold
            • Else - Actions
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Substring(TempString, 1, 3)) Equal to -gl
              • (Substring(TempString, 1, 12)) Equal to -give lumber
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(TempString, 1, 3)) Equal to -gl
            • Then - Actions
              • Set TempString2 = (Substring(TempString, 4, (Length of TempString)))
            • Else - Actions
              • Set TempString2 = (Substring(TempString, 13, (Length of TempString)))
          • Set TempInteger = (Integer((Substring(TempString2, 2, 3))))
          • Set TempInteger2 = (Integer((Substring(TempString2, 4, (Length of TempString2)))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempInteger Not equal to 0
              • TempInteger2 Not equal to 0
            • Then - Actions
              • Player - Add TempInteger2 to (Player(TempInteger)) Current lumber
            • Else - Actions
          • Skip remaining actions
        • Else - Actions
I have also been so kind to upload the map with that trigger.
(Don't simply copy and paste but try to understand what happens and you might be able to make these things yourself without problems.)

(Btw... "Post Quick Reply" 0.o a bit too over the top?)

EDIT:
Sorry.
I am also checking for "-" every time. That one should actually be removed because I check it at the top. My mistake.
 

Attachments

  • Console Commands.w3x
    16.9 KB · Views: 63
Level 2
Joined
Mar 20, 2015
Messages
14
(Don't simply copy and paste but try to understand what happens and you might be able to make these things yourself without problems.)
Oh yea, I will not simple Copy and Paste Only, Very Thanks you then. ^^
 
Status
Not open for further replies.
Top