HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Damn trigger won't work...

09-08-2004, 10:09 PM#1
DragonGeo2
Ok here's what I want the thing to do! I want it to see when a player (in this case player 1) says "Spawn " then a hero name, I use the trigger to extract the String of the hero name (using the Substring function on the text the player entered) and then I say Spawn unit (unitname) at location! And it won't work! Anyone know why?
Here's the Jass:


function Trig_Player1Spawn_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, String2UnitIdBJ(SubStringBJ(GetEventPlayerChatString(), 6, ( StringLength(GetEventPlayerChatString()) - 6 ))), GetTriggerPlayer(), GetRectCenter(gg_rct_HeroesSpawnHere), bj_UNIT_FACING )
call DisableTrigger( GetTriggeringTrigger() )
call QueuedTriggerRemoveBJ( GetTriggeringTrigger() )
call DisableTrigger( GetTriggeringTrigger() )
endfunction
09-08-2004, 10:13 PM#2
DragonGeo2
Yes, i am doing this as a really simple way to do a hero spawn in a map, plus it gives the players the opportunity to select ANY hero they want! Not just the heroes that they see standing next to all those circle of powers. They can even select custom heroes like Jaina and Thrall, however, it Won't WORK!
Also, the jass script got a bit cut off when I pasted it into the post, it should really look like this:

function Trig_Player1Spawn_Actions takes nothing returns nothing
-----call CreateNUnitsAtLoc( 1, String2UnitIdBJ(SubStringBJ(GetEventPlayerChatString(), 6, ( StringLength(GetEventPlayerChatString()) - 6 ))), GetTriggerPlayer(), GetRectCenter(gg_rct_HeroesSpawnHere), bj_UNIT_FACING ) ;
-----call DisableTrigger( GetTriggeringTrigger() ) ;
-----call QueuedTriggerRemoveBJ( GetTriggeringTrigger() ) ;
-----call DisableTrigger( GetTriggeringTrigger() ) ;
endfunction


yeah, i'm a big C++ junkie, and so i put the semicolons there to look good and to tell you where the lines end, the dashes are for indentation, as I cannot get the darn forums to display how i want them to
09-09-2004, 12:32 AM#3
AIAndy
If I get you correctly it compiles fine but then when you enter the string it does not work properly?
Have you put some display text in there to see if the trigger actually runs?
Also the names that are used for String2UnitId are not always the hero names. E.g. the string for the observatory is goblinammodump.
09-09-2004, 01:15 AM#4
-={tWiStÄr}=-
use [code.][/code.] (no dots) tags to get indents but the real prob now:
Code:
call CreateNUnitsAtLoc( 1, String2UnitIdBJ(SubStringBJ([color=red]GetEventPlayerChatStri ng[/color](), 6, ( StringLength(GetEventPlayerChatString()) - 6 ))), GetTriggerPlayer(), GetRectCenter(gg_rct_HeroesSpawnHere), bj_UNIT_FACING )
If your getting a compile error thats it.. the map shouldnt even be able to run if thats it. but what is the - 6 for? it they type in Spawn Jaina it will try to create a well.. negative space.. get rid of that and it should work.
09-09-2004, 07:17 PM#5
DragonGeo2
Well i'm trying to use the substring function to cut up the entered string, lets say it's "Spawn Jaina", I want it to take the substring "Jaina" so I tell it to start at the 6th place (S-p-a-w-n- ) and then create the new string out of the remainder of the original string (done by calculating the string length, then subtracting 6, which is the part that was cut out). Anyway, thanks for the tip AIAndy about the unit names, but i'll name all the heroes available (all of them) accordingly to thier names (blademaster will be "blademaster", not something like "orcsamurai" or something) in the custom unit area. And i'm not getting any compile errors, it jsut won't spawn anything when i type something.
09-10-2004, 01:19 AM#6
-={tWiStÄr}=-
what you do is you take Spawn Jaina 6-(length-6) well string length is 11 so you are doing Substring 6-5 which doesnt work. if you do 6-length thats 6-11 (or Jaina) so thats what you want.