TurokGMT 0 Posted April 14, 2009 (edited) Keep getting a missing "{" error. _logic = _this select 0; _house = nearestbuilding _logic; _pos = []; _grp = creategroup resistance; _j = 0; while { format ["%1", _house buildingPos _j] != "[0,0,0]" } do {_j = _j + 1}; _j = (_j - 1); for ("_i" from 0 to _j) do { _pos = (_house buildingpos _i); null = _grp createunit ["ACE_SoldierGAR",_pos,[],0,"NONE"]; }; the problem lies with the final loop. Tried rewriting it with a a while structure and get the same problem. Can seomone help me? =[ Edited April 14, 2009 by TurokGMT Share this post Link to post Share on other sites
TurokGMT 0 Posted April 14, 2009 current version looks like this. Same problem: _logic = _this select 0; _house = nearestbuilding _logic; _pos = []; _grp = creategroup resistance; _i = 0; _j = 0; _loop = true; while { format ["%1", _house buildingPos _j] != "[0,0,0]" } do {_j = _j + 1}; _j = (_j - 1); // limit troop creation if (_j > 20) then {_j = 20}; while {_loop} do { _pos = (_house buildingpos _i); null = _grp createunit ["ACE_SoldierGAR",_pos,[],0,"NONE"]; _i = _i + 1; if (_i == _j) then {_loop = false;}; }; Share this post Link to post Share on other sites
dr_eyeball 16 Posted April 14, 2009 The script looks technically fine, except for some issues. You are most likely executing this SQF script using 'exec' instead of 'execVM'. Other issues: - When creating a group of side resistance, you either need to already have a resistance unit in the mission or create a 'center' (side) using createCenter. - Using createUnit won't create the unit at the specified position. Instead it finds a nearby position. Use setPos to correct this. Share this post Link to post Share on other sites
Rav_Raven 8 Posted April 15, 2009 (edited) You can not compare arrays complete and should do so by its elements: (while (_house buildingPos _J) select 0! = 0 or (_house BuildingPos _J) select 1! = 0 or (_house buildingPos _J) select 2! = 0 do (_J _J = + 1); I think it may be the source of your problem although I have not tried. Edited April 15, 2009 by RAV_RAVEN Share this post Link to post Share on other sites
Serclaes 0 Posted April 15, 2009 I would advise you to make your while loop look like this: while {_i <= _j} do { _pos = (_house buildingpos _i); null = _grp createunit ["ACE_SoldierGAR",_pos,[],0,"NONE"]; _i = _i + 1; }; The comparison via ==, <=, >=, <, or > returns a boolean (true/false) and makes your life easier. You can explicitly see that the possibility of a _j = -1; is escaped. Also, i believe he expects code ({} or ""} as third parameter of createUnit, as opposed to the array ( [] ) you are passing right now. @RAV RAVEN: he is not comparing arrays, he's comparing strings. He transforms the array into a string with the format function. Share this post Link to post Share on other sites
TurokGMT 0 Posted April 15, 2009 - I've already got the resistance HQ being created in init.sqf - The group is created in this script - The script creates the first unit fine (although doesn't place him at the occupiable building position - this might be a placement issue as discussed) @Serclaes - I've tried similar while boolean structures to set the loop up, going through every iteration I can think of, inculding the type you've suggested, but thank you for your idea! Can anyone try the code out for themselves (needs ACEmod v1.06 if you use my code as is because of the unit being created) and post a verified working script correction? It's doing my head in! Share this post Link to post Share on other sites
Serclaes 0 Posted April 15, 2009 (edited) I tried the version you posted above (with the while loop). No problems. I had one problem the first time, i inserted the execution in the init of the logic i created which somehow hung up my arma. But that may have been because the building didnt have any positions. For the second time i used a trigger (radio bla activation) and the rusty warehouse on rahmadi which did create me 18 soldiers (for 18 positions). And it worked good. Except that all the blokes were ordered back to their formation and were not created exactly on the spot but thats the easy part. Edited April 15, 2009 by Serclaes Share this post Link to post Share on other sites
TurokGMT 0 Posted April 15, 2009 I'm calling mine from init.sqf I've inserted a gamelogic unit (called dave) and call it with [dave] execvm "occupypos.sqf"; my target building is one of the factory buildings in avgani (the one to the south that has no other nearby buildings) it has a confirmed 28 occupiable positions currently it creates a single unit (outside...) then throws up the dreaded "missing {" error... Share this post Link to post Share on other sites
Serclaes 0 Posted April 15, 2009 just tried it again, no problems executed like this: nul = [logic] execVM "manBuilding.sqf"; again with a trigger. Share this post Link to post Share on other sites
TurokGMT 0 Posted April 15, 2009 ok...changed how script is being called. null = [dave] execvm "occupypos.sqf"; now calling without script error, but confirm soldiers are imediately returning to formation This may be because there are TWO ways to create a unit in ARMA The old Operation Flashpoint call: type createUnit [ position, group, init, skill, rank] eg for me would be "ACE_SoldierGAR" creatunit [_pos,_grp,"",0.5,"PRIVATE"]; the trouble with this version is that it doesn't allow spawning out of formation. The alternative is the "createunit array" version introduced in ARMA v1.00 Object = group createUnit [type, position, markers, placement, special] which is the one I've used because placement set to 0 should ensure unit is created at _pos and special SHOULD allow "NONE" which prevents them grouping into formation once spawned... Share this post Link to post Share on other sites
Serclaes 0 Posted April 15, 2009 They don't spawn in formation but they will return to formation once created. You will need to stop them, either by commandStop or doStop. createUnit create a unit at the next free space to the given location. To have them exactly on the point you want you will have to setPos them there. Share this post Link to post Share on other sites
xeno 234 Posted April 15, 2009 Immediately after creation disable movement. _unit disableAI "MOVE"; Xeno Share this post Link to post Share on other sites
Serclaes 0 Posted April 15, 2009 Ah yes of course, you are using ACE. Forgot that ACE disables doStop and commandStop Share this post Link to post Share on other sites
TurokGMT 0 Posted April 15, 2009 (edited) W00t!! Think I've nailed it: Script Requires: 1. EITHER a resistance/guerilla unit to be placed on map OR _GuerHQ = createcentre Resistance; used in init.sqf before calling the script 2. An object (logic units preferable, but will work with any object) to centre the script on. This can be in the mission editor, or dynamically identified by a trigger etc. CALLING SYNTAX: null = [object] execvm "OccupyPos.sqf"; _logic = _this select 0; _house = nearestbuilding _logic; _pos = []; _grp = creategroup resistance; _j = 0; _loop = true; while { format ["%1", _house buildingPos _j] != "[0,0,0]" } do {_j = _j + 1}; _j = (_j - 1); // limit troop creation if (_j > 20) then {_j = 20}; for "_i" from 0 to _j do { _pos = (_house buildingpos _i); _unit = _grp createunit ["ACE_SoldierGAR",_pos,[],0,"NONE"]; _unit setpos _pos; _unit disableAI "MOVE"; _unit setdir (random(360)); }; Once the unit is created, just chuck him back where he is supposed to be. Thanks for the help guys, script is now working as intended! Edited April 15, 2009 by TurokGMT Share this post Link to post Share on other sites