jonbuckles 10 Posted August 28, 2014 I have an issue trying to get a spawned unit via a trigger to have a working INIT field filled in.. if that makes sense. So Ive used this code for the civilians INIT field (which works great if i spawn the civilian unit with the editor and fill in the INIT field) null = [this] execVM "shaun.sqf"; this addEventHandler ["HandleDamage", {((_this select 2)/2)}];this setunitpos "up";0 = this spawn {sleep 1; removeHeadgear _this; removeGoggles _this};enableSentences false; But i want to be able to spawn a civilian in via a trigger like this (which also works great; i use spawn markers like spawn1, spawn2 ect.) GroupOne_X = Creategroup Civilian; "C_man_1" createUnit [getMarkerPos "spawn1",GroupOne_X,"this allowFleeing 0",random 1, "Private"]; The problem is i want to be able to spawn a civilian in with the INIT field filled in with the top code.. any ideas? Share this post Link to post Share on other sites
Kushluk 21 Posted August 28, 2014 Written the way you have it, like this: GroupOne_X = Creategroup Civilian; CivilianOne_X = "C_man_1" createUnit [getMarkerPos "spawn1",GroupOne_X,"this allowFleeing 0",random 1, "Private"]; null = [CivilianOne_X] execVM "shaun.sqf"; CivilianOne_X addEventHandler ["HandleDamage", {((_this select 2)/2)}]; CivilianOne_X setunitpos "up"; 0 = CivilianOne_X spawn { sleep 1; removeHeadgear _this; removeGoggles _this }; enableSentences false; I would do it like this: Trigger [getMarkerPos "spawn1"] execVM "myScript.sqf"; myScript.sqf if(!isServer) exitWith {}; _location = _this select 0; _group = createGroup civilian; _civilian = "C_man_1" createUnit [_location,_group]; _civilian addEventHandler ["HandleDamage", {((_this select 2)/2)}]; _civilian setUnitPos "up"; [_civilian] execVM "shaun.sqf"; sleep 1; removeHeadgear _civilian; removeGoggles _civilian Share this post Link to post Share on other sites
jonbuckles 10 Posted August 28, 2014 (edited) So I tried your first code you gave me and the editor gave me this error: "type nothing, expected any" The second solution you gave me also had an error "Type script, expected nothing" However I tried this code: GroupOne_X = Creategroup Civilian; "C_man_1" createUnit [getMarkerPos "spawn1",GroupOne_X, "removeAllItems this; removeAllWeapons this; enableradio false; _nul = [this] execVM ""shaun.sqf"";", 0.5, "private"]; And it works, however I'm not sure how to add the rest of the below code: this addEventHandler ["HandleDamage", {((_this select 2)/2)}];this setunitpos "up";0 = this spawn {sleep 1; removeHeadgear _this; removeGoggles _this};enableSentences false; ---------- Post added at 03:44 ---------- Previous post was at 03:19 ---------- okay got everything working but this line of code: this addEventHandler ["HandleDamage", {((_this select 2)/2)}]; Edited August 28, 2014 by jonbuckles Share this post Link to post Share on other sites