unlock.sqf 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ////////////////////////////////////////
  2. // Simple Vehicle Locking System //
  3. // scripts\unlock.sqf //
  4. // Sgt Justin [GCF] //
  5. ////////////////////////////////////////
  6. private ["_vehicle","_lockState","_nearvehicle"];
  7. _nearvehicle = nearestObjects [player, ["Armored", "Car", "Support", "Submarine", "LandVehicle", "Ship", "Air"], 5];
  8. _vehicle = _nearvehicle select 0;
  9. _lockState = locked _vehicle;
  10. if(_lockState == 1) then
  11. {
  12. //Lock the vehicle
  13. //_vehicle lock true;
  14. [_vehicle,true] remoteExec ["lock", _vehicle];
  15. //Lock the vehicles inventory
  16. //_vehicle lockCargo true;
  17. [_vehicle,true] remoteExec ["lockCargo", _vehicle];
  18. //Set a variable that describes that the vehicle is locked
  19. _vehicle setVariable ["objectLocked", true, true];
  20. //Turn off the vehicles engine
  21. _vehicle engineOn false;
  22. //Turn on the vehicles headlights
  23. Player action ["lightOn", _vehicle];
  24. //Wait 1/2 a second
  25. sleep 0.5;
  26. //Turn off the vehicles headlights
  27. player action ["lightOff", _vehicle];
  28. //Display a notification at the bottom of the screen
  29. titleText ["Vehicle Locked!","PLAIN DOWN"]; titleFadeOut 2;
  30. }
  31. else
  32. {
  33. //Unlock the vehicle
  34. //_vehicle lock false;
  35. [_vehicle,false] remoteExec ["lock", _vehicle];
  36. //Unlock the vehicles inventory
  37. //_vehicle lockCargo false;
  38. [_vehicle,false] remoteExec ["lockCargo", _vehicle];
  39. //Set a variable that describes that the vehicle is unlocked
  40. _vehicle setVariable ["objectLocked", false, true];
  41. //Turn off the vehicles engine
  42. _vehicle engineOn false;
  43. //Turn on the vehicles headlights
  44. Player action ["lightOn", _vehicle];
  45. //Wait 1/2 a second
  46. sleep 0.5;
  47. //Turn off the vehicles headlights
  48. player action ["lightOff", _vehicle];
  49. //Display a notification at the bottom of the screen
  50. titleText ["Vehicle unlocked!","PLAIN DOWN"]; titleFadeOut 2;
  51. };