Jump to content
  • 0

New vehicle trader -> vehicle spawn direction


wokkelwakker

Question

Hello,

 

I was wondering if anyone knows how to change the direction the vehicle is facing when you buy one at a vehicle trader.

 

I checked the trade_any_vehicle.sqf, but i can't find anything that seems to set the direction.

 

It's either set on 0 by default (which makes it hard to determine which 0 within trade_any_vehicle it represents), or it isn't set at all.

 

Tried setting the _this setDir of the "helihcivil/helihempty", but that doesn't change anything.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

hellihcivil and helihempty are the helipads, changing their direction will not change the direction of the vehicle spawned on top of it.

 

I think the line you're looking for is:

PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];

_dir defines the direction in compass degrees.

Link to comment
Share on other sites

  • 0

Thanks for the quick reply xoleum.

 

How could i not have seen this!! :D

 

I think you're right about the _dir, it's set a little earlier in that file like this:

_dir = round(random 360);

So it seems the direction is set randomly.

 

I'm gonna try editing this to a static number and get back here to let interested people know if it worked.

Link to comment
Share on other sites

  • 0

No probllem, but keep in mind that if you just change _dir to a static number, this is going to apply to all vehicle traders.

 

you might want to include a trader id check.

if (_traderID == <some_id>) then {
	_dir = <custom_direction>;
} else {
	_dir = round(random 360);
}
Link to comment
Share on other sites

  • 0

I'd like to bump this post and ask if there's a way to get the vehicles to spawn in a set direction.

 

My reason is that i've moved the Aircraft Dealer to Balota and the aircraft always spawn facing the hanger, which makes it difficult to taxi large planes away. I've moved the heli invisible pad way back to the grass area, but it's still not far enough for the c130.  

 

Any ideas? :)

Link to comment
Share on other sites

  • 0

For now i've added:

 

sleep 0.2; _object setDir 270; // 270 is facing West

 

Just after: publicVariable "PVDZE_veh_Init";

 

In the server_publishVehicle2.sqf file.

 

Hopefully that won't interfere with anything however, if the player doesn't enter the vehicle then after restart it will be facing North again. Ideally though players should get their vehicles moved after buying them :)

Link to comment
Share on other sites

  • 0

From what I have found when making my custom traders, vehicles always spawn facing north.

For some reason, in server_publishVehicle2.sqf they have commented out 

_dir = _this select 4;

after they call 

spawn{

What this does is change the value of _dir to 0(since its now undefined in the scope of spawn. Since 0 is due north they will always spawn north when that sqf is called. I changed

//_dir = _this select 4;

to

_dir = _this select 4;

 

and

 

_object setVariable ["CharacterID", _characterID, true];
 
to 
 
_object setVariable ["CharacterID", _characterID, true];
_object setDir _dir;

 

That way I can not have to worry about where I place my traders and I won't have to keep unpacking and repacking the dayz_server.pbo. I was worried about it needing a random number with multiple sales of the same item and with those two changes in the publish2 I can instead use a custom trade_any_vehicle_buy and use if statements to help the mod choose a pseudo random number that works.

In my init I call another sqf to spawn my traders and in there, after I place the unit that will be the trader I add a helipad:

  _Hdir2 = round(getdir _unit_3);
  _HPos2 = [_unit_3, 40, _Hdir2] call BIS_fnc_relPos;
  _Heli2 = "HeliHCivil" createvehicle _HPos2;

Since I place my aircraft traders at the end of runways looking the way I want the plane to point the above code creates a helipad 40 meters from my trader with a _dir in the same direction as the trader.

In my custom trade_any_vehicle, after it makes it's check for a helipad I put

if(_name=="C130J_US_EP1") then
{
_dir = round(getDir _helipad);
_dir1 = round(random 23);
_modifier1 = round(random 2);
if(_modifier1==0) then
{
_dir = _dir + _dir1;
_dir = round(_dir);
}else{
if(_modifier1==1) then
{
_dir = _dir - _dir1;
_dir = round(_dir);
};
};

For any vehicle it will choose a random direction and spawn the vehicle but for the C130 it will spawn facing the same direction as the trader, (up the runway), plus or minus 23 degrees, (~1/16 of a circle). I really wasn't sure why the random number for _dir mattered since they also use time in the call to create the uid for the spawned vehicles but I wanted to find a way to help keep problems from happening as well as keeping most of the solution inside my mission. That's just because I don't like making too many changes to the server code if I don't have to.  I also noticed that anything that returns a non integer will take your money, give you a key and not spawn the vehicle so I pretty much added round() to everything. Not even sure if any past the first one was necessary but it has been working fine for me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...