BEAKSBY 11 Posted May 18, 2014 Hi Folkes, 1a) How do I get ArmorDrop.sqf to execute only after the onEachFrame {} is complete? I would like the last _pos from the onEachFrame loop to be passed to the ArmorDrop.sqf ...1b) how do I pass the _pos array? 2) How do I change the direction of _heli while in the onEachFrame loop by using the up arrow key? (or preferably mouse wheel) See script below: onEachFrame { _pos = screenToWorld [0.5,0.5];// land position _heli = createVehicle [ "B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1), 0], [], 0, "CANNOT_COLLIDE" ]; waituntil {!(IsNull (findDisplay 46))}; _keyDown1 = (findDisplay 46) displayAddEventHandler ["KeyDown1", "if (_this select 1 == 200) then {_yy = 10}"]; _heli setDir (direction player -_yy); _heli setVectorUp surfaceNormal position _heli; _heli setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; deleteVehicle _heli; waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {onEachFrame {};}"]; }; waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {_this = execVM "ArmorDrop.sqf";}"]; Share this post Link to post Share on other sites
f2k sel 164 Posted May 18, 2014 I haven't got much Idea about oneachframe so I removed it until it's all working, I think only the actual moving and rotating of the object need to be oneachframe. There was an awful amount of lag as you were in effect spawning an object on each frame along with all the event handlers which where probably also spawning every frame. So this version isn't using oneachframe but does work, it only spawns the object once and there is only one eventhandler per button. disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mous button down. dir1 = 0;// may need changing to setvariable private ["_heli"]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))};//test 1 _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+2} else {dir1=dir1-2}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 2) then {missionnamespace setvariable ['place',false]};"];// middle mouse button down //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {onEachFrame {};}"]; //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {_this = execVM 'ArmorDrop.sqf';}"]; // init Ghost vehicle _pos = screenToWorld [0.5,0.5];// land position _heli = createVehicle [ "B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1), 0], [], 0, "None" ]; // Move Ghost this bit may need the oneachframe commands while {missionnamespace getvariable ["place",true]} do { _pos = screenToWorld [0.5,0.5];// land position _heli setpos _pos; _heli setDir (getdir player )+ dir1; _heli setVectorUp surfaceNormal position _heli; _heli setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; //deleteVehicle _heli; sleep 0.01; }; // end of while/oneachframe deleteVehicle _heli;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. //[] execVM "ArmorDrop.sqf" _pos = screenToWorld [0.5,0.5]; _heli = createVehicle [ "B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1), 0], [], 0, "CAN_COLLIDE" ]; _heli setDir (getdir player )+ dir1; _heli setVectorUp surfaceNormal position _heli; Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 19, 2014 (edited) Thanks F2K Sel, I didn't any noticieable lag on my system, but may likely to occur when playing MP over the INTERNET. You script works, and I tried it initially that way too by moving the vehicle, but not sure how you prevent it from being destroyed if it slides through buildings etc. That's why I went with the create and delete inside the loop. Perhaps I can modify so it does the every 2 or 3rd frame? I call your script from an addAction, for some reason I can only run it once, then the next time I run the vehicle appears but cannot rotate or reposition it? Thanks for the mouse wheel portion too! I adjusted to 15 degree increments and this work faster. But it interferes with the default addAction commands so I changed it to Q and E instead. Also, the Armo.sqf should only be called after the vehicle is deleted. But I don't think you can put this in the onEachFrame loop. Otherwise it executes as soon as you press the addAction command. image = "\A3\armor_f_gamma\MBT_01\Data\ui\map_slammer_mk4_ca.paa"; _txt = composeText ["Cannot place", image _image, image _imageText, _separator1, "here"]; if (!isnull cursortarget) then {hint _txt}; disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. dir1 = 0;// may need changing to setvariable private ["_heli"]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))};//test 1 _KeyDownQ = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 18) then {dir1=dir1+5}"];// E key _KeyDownE = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 16) then {dir1=dir1-5}"];// Q key // _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+15} else {dir1=dir1-15}"];// mouse scroll // _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 2) then {missionnamespace setvariable ['place',false]};"];// middle mouse button down // Create and delete vehicle onEachFrame { _pos = screenToWorld [0.5,0.5];// land position if (!isnull cursortarget) then { _pos = [0,0,0]}; // cannot create inside building or object position _heli = createVehicle [ "B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1), (_pos select 2) +0.5], [], 0, "CANNOT_COLLIDE" ]; _heli setpos _pos; _heli setDir (getdir player )+ dir1; _heli setVectorUp surfaceNormal position _heli; _heli setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _heli setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; deleteVehicle _heli; waituntil {!(IsNull (findDisplay 46))}; _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 2) then {onEachFrame {};}"]; sleep 0.01; }; // end of while/oneachframe //deleteVehicle _heli;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script ** BUT THIS SHOULD ONLY BE CALLED IN AFTER THE VEHICLE IS DELETED ** // [] execVM "ArmorDrop.sqf"; /* ** BUT THIS SHOULD ONLY BE CALLED IN AFTER THE VEHICLE IS DELETED ** _pos = screenToWorld [0.5,0.5]; _heli = createVehicle [ "B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1), (_pos select 2) + 0.50], [], 0, "CANNOT_COLLIDE" ]; _heli setDir (getdir player )+ dir1; _heli setVectorUp surfaceNormal position _heli; */ Edited May 19, 2014 by BEAKSBY being more precise Share this post Link to post Share on other sites
f2k sel 164 Posted May 19, 2014 (edited) I didn't notice the collision part until later, BTW there is no such command as "CANNOT_COLLIDE". I did make another version that gets around the collision part and still only spawns once. It still uses mouseZ and has an exit, it uses a fake object that can't collide and then attache the vehicle to it. There's very little inside the oneachframe loop just the moving part. disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. dir1 = 0;// may need changing to setvariable missionnamespace setvariable ["place",false]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))}; _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+(abs (_this select 1)*2)} else {dir1=dir1-((_this select 1)*2)}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 2) then {missionnamespace setvariable ['place',true]};"];// middle mouse button down //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {onEachFrame {};}"]; //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {_this = execVM 'ArmorDrop.sqf';}"]; // init Ghost vehicle _pos = getposatl player; //screenToWorld [0.5,0.5];// land position _center = createCenter sideLogic; _group = createGroup _center; _holder = _group createUnit ["LOGIC",[(_pos select 0), (_pos select 1), 0], [],0, "NONE"]; _veh = createVehicle ["B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1),0.2], [], 0, "NONE" ]; // settexture colours _veh setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; // to avoid collisions use attachto _veh attachto [_holder]; // Move Ghost this bit may need the oneachframe commands temp_hol = _holder; temp_veh = _veh; onEachFrame { if (missionnamespace getvariable ["place",false]) exitwith {}; _pos = screenToWorld [0.5,0.5];// land position temp_hol setpos _pos; temp_hol setDir (getdir player )+ dir1; temp_hol setVectorUp surfaceNormal position temp_hol; // drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], _pos, 1, 1, 0, typeof temp_veh, 0, 0.03, "default"]; }; // end of while/oneachframe waituntil {missionnamespace getvariable ["place",false]}; deleteVehicle _veh;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. //[] execVM "ArmorDrop.sqf"; //[_holder] execVM "lightning.sqf"; deleteVehicle _holder; _pos = screenToWorld [0.5,0.5]; _veh = createVehicle ["B_MBT_01_TUSK_F",[(_pos select 0), (_pos select 1), 0],[], 0, "NONE"]; _veh setDir (getdir player )+ dir1; _veh setVectorUp surfaceNormal position _veh; Your right about re-starting I hadn't checked that but I think I know the issue. I think a variable needs re-setting and remove the displayAddEventHandler otherwise they may remain active even when the script isn't running. Sorted the respawns it just needed a another variable resetting at script start. Edited May 19, 2014 by F2k Sel Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 19, 2014 YES, this works and it's much faster too! How would I simulate pressing the "backspace" button to clear the addActions in the window before pressing down on the mouse wheel. Otherwise, when rolling the mouse wheel to re-orient the vehicle then next addAction will be activated uppon the pressing down on the mouse wheel. Don't you have to remove the enventhandlers with displayRemoveEventHandler when finished with this script? I noticed everytime you run it, the rotation degrees increase, so by the time you've run it a 10th time it no longer rotates evevery degree, more like every 15 or 30 degrees. Finally, the vehicle should not be able to push the player backwards. I suppose I could resolve this with some distancing restrictions. Thanks again! Share this post Link to post Share on other sites
f2k sel 164 Posted May 19, 2014 I think I've addressed some of the issues you brought up. Prevent multiple scripts Moved mouse button for placement to right mouse button (to avoid triggering addactions) Removed eventhandlers Prevented player collision with vehicle disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. hint ""; IF !(missionnamespace Getvariable ["place",true]) exitwith {hint "Spawn already enabled!"}; dir1 = 0;// may need changing to setvariable missionnamespace setvariable ["place",false]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))}; _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+(abs (_this select 1)*2)} else {dir1=dir1-((_this select 1)*2)}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 1) then {missionnamespace setvariable ['place',true]};"];// middle mouse button down //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {onEachFrame {};}"]; //_keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 33) then {_this = execVM 'ArmorDrop.sqf';}"]; // init Ghost vehicle _pos = getposatl player; _pos = screenToWorld [0.5,0.5];// land position _center = createCenter sideLogic; _group = createGroup _center; _holder = _group createUnit ["LOGIC",[(_pos select 0), (_pos select 1), 0], [],0, "NONE"]; _veh = createVehicle ["B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1),0.2], [], 0, "NONE" ]; // settexture colours _veh setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; // to avoid collisions use attachto _veh attachto [_holder]; // Move Ghost this bit may need the oneachframe commands temp_hol = _holder; temp_veh = _veh; player disableCollisionWith _veh; onEachFrame { if (missionnamespace getvariable ["place",false]) exitwith {}; _pos = screenToWorld [0.5,0.5];// land position temp_hol setpos _pos; temp_veh setDir (getdir player )+ dir1; temp_hol setVectorUp surfaceNormal position temp_hol; // drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], _pos, 1, 1, 0, typeof temp_veh, 0, 0.03, "default"]; }; // end of while/oneachframe waituntil {missionnamespace getvariable ["place",false]}; player disableCollisionWith _veh; deleteVehicle _veh;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. //[] execVM "ArmorDrop.sqf"; //[_holder] execVM "lightning.sqf"; deleteVehicle _holder; _pos = screenToWorld [0.5,0.5]; _veh = createVehicle ["B_MBT_01_TUSK_F",[(_pos select 0), (_pos select 1), 0],[], 0, "can_collide"]; _veh setDir (getdir player )+ dir1; _veh setVectorUp surfaceNormal position _veh; (finddisplay 46) displayremoveeventhandler ["MouseZChanged",_mouseZ]; (finddisplay 46) displayremoveeventhandler ["MouseButtonDown",_mouseM]; Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 20, 2014 (edited) Thanks, puzzle solved! I tested with removing the displayremoveeventhandler and that seemed to solve the rotation issue. Much Apprecitated! I'm also trying to add a camera angle script for when this is called so the player's camera will be raised higher above their head and a bit behind them so they can better see where they are calling in the ghost vehicle positions. If I wanted to cancel the ghost image of the vehicle and backout of the sqf I tried to use missionnamepsace with the backspace variable "cancel". But is causing problems when I delete _veh in the loop. disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. hint ""; IF !(missionnamespace Getvariable ["place",true]) exitwith {hint "You have already selected this. \n Use right mouse button to drop unit."}; if (!isnull cursortarget) exitwith {hint "Cannot Drop here"}; // cannot drop on buildings / objects position dir1 = 0;// may need changing to setvariable missionnamespace setvariable ["place",false]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))}; _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+(abs (_this select 1)*2)} else {dir1=dir1-((_this select 1)*2)}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 1) then {missionnamespace setvariable ['place',true]};"];// middle mouse button down _backspace = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {missionnamespace setvariable ['cancel',true]};"];// backspace is pressed // _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {onEachFrame {};}"]; // init Ghost vehicle _pos = getposatl player; _pos = screenToWorld [0.5,0.5];// land position _center = createCenter sideLogic; _group = createGroup _center; _holder = _group createUnit ["LOGIC",[(_pos select 0), (_pos select 1), 1], [],0, "NONE"]; _veh = createVehicle ["B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1),1], [], 0, "NONE" ]; // settexture colours _veh setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; // to avoid collisions use attachto _veh attachto [_holder]; // Move Ghost this bit may need the oneachframe commands temp_hol = _holder; temp_veh = _veh; player disableCollisionWith _veh; onEachFrame { // if (missionnamespace getvariable ["cancel",true]) then {deleteVehicle _veh}]; DOES NOT WORK....CAUSES PROBLEMS if (missionnamespace getvariable ["place",false]) exitwith {}; _pos = screenToWorld [0.5,0.5];// land position temp_hol setpos _pos; temp_veh setDir (getdir player )+ dir1; temp_hol setVectorUp surfaceNormal position temp_hol; // drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], _pos, 1, 1, 0, typeof temp_veh, 0, 0.03, "default"]; }; // end of while/oneachframe waituntil {missionnamespace getvariable ["place",false]}; player disableCollisionWith _veh; deleteVehicle _veh;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. [] execVM "ArmorDrop.sqf"; //[_holder] execVM "lightning.sqf"; deleteVehicle _holder; /* _pos = screenToWorld [0.5,0.5]; _veh = createVehicle ["B_MBT_01_TUSK_F",[(_pos select 0), (_pos select 1), 0],[], 0, "can_collide"]; _veh setDir (getdir player )+ dir1; _veh setVectorUp surfaceNormal position _veh; */ (finddisplay 46) displayremoveeventhandler ["MouseZChanged",_mouseZ]; (finddisplay 46) displayremoveeventhandler ["MouseButtonDown",_mouseM]; (finddisplay 46) displayremoveeventhandler ["KeyDown",_backspace]; Edited May 20, 2014 by BEAKSBY Share this post Link to post Share on other sites
f2k sel 164 Posted May 20, 2014 NP I think I can sort that later, it will need a few more changes other than those you attempted. Share this post Link to post Share on other sites
f2k sel 164 Posted May 20, 2014 Backspace now terminates spawn. Now using StackedEventHandler for oneachframe (otherwise it never ended) exitwith had no effect. Areas to look at, placement needs to use one of the safe place scripts. When launching the Spawn if you look out to sea the Ghost can't be seen above ground. disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. hint ""; IF !(missionnamespace Getvariable ["place",true]) exitwith {hint "You have already selected this. \n Use right mouse button to drop unit."}; if (!isnull cursortarget) exitwith {hint "Cannot Drop here"}; // cannot drop on buildings / objects position dir1 = 0;// may need changing to setvariable missionnamespace setvariable ["place",false]; missionnamespace setvariable ['cancel',false]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))}; _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+(abs (_this select 1)*2)} else {dir1=dir1-((_this select 1)*2)}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 1) then {missionnamespace setvariable ['place',true]};"];// middle mouse button down _backspace = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {missionnamespace setvariable ['cancel',true]}"]; // _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {onEachFrame {};}"]; // init Ghost vehicle _pos = getposatl player; _pos = screenToWorld [0.5,0.5];// land position _center = createCenter sideLogic; _group = createGroup _center; _holder = _group createUnit ["LOGIC",[(_pos select 0), (_pos select 1), 1], [],0, "NONE"]; _veh = createVehicle ["B_MBT_01_TUSK_F", [(_pos select 0), (_pos select 1),1], [], 0, "NONE"]; // settexture colours _veh setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; // to avoid collisions use attachto _veh attachto [_holder]; // Move Ghost this bit may need the oneachframe commands temp_hol = _holder; temp_veh = _veh; player disableCollisionWith _veh; ["move_ghost", "onEachFrame", { _pos = screenToWorld [0.5,0.5];// land position temp_hol setpos _pos; temp_veh setDir (getdir player )+ dir1; temp_hol setVectorUp surfaceNormal position temp_hol; // drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], _pos, 1, 1, 0, typeof temp_veh, 0, 0.03, "default"]; }] call BIS_fnc_addStackedEventHandler; waituntil {missionnamespace getvariable ["place",false] or missionnamespace getvariable ["cancel",false]}; ["move_ghost", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;// terminates oneachframe player disableCollisionWith _veh; deleteVehicle _veh;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. if !(missionnamespace getvariable "cancel") then { [] execVM "ArmorDrop.sqf"}; //[_holder] execVM "lightning.sqf"; deleteVehicle _holder; /* if !(missionnamespace getvariable "cancel") then { if (!isnull cursortarget) exitwith {hint "Cannot Drop here"}; // cannot drop on buildings / objects position need to use safeplace checking script // cursor target isn't enough to stop collisions on it's own. _pos = screenToWorld [0.5,0.5]; _veh = createVehicle ["B_MBT_01_TUSK_F",[(_pos select 0), (_pos select 1), 0],[], 0, "can_collide"]; _veh setDir (getdir player )+ dir1; _veh setVectorUp surfaceNormal position _veh; }; */ missionnamespace setvariable ["place",true];// reste to allow respawn (finddisplay 46) displayremoveeventhandler ["MouseZChanged",_mouseZ]; (finddisplay 46) displayremoveeventhandler ["MouseButtonDown",_mouseM]; (finddisplay 46) displayremoveeventhandler ["KeyDown",_backspace]; Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 21, 2014 Thanks once more F2K Sel! I added _veh setVehicleLock "LOCKED"; for my final contribution. There were some very strange things happening if you entered the ghost vehicle. So I locked it. It seems to run very smoothly now. I think this file is closed. Share this post Link to post Share on other sites
f2k sel 164 Posted May 21, 2014 veh setVehicleLock "LOCKED"; good idea, I still want to add a few things for my own satisfaction. I really need to fix the water issue also I'd like to add a simple menu system so I can choose the vehicle I want to spawn. Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 21, 2014 I've added a custom paa for the Slammer using photoshop and transparent background so you see a picture, description and price of the vehicle in the addAction menu. I'll post this when I back home tonight. I was going to use a dialog script from Iceman77 "http://forums.bistudio.com/showthread.php?170384-Dialogs&highlight=money+scripts" to list all the vehicles to drop called in by a "vehicle drop" addAction. And do something similar for emplacements (HMG, GMG, AT tripid, AA tripod) and radio support (Air strike, Artillery and UAV recon). The only major issue I have now is when testing on LAN I noticed the opposing player can see the vehicle being placed and rotating. Only the player calling it in should have visibility and the opponent side should only see the resulting smoke and spawn vehicle paradrop-in. Share this post Link to post Share on other sites
das attorney 858 Posted May 21, 2014 Make sure your script is ran on the requesting players machine and use createVehicleLocal. Share this post Link to post Share on other sites
f2k sel 164 Posted May 21, 2014 Maybe createvehiclelocal could be the answer. Beaten to it.. Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 21, 2014 Done and done. Init.sqf player addAction [ "<img size='2' color='#ee0000' shadow='2' image='\A3\Air_F\Heli_Light_01\Data\UI\Map_Heli_Light_01_CA.paa', 'M2A4 Slammer UP $1200' />", { _heli = createVehicle [ "B_Heli_Transport_01_F", player modelToWorld [0,50,0], [], 0, "CAN_COLLIDE" ]; _heli setDir (direction player - 90); _heli setVectorUp surfaceNormal position _heli; _heli setObjectTexture [0, "#(rgb,8,8,3)color(0.5,0,0,1)"]; _heli setObjectTexture [1, "#(rgb,8,8,3)color(0.5,0,0,1)"]; } ]; // player addAction ["<img size='2' color='#00dd00' shadow='2' image='\A3\armor_f_gamma\MBT_01\Data\ui\map_slammer_mk4_ca.paa'/> <t color='#00dd00'>M2A4 Slammer UP $1200</t>", "ObjectPositionAndDirectionD.sqf"]; player addAction ["<img size='2' shadow='5' image='SlammerUp1_CA.paa'/> <t color='#00dd00'>M2A4 Slammer UP $1200</t>", "ObjectPositionAndDirectionD.sqf"]; // hiddenSelectionsTextures[] = {"A3\armor_f_gamma\MBT_01\Data\MBT_01_body_CO.paa","A3\armor_f_gamma\MBT_01\Data\MBT_01_tow_CO.paa","a3\armor_f_epc\mbt_01\data\mbt_addons_co.paa"}; // Icon = "\A3\armor_f_gamma\MBT_01\Data\ui\map_slammer_mk4_ca.paa"; // picture = "\A3\armor_f_gamma\MBT_01\Data\UI\Slammer_M2A1_Base_ca.paa"; ObjectPositionAndDirectionD.sqf disableserialization; // to rotate vehicle use mouse scroll wheel // to terminate and spawn press middle mouse button down. hint ""; IF !(missionnamespace Getvariable ["place",true]) exitwith {hint "You have already selected this. \n Use right mouse button to drop unit. \n Use backspace to cancel."}; if (!isnull cursortarget) exitwith {hint "Cannot Drop here"}; // cannot drop on buildings / objects position dir1 = 0;// may need changing to setvariable missionnamespace setvariable ["place",false]; missionnamespace setvariable ['cancel',false]; // setup mouse/keyboard buttons waituntil {!(IsNull (findDisplay 46))}; _mouseZ = (findDisplay 46) displayAddEventHandler ["MouseZChanged","if ((_this select 1) <0) then {dir1=dir1+(abs (_this select 1)*2)} else {dir1=dir1-((_this select 1)*2)}"];// mouse scroll _mouseM = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 1) then {missionnamespace setvariable ['place',true]};"];// middle mouse button down _backspace = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {missionnamespace setvariable ['cancel',true]}"]; // _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 14) then {onEachFrame {};}"]; // init Ghost vehicle _pos = getposatl player; _pos = screenToWorld [0.5,0.5];// land position _center = createCenter sideLogic; _group = createGroup _center; _holder = _group createUnit ["LOGIC",[(_pos select 0), (_pos select 1), 0], [],0, "NONE"]; _veh = "B_MBT_01_TUSK_F" createVehicleLocal _pos; _veh setVehicleLock "LOCKED"; // settexture colours _veh setObjectTexture [0, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [1, "#(rgb,8,8,3)color(0,0.5,0,1)"]; _veh setObjectTexture [2, "#(rgb,8,8,3)color(0,0.5,0,1)"]; // to avoid collisions use attachto _veh attachto [_holder]; // Move Ghost this bit may need the oneachframe commands temp_hol = _holder; temp_veh = _veh; player disableCollisionWith _veh; ["move_ghost", "onEachFrame", { _pos = screenToWorld [0.5,0.5];// land position temp_hol setpos _pos; temp_veh setDir (getdir player )+ dir1; temp_hol setVectorUp surfaceNormal position temp_hol; // drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], _pos, 1, 1, 0, typeof temp_veh, 0, 0.03, "default"]; }] call BIS_fnc_addStackedEventHandler; waituntil {missionnamespace getvariable ["place",false] or missionnamespace getvariable ["cancel",false]}; ["move_ghost", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;// terminates oneachframe player disableCollisionWith _veh; deleteVehicle _veh;// remove Ghost sleep 0.1;// allow time for removal of Ghost // Spawn actual vehicle or call another script. if !(missionnamespace getvariable "cancel") then { [] execVM "ArmorDrop.sqf"}; //[_holder] execVM "lightning.sqf"; deleteVehicle _holder; /* if !(missionnamespace getvariable "cancel") then { if (!isnull cursortarget) exitwith {hint "Cannot Drop here"}; // cannot drop on buildings / objects position need to use safeplace checking script // cursor target isn't enough to stop collisions on it's own. _pos = screenToWorld [0.5,0.5]; _veh = createVehicle ["B_MBT_01_TUSK_F",[(_pos select 0), (_pos select 1), 0],[], 0, "can_collide"]; _veh setDir (getdir player )+ dir1; _veh setVectorUp surfaceNormal position _veh; }; */ missionnamespace setvariable ["place",true];// rest to allow respawn (finddisplay 46) displayremoveeventhandler ["MouseZChanged",_mouseZ]; (finddisplay 46) displayremoveeventhandler ["MouseButtonDown",_mouseM]; (finddisplay 46) displayremoveeventhandler ["KeyDown",_backspace]; ArmorDrop.sqf _tank = "B_MBT_01_TUSK_F" createVehicle [0,0,0]; _tank setDir random 360; _pos = screenToWorld [0.5,0.5];// land position if (!isnull cursortarget) then { _pos = getpos cursortarget};// building / object position //Drop smoke & Chemlight & Flare _smoke = "SmokeShellGreen" createVehicle [(_pos select 0), (_pos select 1), 0]; _chemlight = "Chemlight_green" createVehicle [(_pos select 0), (_pos select 1), 0]; _flare = "FlareGreen_F" createVehicle [(_pos select 0), (_pos select 1), 0]; _tank setPos [(_pos select 0), (_pos select 1), 150]; _tank call KK_fnc_paraDropTank; hint format["Incoming Armor at %1",(position _pos)]; // Delete smoke and light waitUntil {getPos _tank select 2 < 5}; deleteVehicle _smoke; deleteVehicle _chemlight; deleteVehicle _flare; SlammerUp1_CA.paa The last thing I'm trying to do with this is raise the camera view of the 3rd person so the player can have a better view of the location of the ghost vehicle placement AND have an array of vehicles to select from. ---------- Post added at 22:06 ---------- Previous post was at 21:56 ---------- http://forums.bistudio.com/showthread.php?178031-How-to-change-camera-settings-in-game-with-addAction Share this post Link to post Share on other sites
f2k sel 164 Posted May 22, 2014 Looks nice with those Icons. The last thing I'm trying to do with this is raise the camera view of the 3rd person so the player can have a better view of the location of the ghost vehicle placement AND have an array of vehicles to select from. I don't think it's really possible to control player when in camera mode. I've seen the question asked but never seen a satisfactory answer. Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 22, 2014 Me neither... ...I think this is the first scripting limitation I've found in Arma3 so far. Share this post Link to post Share on other sites