Daemios 10 Posted May 27, 2014 I'm running into an issue where two of the same functions I'm calling refuse to place nice together. Whatever I do, it will only ever call the second one. This is my first time using a function like this, so I'm sure I'm doing something horribly wrong, but I would appreciate any pointers as to why this isn't right. _placePos = _this select 0; //Example: //_n = [(getpos player)] execVM "hq\lib\fuel\lib_refuelAlpha.sqf"; //Useful: //_placePos = (getpos player); fuelAlphaSpeaker setPos [((_placePos select 0)-3),((_placePos select 1)-6),0];; // HQ fuelAlphaMain = createVehicle ["Land_Cargo_HQ_V2_F",(_placePos),[], 0, "CAN_COLLIDE"]; fuelAlphaMain allowDamage false; fuelAlphaMain setDir 270; // Towers fuelAlphaEnterTower = createVehicle ["Land_Cargo_Patrol_V2_F",[((_placePos select 0)-2),((_placePos select 1)-30),0],[], 0, "CAN_COLLIDE"]; fuelAlphaEnterTower setDir 0; fuelAlphaSideTower = createVehicle ["Land_Cargo_Patrol_V2_F",[((_placePos select 0)-25),((_placePos select 1)+15),0],[], 0, "CAN_COLLIDE"]; fuelAlphaSideTower setDir 135; // Military Misc fuelAlphaSpeaker = createVehicle ["Land_Loudspeakers_F",[((_placePos select 0)-3),((_placePos select 1)-6),0],[], 0, "CAN_COLLIDE"]; fuelAlphaSpeaker setDir 0; sleep 1; //N2 After 5m Break [ [((_placePos select 0)+5),((_placePos select 1)+19),0], 0, "Land_HBarrier_5_F", 1, 5.5, 0, 0 ] call bad_fnc_objRepeat; [ [((_placePos select 0)-20),((_placePos select 1)+19),0], 0, "Land_HBarrier_5_F", 3, 5.5, 0, 0 ] call bad_fnc_objRepeat; Here's the function itself: bad_fnc_objRepeat = { private ["_start","_obj","_objPos","_objDir"]; _start = createVehicle [_this select 2, _this select 0,[],0,"CAN_COLLIDE"]; _start setVectorUp [0,0,1]; _start setDir (_this select 1); _start setPosATL (_this select 0); for "_i" from 1 to (_this select 3) do { _obj = createVehicle [ _this select 2, _this select 0, [], 0, "CAN_COLLIDE"]; _obj attachTo [_start, [ _i*(_this select 4), _i*(_this select 5), _i*(_this select 6) ]]; _objPos = getPosATL _obj; _objDir = getDir _obj; detach _obj; _obj setPosATL _objPos; _obj setDir _objDir; }; }; I've tried adding a sleep in between them, to see if it was some sort of speed issue. No luck. Share this post Link to post Share on other sites
Tajin 349 Posted May 27, 2014 Have you checked if you get any script-errors in that function? PS.: I don't get why so many ppl use attachTo/Detach instead of using setPos with modelToWorld. ^^ Share this post Link to post Share on other sites
Daemios 10 Posted May 27, 2014 No errors, unfortunately. I did manage to get it partially working. I used the spawn function vs the call function. However, it still doesn't work the first time the script executes. I can call the first script once and it wont spawn the Land_HBarrier_5_F that it's supposed to. I can then move away from that spawn (or not) and call it again and it works fine. Thoughts? Edit: I haven't done much with modelToWorld yet, but really I use attach here to fit each piece perfectly to each other. It works, so it works for me. As per your last post helping me, I definitely have started taking a look at modelToWorld more. Share this post Link to post Share on other sites
f2k sel 164 Posted May 27, 2014 (edited) Looks ok to me now I had the same issue but I wasn't calling it with the correct preprocess commands. init.sqf waitUntil {not(isNil "BIS_fnc_init")}; call compile preprocessFile "fnc_objRepeat.sqf"; just change the file name to whatever name you used to save the function. Edited May 27, 2014 by F2k Sel Share this post Link to post Share on other sites
Daemios 10 Posted May 27, 2014 Awesome! Thanks again. F2k and Taijin, you guys are both excellent. Thanks for supporting the community like this, I know there's at least one person who appreciates it! Share this post Link to post Share on other sites