Jump to content
Sign in to follow this  
Antorugby

Addaction and Vehicles and maybe Multiplayer

Recommended Posts

Hey guys, I'm sorry that I'm asking such a basic thing, but I worked a lot of hours and I think I fried my brain a bit.

Anyway I'm trying to write a script that will show up an action when the players enter a vehicle and of course the action should be removed when they left.

The action is going to be used in multiplayer, but it's just a moveincargo, only the squad leader will have a moveincargo and a detach action, so it can run client side?

Anyway, can someone help me? I have to rest my head a bit, thank you so much!

Share this post


Link to post
Share on other sites

try this

player addAction ["Get In","goincargo.sqf",[], -5,false, true,"", "(_this == leader group _this) && (vehicle _this == cargo1)"];

Share this post


Link to post
Share on other sites

With following a action named "Some action" should be added to player if he is leader of his group and enter a vehicle running the vehAction.sqf script below. The action should be removed upon vehicle exit.

vehAction.sqf

private ["_noAction","_actionID"];

_veh = _this select 0;

_noAction = true;

while {true} do
{
 if ((vehicle player == _veh) && (player == leader group player) && (_noAction)) then
 {
   _actionID = player addAction ["Some action", "somescript.sqf", [], -1, false, true, ''];
   _noAction = false;
 };
 if ((vehicle player != _veh) && (!_noAction)) then
 {
   player removeAction _actionID;
   _noAction = true;
 };
 sleep 0.5;
};

Add below line to init fields of vehicles you want the action to appear when player leaders enter

null = [this] execVM "vehAction.sqf"

Share this post


Link to post
Share on other sites

can always use eventhandlers

vehicle init

_vehicle addEventHandler ["GetIn", "if (player == (_this select 2)) then {[_this select 2, _this select 0] spawn whatEverYouWant;}"]; 

and then getout addeventhandler

whatEverYouWant function -

whatEverYouWant {
_playerDriver = _this select 0; //passed player
_VehEntered = _this select 1; // passed vehicle player got in
_driver= assignedDriver _VehEject; // returns the assigned driver of vehicle
_playerDriver addAction ["do stuff","dostuff.sqf"]; //or put your code in the addaction
};

Share this post


Link to post
Share on other sites
player addAction ["Get In","goincargo.sqf",[], -5,false, true,"", "(_this == leader group _this) && (vehicle _this [color="#FF0000"]!= _this[/color])"];

Share this post


Link to post
Share on other sites

The one from Kevs work really fine, thank you guys!

Inviato dal mio GT-I9300 con Tapatalk

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  

×