Trulz 1 Posted January 2, 2013 Hey, I have a problem with the createUnit command. The error message tells me that there's a missing "]" but I can't find the spot. As far as I see it all needed "]" are placed. _grp = createGroup Civilian; "Haris_Press_EP1" createUnit [getMarkerPos _mkr, _grp, "this setCaptive true; Reporter = this; Join = this addAction ["Zivilist befreien", "CivJoinGrp.sqf"];"]; This is the spot in my script. _mkr is the marker. It's filled with a String("mkr1" for example). I've already tried it with createUnit array and that works fine. The problem is I don't have an Init-parameter with that function. I used the Wiki explanation of createUnit to script that. I hope some of the experts here can help me out. Thanks in advance. Greetings, Truls Share this post Link to post Share on other sites
tryteyker 28 Posted January 2, 2013 (edited) "this setCaptive true; Reporter = this; Join = this addAction ["Zivilist befreien", "CivJoinGrp.sqf"];"]; When using "" within "" make sure to use single quotes. "this setCaptive true; Reporter = this; Join = this addAction ['Zivilist befreien', 'CivJoinGrp.sqf'];"]; Should work. Else try double double quotes (like this: ""...""). Optimized createUnit array (notice that you can ALWAYS access the unit via the variable, you do not need to name it): _reporter = _grp createUnit ["Haris_Press_EP1", (getmarkerpos "mkr1"), ["mkr2","mkr3"], 0, "NONE"]; _reporter addAction ["Zivilist befreien", "CivJoinGrp.sqf"]; _reporter setCaptive true; Also note that you do not need an array of markers (_mkr) but instead you define your first marker with (getmarkerpos "markername") and additional markers go into the array of markers ["mkr2","mkr3"]; Edited January 2, 2013 by tryteyker Share this post Link to post Share on other sites
Trulz 1 Posted January 2, 2013 Thanks for the quick help. It worked. I would've searched for ages to find that mistake. Share this post Link to post Share on other sites
tryteyker 28 Posted January 2, 2013 Take a look at my edit aswell, I made you a createUnit array version (since that is about x10 faster than the regular createUnit) Share this post Link to post Share on other sites
iceman77 18 Posted January 2, 2013 trulz you should use squint. That will keep typos / syntax in check :) Share this post Link to post Share on other sites
Trulz 1 Posted January 2, 2013 I gave the unit a name to use it with a trigger. I want the trigger to go off if the unit is near it/into the trigger area. Therefore it needs a name, doesn't it? _mkr = _this select 0; hint "Script Civilian gestartet!"; sleep 10; hint format ["Marker Pos: %1", _mkr]; _grp = createGroup Civilian; "Haris_Press_EP1" createUnit [getMarkerPos _mkr, _grp, "this setCaptive true; Reporter = this; Join = this addAction ['Zivilist befreien', 'CivJoinGrp.sqf'];"]; sleep 10; hint "Script Ende! NPC erzeugt!"; Edit: All the HINTs and SLEEPs are debugging entries. This is the script atm. _mkr gets the value from another script that chooses one of three markers on the map and sets that marker to visible. As far as I know it would be easier to give the creatUnit array function a marker array because it chooses one of those markers randomly and automaticly. @Iceman77 Thanks for the hint. I'll try that. I've tried to use Notepadd++ with ArmA-Script but somehow that doesn't work that well. Share this post Link to post Share on other sites
tryteyker 28 Posted January 2, 2013 What exactly are you passing to the script inside the array? If you do it like this: [marker1,2,3] execVM "yourscript.sqf"; it will ONLY choose marker1. Actually not too sure about this, will test it. To randomly select a markerpos you should use (floor(random 3)); However this is unnecessary since createVehicle array does this automatically. About your trigger issue, you would simply use just "reporter" instead of "_reporter" to make the unit a global instead of local variable. This way you can access the unit via trigger in the game itself. Share this post Link to post Share on other sites
Trulz 1 Posted January 2, 2013 What exactly are you passing to the script inside the array?If you do it like this: [marker1,2,3] execVM "yourscript.sqf"; it will ONLY choose marker1. Actually not too sure about this, will test it. To randomly select a markerpos you should use (floor(random 3)); However this is unnecessary since createVehicle array does this automatically. About your trigger issue, you would simply use just "reporter" instead of "_reporter" to make the unit a global instead of local variable. This way you can access the unit via trigger in the game itself. The value of _mkr is just one string. It's the actual marker name. I.e. "mkr1". This is the part of the other script that passes the mkr-value. _rNumber = round(random 2); hint format["%1",_rNumber]; switch (_rNumber) do { case 0: {"mkr1" setMarkerType "Unknown"; mkr = "mkr1"}; case 1: {"mkr2" setMarkerType "Unknown"; mkr = "mkr2"}; case 2: {"mkr3" setMarkerType "Unknown"; mkr = "mkr3"}; }; hint "Informant wurde befragt!"; call {[mkr] execVM "civilian.sqf"}; About the random marker thing from createUnit array - Here's a quote from the Wiki: Creates a unit (person) of the given type (type is a name of a subclass of CfgVehicles) and makes it a member of the given group. If the markers array contains several marker names, the position of a random one is used. Otherwise, the given position is used. The unit is placed inside a circle with this position as its center and placement as its radius. Share this post Link to post Share on other sites
tryteyker 28 Posted January 2, 2013 I suggest you use (floor(random 3)) instead of round(random 2). Gives better results (also floor always rounds down so case 3 will never be there). You can still use createUnit array. Just use (getmarkerpos _mkr) and then in the marker array [] simply leave it blank, since the other markers are just for randomization controls. Share this post Link to post Share on other sites