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

Anyway to make -give (color) trigger shorter?

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
i made to u both

-give *color*
-give *player number*

try it the map

player number
  • Blabla with player number
    • Events
      • Player - Player 1 (Red) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 2 (Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 3 (Teal) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 4 (Purple) types a chat message containing (Substring(-give , 1, 6)) as A substring
    • Conditions
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set String = (Substring((Entered chat string), 7, ((Length of (Entered chat string)) - 7)))
      • Set PlayerNumber = (Integer(String))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PlayerNumber Greater than 0
          • PlayerNumber Less than 13
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( want something from + (Name of (Player(PlayerNumber)))))
        • Else - Actions
with color

map init
  • Map init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ColorNames[1] = Red
      • Set ColorNames[2] = Blue
      • Set ColorNames[3] = Cyan
      • Set ColorNames[4] = Purple
      • Set ColorNames[5] = Yellow
      • Set ColorNames[6] = Orange
      • Set ColorNames[7] = Green
      • Set ColorNames[8] = Pink
      • Set ColorNames[9] = Gray
      • Set ColorNames[10] = Light Blue
      • Set ColorNames[11] = Aqua
      • Set ColorNames[12] = Brown
trigger
  • Blabla with color names
    • Events
      • Player - Player 1 (Red) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 2 (Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 3 (Teal) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 4 (Purple) types a chat message containing (Substring(-give , 1, 6)) as A substring
    • Conditions
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set String = (Substring((Entered chat string), 7, ((Length of (Entered chat string)) - 7)))
      • Set String = (String(String) as Lower case)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • String Equal to (String(ColorNames[(Integer A)]) as Lower case)
            • Then - Actions
              • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( want something from + (Name of (Player((Integer A))))))
              • Skip remaining actions
            • Else - Actions
 

Attachments

  • giveplayer.w3x
    17.9 KB · Views: 35
Level 17
Joined
Nov 13, 2006
Messages
1,814
Can you tell me what the 1 in the substring is used for and what the 6 and 7 are used for?

substring is used in every program language, baseically cat a part from string

example:

String = "Player 12"
//if u write out this then result: Player 12
String = Substring(String,2,4)
//if u write out this then result: Player 12

so Substring(YourString,CutStart,CutEnd)
CutStart=character position in string, u start cut from here
//example "P" = 1, "l" = 2, "a" =3, "y" =4,"e"=5,"r"=6, " " = 7, "1" = 8, "2" = 9th character in string
CutEnd =that character position when ur cutting is over

Edit:Nevermind,but can you confirm what I believe it is? 1=red(player 1) 6 is to make sure it is -give 1 (enter chat string greater than or equal to 6)
7 is to clean up the chat string? lol idk, :/
acctually from 7 character is the info
so if your command is "-give 8"
then
string="-give 8"

SubString(string.1.1)="-"
SubString(string.2.2)="g"
SubString(string.3.3)="i"
SubString(string.4.4)="v"
SubString(string.5.5)="e"
SubString(string.6.6)=" "
SubString(string.7.7)="8"

so i convert the 7th string character to integer and "8" is 8, its mean Player(8) :p

i made condition because if u typed only "-give " what is 6 character long then the trigger dont running, coz simnple senseless, dont ahve any info because player number will be 7th character :p
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Since u pmed me i post here your request

(i also uploaded the demo map for you, u need copy the triggers only)

Your request:
command what give the selected units to another player (GUI) with
-give *player color code or player number*

map init if u need player color code solution
  • Map init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Set ColorNames[1] = Red
      • Set ColorNames[2] = Blue
      • Set ColorNames[3] = Cyan
      • Set ColorNames[4] = Purple
      • Set ColorNames[5] = Yellow
      • Set ColorNames[6] = Orange
      • Set ColorNames[7] = Green
      • Set ColorNames[8] = Pink
      • Set ColorNames[9] = Gray
      • Set ColorNames[10] = Light Blue
      • Set ColorNames[11] = Aqua
      • Set ColorNames[12] = Brown
Color name command

  • Give unit command with color names
    • Events
      • Player - Player 1 (Red) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 2 (Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 3 (Teal) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 4 (Purple) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 5 (Yellow) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 6 (Orange) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 7 (Green) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 8 (Pink) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 9 (Gray) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 10 (Light Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 11 (Dark Green) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 12 (Brown) types a chat message containing (Substring(-give , 1, 6)) as A substring
    • Conditions
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set PlayerGroup = (Player group((Triggering player)))
      • Set String = (Substring((Entered chat string), 7, ((Length of (Entered chat string)) - 7)))
      • Set String = (String(String) as Lower case)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • String Equal to (String(ColorNames[(Integer A)]) as Lower case)
            • Then - Actions
              • Set PlayerNumber = (Integer A)
              • Set TempUnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is selected by (Triggering player)) Equal to True))
              • Set Count = (Number of units in TempUnitGroup)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Count Greater than 0
                • Then - Actions
                  • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( gived + (((String(Count)) + unit to ) + (Name of (Player(PlayerNumber))))))
                  • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                    • Loop - Actions
                      • Unit - Change ownership of (Picked unit) to (Player(PlayerNumber)) and Change color
                • Else - Actions
                  • Game - Display to PlayerGroup the text: (Select unit what u want give to + (Name of (Player(PlayerNumber))))
              • Custom script: call DestroyGroup (udg_TempUnitGroup)
              • Skip remaining actions
            • Else - Actions
  • Custom script: call DestroyForce(udg_PlayerGroup)
With player number

  • Give unit command with player number
    • Events
      • Player - Player 1 (Red) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 2 (Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 3 (Teal) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 4 (Purple) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 5 (Yellow) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 6 (Orange) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 7 (Green) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 8 (Pink) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 9 (Gray) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 10 (Light Blue) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 11 (Dark Green) types a chat message containing (Substring(-give , 1, 6)) as A substring
      • Player - Player 12 (Brown) types a chat message containing (Substring(-give , 1, 6)) as A substring
    • Conditions
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set PlayerGroup = (Player group((Triggering player)))
      • Set String = (Substring((Entered chat string), 7, ((Length of (Entered chat string)) - 7)))
      • Set PlayerNumber = (Integer(String))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PlayerNumber Greater than 0
          • PlayerNumber Less than 13
        • Then - Actions
          • Set TempUnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is selected by (Triggering player)) Equal to True))
          • Set Count = (Number of units in TempUnitGroup)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Count Greater than 0
            • Then - Actions
              • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( gived + (((String(Count)) + unit to ) + (Name of (Player(PlayerNumber))))))
              • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Player(PlayerNumber)) and Change color
            • Else - Actions
              • Game - Display to PlayerGroup the text: (Select unit what u want give to + (Name of (Player(PlayerNumber))))
              • Custom script: call DestroyGroup (udg_TempUnitGroup)
        • Else - Actions
  • Custom script: call DestroyForce(udg_PlayerGroup)
ofc u can use both too, dont ahve conflict the triggers with eachother
 

Attachments

  • giveplayer.w3x
    21.1 KB · Views: 32
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
Because the GUI actions create a group every time they are used. The jass code you posted uses a global group, it doesn't create new ones.

In post #5 of this thread, check where the DestroyGroup is. It should be after the if/then/else.

i see

2. it was outside from if, just i edited manually my post instead copy trigger again, in map it is in right place :)
 
Status
Not open for further replies.
Top