Advertisement
Guest User

vehicleservice.sqf

a guest
Jul 21st, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.76 KB | None | 0 0
  1. /*
  2.     Vehicle Service script v0.00000001 by nibbles.
  3.     Shamelessly adapted from Jacmac GVS (http://www.armaholic.com/page.php?id=19735)
  4.     and whatever Ahoyworld.co.uk does in their vehicle service triggers
  5.    
  6.     Features:
  7.     -Generates triggers for LandVehicles, AirVehicles, Ships based on name of markers
  8.     -Generates Event handlers for display of the trigger locations when a player is within a vehicle
  9.  
  10.     Notes:
  11.     Trigger location display is:
  12.     Null on foot
  13.     500 meters in LandVehicles and Ships
  14.     1K in AirVehicles
  15.    
  16.     Usage:
  17.     Create markers and name them according to service_land_0 .._1, service_air_0 .._1, service_ship_0 .._1 etc.
  18.     Make the markers as ELLIPSE or RECTANGLE. Icon will not work and is stupid. Size them appropriately.
  19.     Run from init.sqf with "execVM vehicleservice.sqf"
  20.    
  21.     Issues:
  22.     Icon for Ships will be in weird locations in certain cases.
  23.     Probably much more.
  24. */
  25.  
  26. // Only do this locally in Dedicated scenarios.
  27. if (isDedicated) exitWith {};
  28.  
  29. VehicleService =
  30. {
  31.     private ["_veh","_type"];
  32.     _veh = param[0];
  33.     _type = param[1];
  34.     if (_veh isKindOf "ParachuteBase" || !alive _veh) exitWith {};
  35.     if (!(_veh isKindOf _type)) exitWith { _veh vehicleChat "We dont serve your type here!"};
  36.  
  37.     _veh vehicleChat format["Servicing %1, please wait ...", _veh];
  38.     _veh setFuel 0;
  39.  
  40.     //---------- RE-ARMING
  41.     sleep 5;
  42.     _veh vehicleChat "Re-arming ...";
  43.     //---------- REPAIRING
  44.     sleep 5;
  45.     _veh vehicleChat "Repairing ...";
  46.     //---------- REFUELING
  47.     sleep 5;
  48.     _veh vehicleChat "Refueling ...";
  49.     //---------- FINISHED
  50.     sleep 5;
  51.     _veh setDamage 0;
  52.     _veh vehicleChat "Repaired (100%).";
  53.     _veh setVehicleAmmo 1;
  54.     _veh vehicleChat "Re-armed (100%).";
  55.     _veh setFuel 1;
  56.     _veh vehicleChat "Refuelled (100%).";
  57.     sleep 2;
  58.     _veh vehicleChat "Service complete.";
  59. };
  60.  
  61.  
  62. _landprefix = "service_land_";
  63. _airprefix = "service_air_";
  64. _shipprefix = "service_ship_";
  65. _veh = 0;
  66. _air = 0;
  67. _ship = 0;
  68. {
  69.     _marker = _x;
  70.     _marPos = getMarkerPos _marker;
  71.     _marDir = markerDir _marker;
  72.     _marShape = markerShape _marker;
  73.     _marSize = [0,0];
  74.     _marIsRect = false;
  75.     if (_marShape == "RECTANGLE" or _marShape == "ELLIPSE") then { _marSize = markerSize _marker };
  76.     if (_marShape == "RECTANGLE") then { _marIsRect = true };
  77.    
  78.     // LandVehicle trigger setup
  79.     if ( _x == format["%1%2", _landprefix, _veh]) then
  80.     {
  81.         // Creates the nice icon in 3D space
  82.         call compile format ["addMissionEventHandler [""Draw3D"",
  83.         {
  84.            _pos = getMarkerPos ""%1"";
  85.            _distp = player distance _pos;
  86.            if (_distp < 500 and (vehicle player isKindOf ""LandVehicle"")) then
  87.             {
  88.                _scale = 0.0251 - (_distp / 20000);
  89.                _pos set [2, 2 + (_distp * 0.05)];
  90.                _alpha = _distp / 500;
  91.                _texture = format [""#(rgb,1,1,1)color(0.5,0.5,0.5,%2)"", _alpha];
  92.                _texture = ""\A3\ui_f\data\map\markers\nato\c_car.paa"";
  93.                if (_distp < 250) then {
  94.                    _alpha = 1.001 - (_distp / 500);
  95.                };
  96.                _color = [0.85,0.65,0.13,_alpha];
  97.                drawIcon3D [_texture, _color, _pos, 0.5, 0.5, 0, ""Ground Vehicle Service"", 1, _scale, ""TahomaB""];
  98.            };
  99.        }];", _marker, "%1"];  
  100.  
  101.         _con = format ["({player == driver _x and _x isKindOf ""LandVehicle"" and (getposATL _x param[2]) < 1 and speed _x == 0} count thislist == 1)"];
  102.         _act = format ["[(thisList param[0]),'LandVehicle'] spawn VehicleService"];
  103.         _trg = createTrigger["EmptyDetector", _marPos,false];
  104.         _trg setTriggerArea [_marSize param[0],_marSize param[1],_marDir,_marIsRect];
  105.         _trg setTriggerActivation["ANY", "PRESENT", true];
  106.         _trg setTriggerStatements[_con, _act, "player vehicleChat 'Trigger deactivated'"];
  107.         _veh = _veh + 1;   
  108.     };
  109.     // AirVehicle trigger setup
  110.     if ( _x == format["%1%2", _airprefix, _air]) then
  111.     {
  112.         // Creates the nice icon in 3D space
  113.         call compile format ["addMissionEventHandler [""Draw3D"", {
  114.            _pos = getMarkerPos ""%1"";
  115.            _distp = player distance _pos;
  116.            if (_distp < 1000 and (vehicle player isKindOf ""Air"")) then {
  117.                _scale = 0.0201 - (_distp / 50000);
  118.                _pos set [2, 2 + (_distp * 0.05)];
  119.                _alpha = _distp / 500;
  120.                _texture = format [""#(rgb,1,1,1)color(0.5,0.5,0.5,%2)"", _alpha];
  121.                _texture = ""\A3\ui_f\data\map\markers\nato\c_air.paa"";
  122.                if (_distp < 500) then {
  123.                    _alpha = 1.001 - (_distp / 1000);
  124.                };
  125.                _color = [0.25,0.50,0.10,_alpha];
  126.                drawIcon3D [_texture, _color, _pos, 0.5, 0.5, 0, ""Air Vehicle Service"", 1, _scale, ""TahomaB""];
  127.            };
  128.        }];", _marker, "%1"];
  129.  
  130.         _con = format ["({player == driver _x and _x isKindOf ""Air"" and (getposATL _x param[2]) < 1 and speed _x == 0} count thislist == 1)"];
  131.         _act = format ["[(thisList param[0]),'Air'] spawn VehicleService"];
  132.         _trg = createTrigger["EmptyDetector", _marPos,false];
  133.         _trg setTriggerArea [_marSize param[0],_marSize param[1],_marDir,_marIsRect];
  134.         _trg setTriggerActivation["ANY", "PRESENT", true];
  135.         _trg setTriggerStatements[_con, _act, "player vehicleChat 'Trigger deactivated'"];
  136.         _air = _air + 1;   
  137.     };
  138.     // ShipVehicle trigger setup
  139.     if ( _x == format["%1%2", _shipprefix, _ship]) then
  140.     {
  141.         // Creates the nice icon in 3D space
  142.         call compile format ["addMissionEventHandler [""Draw3D"",
  143.         {
  144.            _pos = getMarkerPos ""%1"";
  145.            _distp = player distance _pos;
  146.            if (_distp < 500 and (vehicle player isKindOf ""Ship"")) then
  147.             {
  148.                _scale = 0.0251 - (_distp / 20000);
  149.                _pos set [2, (getposASL player param[2]) + (_distp * 0.05)];
  150.                _alpha = _distp / 500;
  151.                _texture = format [""#(rgb,1,1,1)color(0.5,0.5,0.5,%2)"", _alpha];
  152.                _texture = ""\A3\ui_f\data\map\markers\nato\c_ship.paa"";
  153.                if (_distp < 250) then {
  154.                    _alpha = 1.001 - (_distp / 500);
  155.                };
  156.                _color = [0.85,0.65,0.13,_alpha];
  157.                drawIcon3D [_texture, _color, _pos, 0.5, 0.5, 0, ""Sea Vehicle Service"", 1, _scale, ""TahomaB""];
  158.            };
  159.        }];", _marker, "%1"];  
  160.  
  161.         _con = format ["({player == driver _x and _x isKindOf ""Ship"" and (getposASL _x param[2]) < 2 and (getposASL _x param[2]) > -2  and speed _x < 2 and speed _x > -2} count thislist == 1)"];
  162.         _act = format ["[(thisList param[0]),'Ship'] spawn VehicleService"];
  163.         _trg = createTrigger["EmptyDetector", _marPos,false];
  164.         _trg setTriggerArea [_marSize param[0],_marSize param[1],_marDir,_marIsRect];
  165.         _trg setTriggerActivation["ANY", "PRESENT", true];
  166.         _trg setTriggerStatements[_con, _act, "player vehicleChat 'Trigger deactivated'"];
  167.         _ship = _ship + 1; 
  168.     };
  169. } forEach allMapMarkers;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement