Jump to content
Sign in to follow this  
BeastlyFX

How do I set the direction of a spawned vehicle?

Recommended Posts

How might I set the direction of a vehicle that is spawned? I've been trying to use the _vehicle setDir 37; but that doesn't seem to work.

_createAndApplyapplyVehProperties = 
{
   private ["_vehicle", "_colorText","_texturePath", "_type", "_pos"];
   _pos = _this select 0;
_type = _this select 1;
_colorText = _this select 2;

if (_deliveryMethod == _DELIVERY_METHOD_AIRDROP) then {
	_spawnType = "FLY";
} else {
	_spawnType = "NONE";
};

_vehicle = createVehicle [_type,_pos, [], 0, _spawnType];
//_vehicle disableTIEquipment true; // Disable Thermal on bought vehicles. Mission based ones are more powerful
_vehicle setFormDir 190;
_vehicle setVariable ["newVehicle",1,true];

_texturePath = "";

//if they chose a color set the color
if(_colorText == "Orange") then { _texturePath = '#(argb,8,8,3)color(0.82,0.2,0,1)';};
if(_colorText == "Red") then { _texturePath = '#(argb,8,8,3)color(0.79,0.03,0,1)';};
if(_colorText == "Pink") then { _texturePath = '#(argb,8,8,3)color(0.91,0.53,0.57,1)';};
if(_colorText == "Yellow") then { _texturePath = '#(argb,8,8,3)color(1,0.97,0.17,1)';};
if(_colorText == "Purple") then { _texturePath = '#(argb,8,8,3)color(0.43,0.18,0.67,1)';};
if(_colorText == "Blue") then { _texturePath = '#(argb,8,8,3)color(0,0.1,0.8,1)';};
if(_colorText == "Dark Blue") then { _texturePath = '#(argb,8,8,3)color(0.03,0.02,0.35,1)';};
if(_colorText == "Green") then { _texturePath = '#(argb,8,8,3)color(0.01,0.64,0,1)';};
if(_colorText == "Black") then { _texturePath = '#(argb,8,8,3)color(0,0,0,1)';};
if(_colorText == "White") then { _texturePath = '#(argb,8,8,3)color(1,1,1,1)';};
if(_colorText == "Teal") then { _texturePath = '#(argb,8,8,3)color(0,0.93,0.86,1)';};
_vehicle setVariable ["textureName", _texturePath];

if(_texturePath != "") then
{
	serverRelaySystem = [MESSAGE_VEHICLE_PROPERTIES_APPLY, _vehicle, _texturePath];
	publicVariable "serverRelaySystem";
};

       //if this a remote controlled type we have to do some special stuff
       if ({_type isKindOf _x} count (call uavArray) > 0) then
	{
		//collect arguments
		_playerItems = items player;
		_playerAssignedItems = assignedItems player;
		_playerSide = side player;

		//decide which uav controller we should give the player
		switch (_playerSide) do
		{
			case BLUFOR: { _uavTerminal = "B_UavTerminal" };
			case OPFOR:	 { _uavTerminal = "O_UavTerminal" };
			default	     { _uavTerminal = "I_UavTerminal" };
		};

		if !(_uavTerminal in _playerAssignedItems) then
		{
			{ player unassignItem _x } forEach ["ItemGPS", "B_UavTerminal", "O_UavTerminal", "I_UavTerminal"]; // Unassign any GPS slot item

			if (_uavTerminal in _playerItems) then
			{
				player assignItem _uavTerminal;
			}
			else
			{
				player linkItem _uavTerminal;
			};
		};

		//assign an AI to the vehicle so it can actually be used
		createVehicleCrew _vehicle;

		//create a group that matches the player's side so it doesn't kill them on spawn!
		_group = createGroup _playerSide;
		[_vehicle] joinSilent _group;

		player connectTerminalToUav _vehicle; 
};

//tell the vehicle to delete itself after dying
_vehicle addEventHandler ["Killed",{(_this select 0) spawn {sleep 180; deleteVehicle _this}}];

//enable vehicle locking
   _vehicle setVariable ["objectLocked", true, true]; //force lock
   _vehicle addAction ["Unlock / Lock","client\functions\unlocklock.sqf",[],7,true,true,"","(_target distance _this) < 7"];
   _vehicle setVariable ["buyer", getPlayerUID _player, true];
};

Share this post


Link to post
Share on other sites

I recall reading a while ago that to make the direction work sometimes you have to Setpos the vehicle back in the same spot after the setdir.

 _vehicle setpos getpos _vehicle 

Share this post


Link to post
Share on other sites

The only setDir command I see in your posted code is setFormDir. Use setDir instead of setFormDir. If you prefer you can also use switch case instead of alot of ifs. Cheers.

switch (_colortext) do {
case "Orange": {_texturePath = '#(argb,8,8,3)color(0.82,0.2,0,1)';};
case "Red": {_texturePath = '#(argb,8,8,3)color(0.79,0.03,0,1)';};
case "Pink": {_texturePath = '#(argb,8,8,3)color(0.91,0.53,0.57,1)';};
case "Yellow": {_texturePath = '#(argb,8,8,3)color(1,0.97,0.17,1)';};
case "Purple": {_texturePath = '#(argb,8,8,3)color(0.43,0.18,0.67,1)';};
case "Blue": {_texturePath = '#(argb,8,8,3)color(0,0.1,0.8,1)';};
case "Dark Blue": {_texturePath = '#(argb,8,8,3)color(0.03,0.02,0.35,1)';};
case "Green": {_texturePath = '#(argb,8,8,3)color(0.01,0.64,0,1)';};
case "Black": {_texturePath = '#(argb,8,8,3)color(0,0,0,1)';};
case "White": {_texturePath = '#(argb,8,8,3)color(1,1,1,1)';};
case "Teal": {_texturePath = '#(argb,8,8,3)color(0,0.93,0.86,1)';};
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×