clydefrog 3 Posted April 16, 2013 I have a cargo box attached to a vehicle, after running an addaction script on the vehicle I want to detach the object but then I'd like to be able to set the position of the object on the ground to the left or right of the vehicle, is this possible? Here's the code I have so far: in main script: // Create cargo box and attach it to the vehicle (already created) cargobox1 = createVehicle ["Land_CargoBox_V1_F", getPos _veh1, [], 0, "NONE"]; cargobox1 attachTo [_veh1, [0,-2.0,0.1]]; // Add action to vehicle, remove action afterwards showAction1 = true; publicVariable "showAction1"; _veh1 addAction ["Take Stuff", "scripts\carintel1.sqf", [], 1, false, true, "", "showAction1"]; and then in carintel1.sqf: // carintel1.sqf // set variable to hide action menu showAction1=false; publicVariable "showAction1"; // play animation for player player playmove "AidlPknlMstpSnonWnonDnon01"; sleep 5; detach cargobox1; sleep 2; deletevehicle cargobox1; // set variable for action used car1intel = true; publicVariable "car1intel"; As you can see it currently just deletes the cargobox object when the addaction is run, but I'd like to first move the box onto the ground beside the vehicle. Anybody know how to do this? I know it's something to do with setPos but I don't know how to go about it with this as the vehicle name is local (_veh1) in the main script so it can't be accessed by the car1intel script, ideally I would like to keep it local to the main script as well if possible. The script is for multiplayer by the way. Thanks Share this post Link to post Share on other sites
f2k sel 164 Posted April 17, 2013 Just use another attachto command giving it the x,y,z of the new location relative to the vehicle. Then use the detach object. To make sure it's on the ground you could then use setpos as setting the height in the attachto would be hit and miss depending on the terrain. cargobox1 attachto [_veh1,[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; Share this post Link to post Share on other sites
clydefrog 3 Posted April 17, 2013 Just use another attachto command giving it the x,y,z of the new location relative to the vehicle.Then use the detach object. To make sure it's on the ground you could then use setpos as setting the height in the attachto would be hit and miss depending on the terrain. cargobox1 attachto [_veh1,[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; Cheers, but doing it this way if I do it through the carintel1.sqf, it means I will need to give the vehicle a global name in the main script. If this is the only way it will be possible then I guess that's what I'll need to do though. Share this post Link to post Share on other sites
f2k sel 164 Posted April 17, 2013 (edited) At some point you know what vehicle it is attached to so you could store that name in a objects name variable in the script where you attach the box cargobox1 setvariable ["veh_box1",_veh1,true]; then to use it later cargobox1 attachto [getvariable "veh_box1",[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; Or you may get away with nearestobject veh=nearestobject [cargobox1,"car"]; cargobox1 attachto [veh,[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; I've not tested these but either should work as long as the syntax is correct. Edited April 17, 2013 by F2k Sel Share this post Link to post Share on other sites
clydefrog 3 Posted April 18, 2013 (edited) At some point you know what vehicle it is attached to so you could store that name in a objects name variablein the script where you attach the box cargobox1 setvariable ["veh_box1",_veh1,true]; then to use it later cargobox1 attachto [getvariable "veh_box1",[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; Or you may get away with nearestobject veh=nearestobject [cargobox1,"car"]; cargobox1 attachto [veh,[3,-2,0]];// you could probably use modeltoworld detach cargobox1; cargobox1 setpos [getpos cargobox1 select 0,getpos cargobox1 select 1,0]; I've not tested these but either should work as long as the syntax is correct. Thanks Sel, the first setvariable/getvariable way didn't work but the nearestobject one did. I know you don't do MP missions but in your opinion should that work? I know attachTo and detach only need to be executed on one client so it should be fine doing that through an addaction, but setpos I don't know about. I take it even though addactions only run the commands given for the person who executed it, global commands will remain global e.g. deletevehicle in an addaction will still delete the object for every client? ---------- Post added at 22:31 ---------- Previous post was at 20:46 ---------- Ok there's actually a big problem with this and so far I can't find out how to fix it. Adding the action in the script only adds the action for the server (as it is in the isServer if statement). I thought ok well I'll just move it outside of that statement and that will fix it but this just caused more different problems and no longer showed the action at all. Edited April 18, 2013 by clydefrog Share this post Link to post Share on other sites