Jump to content
Sign in to follow this  
iceman77

Vehicle Flip Script To Share

Recommended Posts

An action to put flipped vehicles back upright. Enjoy!!

Example Mission:

new_logo_shmodel-vfl9sSGTp.png

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 by Iceman77

Share this post


Link to post
Share on other sites

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

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 by Iceman77

Share this post


Link to post
Share on other sites

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

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

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

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
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 by Larrow
add distance check :D

Share this post


Link to post
Share on other sites

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

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

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
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 by Iceman77

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×