Advertisement
Virus_

icapacitated chopper problem

Jul 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.15 KB | None | 0 0
  1. //incapacitated falling out of chopper again, when others enter it
  2. //Problem is, that in life state incapacitated the unit is kicked out as soon as somebody else tries to enter.
  3. //Idea 1: Fill space from highest to lowest. So they still get kicked, but only if the space is needed.
  4. //Idea 2: Lock the cargospot they are in. But unlocking is a pain... Thx Bohemia!
  5. //Testing Code:
  6. 0 spawn {{if!(_x == player) then {
  7. _x setUnconscious true;
  8. _x assignAsCargo H;
  9. _x moveInCargo H;};} foreach units group player;};
  10.  
  11. A addEventhandler ["GetOutMan", {params ["_vehicle", "_role", "_unit", "_turret"]; systemChat format ["%1", H getCargoIndex A];}];
  12.  
  13. H addEventHandler ["GetOut", {
  14.     params ["_vehicle", "_role", "_unit", "_turret"];
  15.     _emptyLockedSeats = ((fullCrew [vehicle player, "cargo", true]) - (fullCrew [vehicle player, "cargo", false])) select {_vehicle lockedCargo (_x select 2))};
  16.     {
  17.         _x params ["_unit", "", "_index"];
  18.         _vehicle lockCargo [_index, false];
  19.     } foreach _emptySeats;
  20. }];
  21.  
  22.  
  23.  
  24. //A addEventHandler ["GetOutMan", {
  25. //  params ["", "", "_vehicle", ""];
  26. H addEventHandler ["GetOut", {
  27.     params ["_vehicle", "", "", ""];
  28.     systemChat format["Get out calles: %1", _this];
  29.     _emptySeatIndices = [];
  30.     {_x params ["_unit", "", "_index"]; if(isNull _unit) then {_emptySeatIndices pushBack _index;}} foreach (fullCrew [_vehicle, "cargo", true]);
  31.         systemChat format["%1 << indices", _emptySeatIndices];
  32.     _locksToRemove = _emptySeatIndices select {_x in (_vehicle getVariable ["MD_lockedForMedicalTransport",[]])};
  33.     {
  34.         _vehicle lockCargo [_x, false];
  35.         systemChat format["%1 is free again", _x];
  36.     } foreach _locksToRemove;
  37.     _vehicle setVariable ["MD_lockedForMedicalTransport", ((_vehicle getVariable ["MD_lockedForMedicalTransport",[]]) - _locksToRemove), true];
  38. }];
  39.  
  40. H addEventHandler ["GetIn", {
  41.     params ["_vehicle", "_role", "_unit", "_turret"];
  42.     _index = (_vehicle getCargoIndex _unit);
  43.     if (_index > -1) then {
  44.         _vehicle lockCargo [_index, true];
  45.         _lockedSeats = _vehicle getVariable ["MD_lockedForMedicalTransport",[]];
  46.         _lockedSeats pushBackUnique _index;
  47.         _vehicle setVariable ["MD_lockedForMedicalTransport", _lockedSeats, true];
  48.     }
  49. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement