Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. /*
  2. File: fn_spawnVehicle.sqf
  3. Author: Bryan "Tonic" Boardwine
  4.  
  5. Description:
  6. Sends the query request to the database, if an array is returned then it creates
  7. the vehicle if it's not in use or dead.
  8. */
  9. private["_vid","_sp","_pid","_query","_sql","_vehicle","_nearVehicles","_name","_side","_tickTime","_dir"];
  10. _vid = [_this,0,-1,[0]] call BIS_fnc_param;
  11. _pid = [_this,1,"",[""]] call BIS_fnc_param;
  12. _sp = [_this,2,[],[[],""]] call BIS_fnc_param;
  13. _unit = [_this,3,ObjNull,[ObjNull]] call BIS_fnc_param;
  14. _price = [_this,4,0,[0]] call BIS_fnc_param;
  15. _dir = [_this,5,0,[0]] call BIS_fnc_param;
  16. _unit_return = _unit;
  17. _name = name _unit;
  18. _side = side _unit;
  19. _unit = owner _unit;
  20.  
  21. if(_vid == -1 OR _pid == "") exitWith {};
  22. if(_vid in serv_sv_use) exitWith {};
  23. serv_sv_use pushBack _vid;
  24.  
  25. _query = format["SpawnVehicle:%1:%2",_vid,_pid];
  26.  
  27. waitUntil{sleep (random 0.3); !DB_Async_Active};
  28. _tickTime = diag_tickTime;
  29. _queryResult = [_query,2] call DB_fnc_asyncCall;
  30.  
  31. diag_log "------------- Client Query Request -------------";
  32. diag_log format["QUERY: %1",_query];
  33. diag_log format["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
  34. diag_log format["Result: %1",_queryResult];
  35. diag_log "------------------------------------------------";
  36.  
  37. if(typeName _queryResult == "STRING") exitWith {};
  38.  
  39. _vInfo = _queryResult;
  40. if(isNil "_vInfo") exitWith {serv_sv_use = serv_sv_use - [_vid];};
  41. if(count _vInfo == 0) exitWith {serv_sv_use = serv_sv_use - [_vid];};
  42.  
  43. if((_vInfo select 5) == 0) exitWith
  44. {
  45. serv_sv_use = serv_sv_use - [_vid];
  46. [[1,format[(localize "STR_Garage_SQLError_Destroyed"),_vInfo select 2]],"life_fnc_broadcast",_unit,false] call life_fnc_MP;
  47. };
  48.  
  49. if((_vInfo select 6) == 1) exitWith
  50. {
  51. serv_sv_use = serv_sv_use - [_vid];
  52. [[1,format[(localize "STR_Garage_SQLError_Active"),_vInfo select 2]],"life_fnc_broadcast",_unit,false] call life_fnc_MP;
  53. };
  54. if(typeName _sp != "STRING") then {
  55. _nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10];
  56. } else {
  57. _nearVehicles = [];
  58. };
  59. if(count _nearVehicles > 0) exitWith
  60. {
  61. serv_sv_use = serv_sv_use - [_vid];
  62. [[_price,_unit_return],"life_fnc_garageRefund",_unit,false] call life_fnc_MP;
  63. [[1,(localize "STR_Garage_SpawnPointError")],"life_fnc_broadcast",_unit,false] call life_fnc_MP;
  64. };
  65.  
  66. _query = format["SpawnVehicle+1:%1:%2",_pid,_vid];
  67.  
  68. waitUntil {!DB_Async_Active};
  69. [_query,1] spawn DB_fnc_asyncCall;
  70. if(typeName _sp == "STRING") then {
  71. _vehicle = createVehicle[(_vInfo select 2),[0,0,999],[],0,"NONE"];
  72. waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
  73. _vehicle allowDamage false;
  74. _hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0;
  75. _vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]);
  76. sleep 0.6;
  77. } else {
  78. _vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"];
  79. waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
  80. _vehicle allowDamage false;
  81. _vehicle setPos _sp;
  82. _vehicle setVectorUp (surfaceNormal _sp);
  83. _vehicle setDir _dir;
  84. };
  85. _vehicle allowDamage true;
  86. //Send keys over the network.
  87. [[_vehicle],"life_fnc_addVehicle2Chain",_unit,false] call life_fnc_MP;
  88. [_pid,_side,_vehicle,1] call TON_fnc_keyManagement;
  89. _vehicle lock 2;
  90. //Reskin the vehicle
  91. [[_vehicle,_vInfo select 8],"life_fnc_colorVehicle",nil,false] call life_fnc_MP;
  92. _vehicle setVariable["vehicle_info_owners",[[_pid,_name]],true];
  93. _vehicle setVariable["dbInfo",[(_vInfo select 4),_vInfo select 7]];
  94. [_vehicle] call life_fnc_clearVehicleAmmo;
  95.  
  96. //D41 Liste für Sitzplatzabfrage
  97. _civHeli = ["B_Heli_Light_01_F","civ_md500_blueline","civ_md500_shadow","civ_md500_whitered","civ_md500_greywatcher","civ_md500_speedy","civ_md500_sunset","civ_md500_wasp","civ_md500_wave"];
  98.  
  99. //Sets of animations
  100. if((_vInfo select 1) == "civ" && (_vInfo select 2) == "civ_md500_urban") then
  101. {
  102. [[_vehicle,"civ_md500_urban",true],"life_fnc_vehicleAnimate",_unit,false] call life_fnc_MP;
  103. };
  104.  
  105. if((_vInfo select 1) == "civ" && ((_vInfo select 2) in _civHeli)) then //ALTE ABFRAGE if((_vInfo select 1) == "civ" && ((_vInfo select 2) in _civHeli) && _vInfo select 8 != 13) then
  106. {
  107. [[_vehicle,"civ_littlebird",true],"life_fnc_vehicleAnimate",_unit,false] call life_fnc_MP;
  108. };
  109.  
  110. /*if((_vInfo select 1) == "cop" && (_vInfo select 2) in ["C_SUV_01_F","C_Offroad_01_F","D41_MRAP_01_F","Offroad_Pol","BMW_X6M_Pol","Offroad_SWAT","D41_swat_hunter"]) then
  111. {
  112. [[_vehicle,"cop_offroad",true],"life_fnc_vehicleAnimate",_unit,false] call life_fnc_MP;
  113. };
  114.  
  115. if((_vInfo select 1) == "med" && (_vInfo select 2) in ["D41_Offroad_Medic","C_Offroad_01_F"]) then
  116. {
  117. [[_vehicle,"med_offroad",true],"life_fnc_vehicleAnimate",_unit,false] call life_fnc_MP;
  118. };*/
  119. [[1,"Your vehicle is ready!"],"life_fnc_broadcast",_unit,false] call life_fnc_MP;
  120. serv_sv_use = serv_sv_use - [_vid];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement