Skip to content

Instantly share code, notes, and snippets.

@Cuel
Last active January 8, 2016 03:04
Show Gist options
  • Save Cuel/7f4cbabb1272741df01e to your computer and use it in GitHub Desktop.
Save Cuel/7f4cbabb1272741df01e to your computer and use it in GitHub Desktop.
Switch vehicle crew
/*
class Extended_InitPost_EventHandlers {
class LandVehicle {
class CUL_switchL { init = "_this call CUL_switchCrew;"; };
};
class Air {
class CUL_switchA { init = "_this call CUL_switchCrew;"; };
};
};
*/
CUL_switchCrew = {
params ["_veh"];
if (!local _veh || {!(side _veh in [opfor, independent])}) exitWith {};
private _crew = crew _veh;
private _amount = count _crew;
private _slots = [];
{_slots pushBack (assignedVehicleRole _x)} forEach _crew;
{deleteVehicle _x} forEach _crew;
private _grp = createGroup independent;
for "_i" from 1 to _amount do {
_grp createUnit ["FP_Faction_FEC_Rifleman", [0,0,0], [], 0, "FORM"];
};
_grp addVehicle _veh;
{
_x params ["_slot", "_path"];
private _unit = (units _grp) select _forEachIndex;
switch (toLower _slot) do {
case "driver": {_unit moveInDriver _veh};
case "turret": {_unit moveInTurret [_veh, _path]};
case "cargo": {_unit moveInCargo _veh;}
};
} forEach _slots;
(units _grp) remoteExecCall ["FP_fnc_addToCurators", 2];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment