iceman77 18 Posted October 25, 2013 (edited) An action to put flipped vehicles back upright. Enjoy!! Example Mission: init.sqf if (!isDedicated) then { waitUntil {!isNull player && {time > 0}}; player addAction [ "Flip Vehicle", "FlipAction.sqf", [], 0, false, true, "", "_this == (vehicle _target) && {(count nearestObjects [_target, ['landVehicle'], 5]) > 0 && {(vectorUp cursorTarget) select 2 < 0}}" ]; Player AddEventHandler ["Respawn", { (_this select 0) addAction [ "Flip Vehicle", "FlipAction.sqf", [], 0, false, true, "", "_this == (vehicle _target) && {(count nearestObjects [_target, ['landVehicle'], 5]) > 0 && {(vectorUp cursorTarget) select 2 < 0}}" ]; }]; }; flipAction.sqf private ["_caller","_veh"]; _caller = _this select 1; _veh = nearestObjects [_caller, ["landVehicle"], 5] select 0; _veh setVectorUp [0,0,1]; _veh setPosATL [(getPosATL _veh) select 0, (getPosATL _veh) select 1, 0]; Edited October 4, 2014 by Iceman77 Share this post Link to post Share on other sites
-LTac- Imperator 10 Posted October 25, 2013 Simple solution, to an interesting problem. I was wondering though why not provide a simple check based upon a timer for each vehicle so every 3-5 seconds check the vectorUp of the vehicle, if it is equivalent to the vehicle being upside down then add the action to the vehicle rather than to a player. That way a player cant constantly spam a script unless its actually needed. Not that its going to do much damage to the server or the client. Or you could also check periodically if there's an empty upside down vehicle within a certain distance of the player, then add the action to the player. While it does add overhead to the processing cycle - It might be a way to go.. I would check performance of the two methods if I had the time - but just offering a few thoughts :) Share this post Link to post Share on other sites
iceman77 18 Posted October 25, 2013 (edited) Yeah. Well this is how I did it... The simplest way I knew how. Also, spamming vehicles with the action will do nothing unless it's upside down and is empty. Aside from an upright vehicle doing a little twitch. Which isn't noticeable at all unless the player is close enough and is paying close attention. Also loops are nasty, I'd hate to use one to monitor vehicles just to see if their right side up or not. What i could do is put a check in there to see if the vehicle isn't upright. That would be neat. Edited October 25, 2013 by Iceman77 Share this post Link to post Share on other sites
-LTac- Imperator 10 Posted October 25, 2013 Sorry I didn't mean to insult you - I was actually very impressed with your script - was just offering some advice as to potentially improve it was all. Thank you for your sharing the script :) The methods I put forward would need to be tested as to the impact to the player, because adding any type of a loop that checks for things can be challenging.. you have to make sure you dont have 5 billion of them running or it can noticably slow down either the server or clients performance. Thats why I used the word simple, not to mean that it was "Simple"... Share this post Link to post Share on other sites
iceman77 18 Posted October 25, 2013 By all means re-write / tweak it and share it :). I'm certainly open for suggestions! Share this post Link to post Share on other sites
johnnyboy 3793 Posted October 25, 2013 Thanks Iceman, this is very useful. Another one I would like to see is a "push boat" script. It sucks to beach a zodiac, and have no way to get it back in the water. The direction of the player would be direction to push the boat, via setVelocity probably. Hmmmm.... Share this post Link to post Share on other sites
Kunsa 10 Posted October 25, 2013 this happened to me just today and I was thinking if only I could just walk up to it and push it lol. glad I found this, I will use it. However in my mind I was thinking that I would like to have 3 or more ppl and it would roll over. Share this post Link to post Share on other sites
Larrow 2820 Posted October 25, 2013 (edited) Another one I would like to see is a "push boat" script. player addAction ["Push",{ cursorTarget setVelocity [(sin (getDir player)*10),(cos (getDir player)*10),0]; }, [], -10, false, true, "", "(cursorTarget iskindof 'ship') && cursorTarget distance player < 8" ] Edited October 25, 2013 by Larrow add distance check :D Share this post Link to post Share on other sites
iceman77 18 Posted October 26, 2013 This happened to me just today and I was thinking if only I could just walk up to it and push it lol. glad I found this, I will use it. However in my mind I was thinking that I would like to have 3 or more ppl and it would roll over. That would be interesting. Share this post Link to post Share on other sites
coolfact 10 Posted September 29, 2014 Okay what am I doing wrong? trying to add another condition, but doesn't work :S player addAction ["Flip Vehicle", "missionscripts\vehflip\FlipAction.sqf", [], 0, false, true, "", "_this == vehicle _target && {(vectorUp _target) select 2 < 0}"]; Share this post Link to post Share on other sites
iceman77 18 Posted September 29, 2014 Because _target in this case is the player. _target (unit to which action is attached to) and _this (caller/executing unit) Share this post Link to post Share on other sites
iceman77 18 Posted October 4, 2014 (edited) Okay what am I doing wrong? trying to add another condition, but doesn't work :S player addAction ["Flip Vehicle", "missionscripts\vehflip\FlipAction.sqf", [], 0, false, true, "", "_this == vehicle _target && {(vectorUp _target) select 2 < 0}"]; I've re-written the script: - It's smaller - It now relies on vectorUp condition and nearby vehicle count condition before the action is available Edited October 4, 2014 by Iceman77 Share this post Link to post Share on other sites
dlegion 98 Posted March 22, 2017 yeah! i was searching for this! forgive me, but i cant understand how use it (where place code) to push and flip the boats (any vehicle if possible!) ! thanks Share this post Link to post Share on other sites