Jump to content
Sign in to follow this  
Valfunction

Getting unit out of vehicle

Recommended Posts

I have a script where you can arrest a unit and then put them into the cargo of a vehicle for transport. I'm using action ["getInCargo"] to get them in the vehicle but then when I try to get them out the unit pops out for a fraction of a second and then snaps back into the spot it previously occupied in the vehicle. It works fine in the editor and if I am the host but in MP it stuffs up and does what I just described. The script to get them out is as follows. As you can see I've tried everything to get the to stay out of the car.

{
  if (alive _x) then
  {

_x disableAI "MOVE";
detach _x;

unassignVehicle _x;
_x leaveVehicle (nearestObject [player, "Landvehicle"]);
_x action ["cancelAction", (nearestObject [player, "Landvehicle"])];
_x action ["getOut", (nearestObject [player, "Landvehicle"])];
moveOut _x;

_x switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";

_x addAction ["Escort", "CIS\escort.sqf"];
_x removeAction putdown1;
  };
} forEach (crew cursorTarget);

Share this post


Link to post
Share on other sites

I've got that in there. The guy even does the switchMove and is actually sitting in the front seat of the car in the switchMove pose.

Edited by Valfunction

Share this post


Link to post
Share on other sites

sorry i was in a rush and didn't read properly :o

you should look into the multiplayer framework or similar methods to make sure it's working in MP. i had the exact same problem when i was making the same thing (prisoner handling) and fixed it like that:

[nil, _x, "loc", rSPAWN, _x,

{

_this action ["getOut", (nearestObject [player, "Landvehicle"])];

}

] call RE;

this is just an example for one part of your code hence the _x. you can use it with normal variables too. make sure you have a functions module in the mission. this is just one method which is easy to use. there's another way with more specific control i still have to learn myself. check out this for more info: http://forums.bistudio.com/showthread.php?145773-script-only-works-for-host

Edit: i think his problem is with leaving not entering the vehicle. seems more like an MP issue overall

Share this post


Link to post
Share on other sites

are u sure its not the switchmove causing the issue, being that switchmove is local and has to be broadcast to every player.. if your captured guy gets out even for half a second it sounds like the getout stuff is working, but then once thats done he snapps back to the switchmove..

Share this post


Link to post
Share on other sites
are u sure its not the switchmove causing the issue, being that switchmove is local and has to be broadcast to every player.. if your captured guy gets out even for half a second it sounds like the getout stuff is working, but then once thats done he snapps back to the switchmove..

It's definitely not the switchMove. I tried leaving it out and it still did it. I tried to assignAsCargo on the "Getin.sqf" (which places the unit in the vehicle) and then orderGetIn false in this script but that didn't do it.

I've managed to create a workaround for this. The "Putdown" event (which is also used elsewhere) runs a disableAI "MOVE" and forces the unit to just sit there. However as soon as the unit is released (AI enabled and not forced sit) they run straight back for the vehicle. The script now looks like this:

["Getout", {
{
  if (alive _x) then
  {	
_x disableAI "MOVE";
[_x] orderGetIn flase;
unassignVehicle _x;
_x leaveVehicle (nearestObject [_x, "Landvehicle"]);
moveOut _x;

["Putdown", [_x]] call CBA_fnc_globalEvent;
  };
} forEach (crew cursorTarget);

//(nearestObject [player, "Landvehicle"]) removeAction getout1;
}] call CBA_fnc_addEventHandler;

The Getin script looks like this just for reference:

//GETIN SCRIPT
["Getin", {
_unit = _this select 0;
_vehicle = _this select 1;	

_unit switchMove "";

_unit removeAction release1;
_unit removeAction getin1;
_unit removeAction escort1;

_unit disableAI "MOVE";

_unit assignAsCargo _vehicle;
[_unit] orderGetIn true;                   //this seems to do a whole lot of nothing the guy just stands there
_unit moveInCargo _vehicle;

_getoutact = _vehicle getVariable ["Getout_id", false];
if _getoutact exitWith {};

getout1 = _vehicle addAction ["Disembark", "CIS\getout.sqf"];
_vehicle setVariable ["Getout_id", true];
}] call CBA_fnc_addEventHandler;

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  

×