| 06-01-2006, 03:52 AM | #1 |
I need help settin up a good simple trigger for giving people units that u are selecting, even if someone posts an asnwer. if u know one pls tell! and leave ur warcraft name for credits pls. |
| 06-01-2006, 04:09 AM | #2 |
| 06-02-2006, 02:55 AM | #3 |
i was thinking more of a -give (player) type trigger, but it gives what u are selecting |
| 06-02-2006, 07:12 AM | #4 |
Trigger: Change Owner
That more like it? :P |
| 06-02-2006, 08:41 AM | #5 |
You'll need to use substrings to isolate the string in the message reffering to the player (ie: the 'red', 'blue'). At map initialisation, set up an array of size 12, with the player colours (red, blue, pink, etc.) Trigger: ![]() Events:
![]() Player - Player enters '-give ' as a substring. //You'll need one for each player
![]() Conditions:
![]() Actions:
![]() Set TempGroup = Units selected by triggering player and owned by triggering player.
![]() For each integer A from 1 to 12
![]() If substring(entered message, 7, 15) is equal to ARRAY[integer A]
![]() Then Unit group - pick every unit in TempGroup and change owner to Player(integer A)
![]() Else |
| 06-02-2006, 08:56 AM | #6 |
If you want it that far in depth, just ask for player numbers. That's much easier and doesn't require any additional work really. (Just one substring thinger) |
| 06-02-2006, 09:01 AM | #7 |
I have moved away from numbers after a couple of incidents where I kicked the wrong person. |
| 06-03-2006, 01:50 AM | #8 |
what does the "for each player 1 to 12" do and is it a contidionor action. |
| 06-03-2006, 01:49 PM | #9 |
It's a loop. It loops. Does each action in the loop for each integer from 1 to 12 (effectively 12 times), and you can get which integer it is on. Its an action. |
| 06-03-2006, 09:38 PM | #10 |
thnx alot im gona test it out. erm do u have a warcraft screen name i can give credits to? |
| 06-03-2006, 11:06 PM | #11 |
Captain_Griffen, proud European. Use the same alias pretty much everywhere. |
| 06-03-2006, 11:53 PM | #12 |
Here, have my code from D&D Crystal: JASS:function GiveEnumUnitSelected takes nothing returns nothing if IsUnitSelected(GetEnumUnit(), udg_TEMP_Player) then if GetBooleanOr(IsPlayerInForce(GetOwningPlayer(GetEnumUnit()), udg_Force[1]), IsPlayerInForce(GetOwningPlayer(GetEnumUnit()), udg_Force[3])) then call SetUnitOwner( GetEnumUnit(), ConvertedPlayer(udg_TEMP_Integer), true ) endif endif endfunction function GetPlayerNumFromStr takes string text returns integer local integer i if text == "red" then return 1 elseif text == "enemy" then return 1 elseif text == "blue" then return 2 elseif text == "teal" then return 3 elseif text == "purple" then return 4 elseif text == "yellow" then return 5 elseif text == "ally" then return 5 elseif text == "orange" then return 6 elseif text == "green" then return 7 elseif text == "pink" then return 8 elseif text == "grey" then return 9 elseif text == "gray" then return 9 elseif text == "cyan" then return 10 elseif text == "lightblue" then return 10 elseif text == "lb" then return 10 elseif text == "darkgreen" then return 11 elseif text == "dg" then return 11 elseif text == "brown" then return 12 elseif text == "black" then return 13 else set i = S2I(text) if i < 1 or i > 13 then return -1 endif return i endif return -1 endfunction //Give elseif SubStringBJ(str,1,4) == "give" then //Get rid of that pesky 'to' in quatredan if (SubStringBJ(str,5,6) == "to") then //Get rid of that pesky space people like to add if (SubStringBJ(str,7,7) == " ") then set text = SubStringBJ(str,8,StringLength(str)) else set text = SubStringBJ(str,7,StringLength(str)) endif else //Get rid of that pesky space people like to add if (SubStringBJ(str,5,5) == " ") then set text = SubStringBJ(str,6,StringLength(str)) else set text = SubStringBJ(str,5,StringLength(str)) endif endif set udg_TEMP_Integer = GetPlayerNumFromStr(text) set udg_TEMP_Player = pl if udg_TEMP_Integer == -1 then call DisplayTextToForce( fp, " |c00FF0000Invalid Player: |r" + text ) elseif IsPlayerInForce(ConvertedPlayer(udg_TEMP_Integer), udg_Force[1]) or IsPlayerInForce(ConvertedPlayer(udg_TEMP_Integer), udg_Force[3]) then set grp = GetUnitsInRectAll(GetPlayableMapRect()) call ForGroupBJ( grp, function GiveEnumUnitSelected ) call DestroyGroup(grp) else call DisplayTextToForce( fp, " |c00FF0000Cannot give units to |r" + ColorNamePl(ConvertedPlayer(udg_TEMP_Integer)) + "|c00FF0000.|r" ) endif You'll have to fix it to work in your map obviously, but there it is. Like all commands in my map, it's very user-friendly and does not require a very rigid syntax; it will automatically parse out spaces, understands color names and numbers, and works with 'give' or QD&D-style 'giveto': give 10 give10 giveto 10 giveto10 give lb givecyan givetolightblue etc. Enjoy. |
| 06-03-2006, 11:56 PM | #13 |
Using code like JASS:elseif text == "darkgreen" then return 11 elseif text == "dg" then return 11 Seems a bit silly when you can use an or JASS:elseif text == "darkgreen" or text == "dg" then return 11 |
| 06-04-2006, 12:01 AM | #14 |
...So? It was easier to write my way, because I just pasted an elseif/return block like 20 times and then wrote the colors in. |
| 06-04-2006, 09:16 AM | #15 |
...So? It is still inefficient and bigger for no reason. |
