• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Help with a Give Command

Status
Not open for further replies.
Level 5
Joined
Jul 24, 2009
Messages
70
Here I'm making a give command but I get issues with selection bug. I want to be sure that when red select 12 units and do, for example, -give 2, it'll give those 12 units only to player 2. But instead of it, it also include units selected by other players else than red.

Here my actual trigger:
  • Events
  • Player - Player 1 type a chat message containing -give 2 as a equivalent result
  • Action
  • Group Unit - Pick every units in (units currently selected by player 1) and do (if owner of picked units equal to player 1) then do (unit - Change ownership of picked unit to player 2 and change color), else do nothing
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
  • Give Units
    • Events
      • Player - Player 1 (Red) types a chat message containing -give as A substring
    • Conditions
    • Actions
      • Set GivePlayer = (Player((Integer((Substring((Entered chat string), 7, 8))))))
      • Set GiveGroup = (Units currently selected by (Triggering player))
      • Unit Group - Pick every unit in GiveGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Triggering player)
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to GivePlayer and Change color
            • Else - Actions
This works fine.
 
Level 5
Joined
Jul 24, 2009
Messages
70
Thank you for your help but now my game crash.

When someone type somethign else than a number, the game crash. Like -give hostile, -give neutral, etc.

Any help about that?

Edit: Ok fixed the crash error by setting every possible events instead of just a simple -give.
 
Last edited:
Level 25
Joined
Jul 10, 2006
Messages
3,315
Sigh.

I am very annoyed that I gave you a functioning trigger and explained how to fix the possible crash.

Anyways, since it is the festive season:
  • Give
    • Events
      • Player - Player 1 (Red) types a chat message containing -give as A substring
      • Player - Player 2 (Blue) types a chat message containing -give as A substring
      • ...
      • Player - Player 12 (Brown) types a chat message containing -give as A substring
    • Conditions
    • Actions
      • Set tempGroup = (Units currently selected by (Triggering player))
      • Set tempInteger = (Integer((Substring((Entered chat string), 7, 8))))
      • -------- Check if the number is valid --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • tempInteger Greater than or equal to 1
              • tempInteger Less than or equal to 12
        • Then - Actions
          • Set tempPlayer = (Player(tempInteger))
          • Unit Group - Pick every unit in tempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to (Triggering player)
                • Then - Actions
                  • Unit - Change ownership of (Picked unit) to tempPlayer and Change color
                • Else - Actions
        • Else - Actions
      • Custom script: call DestroyGroup(udg_tempGroup)
Also attached, fill in the rest of the player events.
 

Attachments

  • GiveUnits.w3x
    17 KB · Views: 46
Status
Not open for further replies.
Top