OksmanTV

Untitled

Jul 15th, 2022 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.42 KB | None | 0 0
  1.  
  2. /*
  3.     Vehicle Requisition Script - Created by Oksman @ Guerrillas of Liberation for Reddit User: u/kiingkiller
  4.  
  5.     Params:
  6.     1: ObjNull - Action Object - Flag or Computer for example - Object will spawn 15 meters behind this object.
  7.     2: String - Classname of Vehicle
  8.     3: Integer - Cooldown Timer in Seconds
  9.     4: Integer - Amount of Available Vehicle of Type
  10.  
  11.     Example: [this,"B_MRAP_01_F",15,20] execVM "VehicleRequisition.sqf";
  12. */
  13.  
  14. Params ["_ActionObject","_VehicleClassname","_CooldownDelay","_AvailableVehicleCount"];
  15.  
  16. _Variable = format["OKS_VehicleRequisition_%1",_VehicleClassname];
  17. _VehicleName = getText (configFile >> "CfgVehicles" >> _VehicleClassname >> "displayName");
  18. _ActionObject setVariable [_Variable,_AvailableVehicleCount,true];
  19.  
  20. _ActionObject addAction [
  21.     format["<t color='#1cbf13'>Requisition %1</t>",_VehicleName], /// Action Name
  22.     {
  23.         //// Code
  24.         Params ["_ActionObject","_caller","_actionId","_arguments"];
  25.         _arguments Params ["_VehicleClassName","_Variable","_Delay"];
  26.  
  27.         if(_ActionObject getVariable [_Variable,0] > 0 && !(_ActionObject getVariable [format['%1_Deactivated',_VehicleClassname],false])) then {
  28.             _ActionObject setVariable [format["%1_Deactivated",_VehicleClassname],true,true];
  29.             _ActionObject setVariable [_Variable,((_ActionObject getVariable [_Variable,0]) - 1),true];
  30.             _Dir = (getDir _ActionObject - 180);
  31.             _Vehicle = createVehicle [_VehicleClassName, (getPos _ActionObject) getPos [15,_Dir], [], 0, "NONE"];
  32.             _Vehicle setDir (_Vehicle getDir _ActionObject);
  33.  
  34.             _VehicleName = getText (configFile >> "CfgVehicles" >> _VehicleClassname >> "displayName");
  35.             SystemChat format["%1 Requisitioned - Remaining: %2 - Cooldown: %3 seconds",_VehicleName,_ActionObject getVariable [_Variable,0],_Delay];
  36.             sleep _Delay;
  37.             _ActionObject setVariable [format["%1_Deactivated",_VehicleClassname],false,true];
  38.         } else {
  39.             _Message = "";
  40.             if(_ActionObject getVariable [_Variable,0] < 1) then {
  41.                 _Message = "All vehicles spent."
  42.             } else {
  43.                 _Message = "Cooldown still in effect."
  44.             };
  45.             systemChat format["Vehicle is currently unavailable. %1",_Message];
  46.         }
  47.     },
  48. [_VehicleClassname,_Variable,_CooldownDelay],  /// Arguments
  49. 1,
  50. false,
  51. true,
  52. "",
  53. format["_target getVariable ['%1',0] > 0 && !(_target getVariable ['%1_Deactivated',false])",_Variable]
  54. // ^- If you want the action to always show, comment the line above. Message will be shown instead if it is unavailable.
  55. ];
Add Comment
Please, Sign In to add comment