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

[Trigger] Restrict the trade of resources

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
335
Can anyone help to limiting resources on these trigger? (All I want is send only 2 gold/2k lumber per minute with cmd, you cannot send more than that)
  • Trade
    • Events
      • Player - Player 1 (Red) types a chat message containing -g as A substring
      • Player - Player 2 (Blue) types a chat message containing -g as A substring
      • Player - Player 3 (Teal) types a chat message containing -g as A substring
      • Player - Player 4 (Purple) types a chat message containing -g as A substring
      • Player - Player 5 (Yellow) types a chat message containing -g as A substring
      • Player - Player 6 (Orange) types a chat message containing -g as A substring
      • Player - Player 7 (Green) types a chat message containing -g as A substring
      • Player - Player 8 (Pink) types a chat message containing -g as A substring
      • Player - Player 9 (Gray) types a chat message containing -g as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -g as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -g as A substring
      • Player - Player 12 (Brown) types a chat message containing -g as A substring
      • Player - Player 1 (Red) types a chat message containing -w as A substring
      • Player - Player 2 (Blue) types a chat message containing -w as A substring
      • Player - Player 3 (Teal) types a chat message containing -w as A substring
      • Player - Player 4 (Purple) types a chat message containing -w as A substring
      • Player - Player 5 (Yellow) types a chat message containing -w as A substring
      • Player - Player 6 (Orange) types a chat message containing -w as A substring
      • Player - Player 7 (Green) types a chat message containing -w as A substring
      • Player - Player 8 (Pink) types a chat message containing -w as A substring
      • Player - Player 9 (Gray) types a chat message containing -w as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -w as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -w as A substring
      • Player - Player 12 (Brown) types a chat message containing -w as A substring
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 1, 2)) Equal to (==) -g
        • Then - Actions
          • Set Integer_TradePlayer = (Integer((Substring((Entered chat string), 4, 5))))
          • Set Integer_TradeAmount = (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Player(Integer_TradePlayer)) slot status) Equal to (==) Is playing
                • ((Triggering player) is an ally of (Player(Integer_TradePlayer))) Equal to (==) True
                • ((Triggering player) Current gold) Greater than or equal to (>=) Integer_TradeAmount
                • Integer_TradeAmount Greater than (>) 0
              • Then - Actions
                • Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - Integer_TradeAmount)
                • Player - Add Integer_TradeAmount to (Player(Integer_TradePlayer)) Current gold
                • Set PlayerGroup = (Player group((Triggering player)))
                • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + ( has given + (Strings_PlayerColors[Integer_TradePlayer] + ((Name of (Player(Integer_TradePlayer))) + (|r + ( |cffffff00 + ((String(Integer_TradeAmount)) +
                • Custom script: call DestroyForce(udg_PlayerGroup)
              • Else - Actions
                • Set PlayerGroup = (Player group((Triggering player)))
                • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + not enough resources. |cffff0000Cannot trade with the enemy.|r)))
                • Custom script: call DestroyForce(udg_PlayerGroup)
        • Else - Actions
      • -------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Substring((Entered chat string), 1, 2)) Equal to (==) -w
          • Then - Actions
            • Set Integer_TradePlayer = (Integer((Substring((Entered chat string), 4, 5))))
            • Set Integer_TradeAmount = (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player(Integer_TradePlayer)) slot status) Equal to (==) Is playing
                  • ((Triggering player) is an ally of (Player(Integer_TradePlayer))) Equal to (==) True
                  • ((Triggering player) Current lumber) Greater than or equal to (>=) Integer_TradeAmount
                  • Integer_TradeAmount Greater than (>) 0
                • Then - Actions
                  • Player - Set (Triggering player) Current lumber to (((Triggering player) Current lumber) - Integer_TradeAmount)
                  • Player - Add Integer_TradeAmount to (Player(Integer_TradePlayer)) Current lumber
                  • Set PlayerGroup = (Player group((Triggering player)))
                  • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + ( has given + (Strings_PlayerColors[Integer_TradePlayer] + ((Name of (Player(Integer_TradePlayer))) + (|r + ( |cff008000 + ((String(Integer_TradeAmount)) +
                  • Custom script: call DestroyForce(udg_PlayerGroup)
                • Else - Actions
                  • Set PlayerGroup = (Player group((Triggering player)))
                  • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + not enough resources. |cffff0000Cannot trade with the enemy.|r)))
                  • Custom script: call DestroyForce(udg_PlayerGroup)
          • Else - Actions
  • Trade Limit
    • Events
      • Time - Timer_TradeRestart expires
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_TradeAmount Less than or equal to (<=) 2
        • Then - Actions
          • Set PlayerGroup = (Player group((Triggering player)))
          • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + you can only send a maximum of 2 Gold per minute.)))
          • Custom script: call DestroyForce(udg_PlayerGroup)
        • Else - Actions
      • -------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Integers_TradedMaxLumber[Integer_TradeAmount] Less than or equal to (<=) 2000
          • Then - Actions
            • Set PlayerGroup = (Player group((Triggering player)))
            • Game - Display to PlayerGroup the text: (Strings_PlayerColors[(Player number of (Triggering player))] + ((Name of (Triggering player)) + (|r + you can only send a maximum of 2000 Lumber per minute.)))
            • Custom script: call DestroyForce(udg_PlayerGroup)
          • Else - Actions
 
I would suggest to reduce the parsed amout from a player specific remaining allowed traded amount and reduce the remaining allowed amount by the now send amount. Ever 60 seconds reset the allowed traded amount back to the max allowed.

One could also sum up send amount and dump down sends when the new sum would be to big.
 
Level 10
Joined
Jun 20, 2017
Messages
335
Something like this?!
  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Integers_TradeAmountMax[(Integer_TradePlayer + Integer_TradeAmount)] Less than or equal to (<=) 2) and (((Triggering player) Current gold) Greater than (>) 0)
    • Then - Actions
      • Set Integers_TradeAmountMax[Integer_TradePlayer] = Integers_TradeAmountMax[(Integer_TradePlayer + Integer_TradeAmount)]
    • Else - Actions
  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Integers_TradeAmountMax[(Integer_TradePlayer + Integer_TradeAmount)] Less than or equal to (<=) 2000) and (((Triggering player) Current lumber) Greater than (>) 0)
    • Then - Actions
      • Set Integers_TradeAmountMax[Integer_TradePlayer] = Integers_TradeAmountMax[(Integer_TradePlayer + Integer_TradeAmount)]
    • Else - Actions
 
Kind of. But you sum up the array index in the right part of the calucation. You have to read Tradeamount at arrayIndex [player] and add Tradeamount to that value.

For useability (for players) it also might be nice if your trigger would change the wanted Tradeamount to the maximum possible, if the maximum would exceed.
 
Status
Not open for further replies.
Top