Advertisement
mrkarp

spawnVehicle

Oct 29th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. /*
  2.     File: fn_spawnVehicle.sqf
  3.     Author: Bryan "Tonic" Boardwine
  4.    
  5.     Description:
  6.     Spawns the selected vehicle, if a vehicle is already on the spawn point
  7.     then it deletes the vehicle from the spawn point.
  8. */
  9. disableSerialization;
  10. private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
  11. if(lnbCurSelRow 38101 == -1) exitWith {hint "You did not select a vehicle to spawn!"};
  12.  
  13. _className = lnbData[38101,[(lnbCurSelRow 38101),0]];
  14. _displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
  15. _position = getMarkerPos VVS_SP;
  16. _direction = markerDir VVS_SP;
  17.  
  18. //Make sure the marker exists in a way.
  19. if(isNil "_position") exitWith {hint "The spawn point marker doesn't exist?";};
  20.  
  21. //Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
  22. _spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
  23. if(!isNil "_spCheck") then {deleteVehicle _spCheck;};
  24.  
  25. _cfgInfo = [_className] call VVS_fnc_cfgInfo;
  26.  
  27. _vehicle = _className createVehicle _position;
  28. //_vehicle = [_className]execVM "scripts\vehicle\monitor.sqf";
  29. [[[this],"scripts\vehicle\monitor.sqf"],"BIS_fnc_execVM",false,true] call BIS_fnc_MP; //Need to put this script in the spawned vehicles init
  30. diag_log format ["%1, Spawned with Script", _className];
  31. _vehicle allowDamage false;
  32. _vehicle setPos _position; //Make sure it gets set onto the position.
  33. _vehicle setDir _direction; //Set the vehicles direction the same as the marker.
  34.  
  35.  
  36. if((_cfgInfo select 4) == "Autonomous") then
  37. {
  38.     createVehicleCrew _vehicle;
  39. };
  40.  
  41. if(VVS_Checkbox) then
  42. {
  43.     clearWeaponCargoGlobal _vehicle;
  44.     clearMagazineCargoGlobal _vehicle;
  45.     clearItemCargoGlobal _vehicle;
  46. };
  47.  
  48. _vehicle allowDamage true;
  49. hint format["You have spawned a %1",_displayName];
  50. closeDialog 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement