Jump to content

[Fix] Traders spawning vehicles on top of each other


Sandbird

Recommended Posts

I am surprised noone else is bothered by this. It really bothered me that vehicles would spawn on top of each other when you buy a vehicle and another one is there.

 

What does the fix do ?
It will check if there is a safe location in a 60m radius to spawn the vehicle. If there is one, it will select it...otherwise worst case scenario, it reverts to the old location..

 

The fix is very easy. All you have to do is open \dayz_server\compile\server_publishVehicle2.sqf

 

Find 

_uid = _worldspace call dayz_objectUID3;

ABOVE it put :

//Safe spawning of veh, not on top of eachother
_position = _location findEmptyPosition [0,60,_class];  //60m radius
if (count _position != 0) then {
    _safelocation = _position;
}else{
    //default spawner
    diag_log format["###### TRADER BUY VEH: NO SPACE, spawning dead center ######"];
    _safelocation = _location;
};
_worldspace = format["[%1,%2]", _dir,_safelocation];
_worldspace = call compile _worldspace;

Find bellow:

[_object,_uid,_characterID,_class,_dir,_location,_donotusekey,_activatingPlayer] spawn {

In this array change _location to _safelocation. So it should look like:

[_object,_uid,_characterID,_class,_dir, _safelocation,_donotusekey,_activatingPlayer] spawn {

Dont forget to add

"_position","_safelocation"

at the top in the private array.

 

 

What we did here:

  1. Insert the vehicle in the database with the new location
  2. Use the new location to spawn a vehicle
  3. If there is no available position withing 60m, then it will revert back to the old (on top of vehicles) position
Link to comment
Share on other sites

I am surprised noone else is bothered by this. It really bothered me that vehicles would spawn on top of each other when you buy a vehicle and another one is there.

 

What does the fix do ?

It will check if there is a safe location in a 60m radius to spawn the vehicle. If there is one, it will select it...otherwise worst case scenario, it reverts to the old location..

 

The fix is very easy. All you have to do is open \dayz_server\compile\server_publishVehicle2.sqf

 

Find 

_uid = _worldspace call dayz_objectUID3;

Under it put :

//Safe spawning of veh, not on top of eachother
_position = _location findEmptyPosition [0,60,_class];  //60m radius...check if this vehicle can fit anywhere inside this area
if (count _position != 0) then {
    _safelocation = _position;
}else{
    //default spawner
    diag_log format["###### TRADER BUY VEH: NO SPACE, spawning dead center ######"];
    _safelocation = _location;
};
_worldspace = format["[%1,%2]", _dir,_safelocation];  // Add the direction as well in the db cell

Dont forget to add

"_position","_safelocation"

at the top in the private array.

Very nice dude, that will come in handy :)

I lowered the distance as i can imagine some players are going ot complain their vehilcle didnt spawn :P

Many thanks

Link to comment
Share on other sites

Yeah, it really depends on the map and how small is the trade area.

I guess you could also send that value from the trade_any_vehicle.sqf file...so it depends on the trader.

If its a big trader city,set it up to 40 or something, and if its a small one, to something less.

This 'safe area' starts dead center in the helipad and expands to 60 right now...so plenty of space around it.

I set it up high cause maybe you'll spawn 2-3 Chinooks...and they need space :P

Link to comment
Share on other sites

Maybe it makes sence if a new position (a bit further away) is needed, that the player gets an appropriate message.

 

I thought about that as well, but I didnt want to get into server->client message stuff cause i dont know what type of overwrites each person does.

For example i am overwriting my trade_any_vehicle.sqf type of files, so i can do it...but maybe people use the default ones...or they dont know how to do it.

This way its up to 'you' to do as you please.

 

For example for my case i'll be changing the red arrow to something else...so it can be seen from where the player is...even if the 'supposed arrow' is behind a fence, but that's too technical for some people.

Link to comment
Share on other sites

Woot, indeed easy fix and really nice.

 

Btw, I have an epoch origins server and one of the two boat dealer is bugged: when buying from him the boats just fell in the water and then are moved a bit far away ( in the water or even on the ground).

 

Any chance you know where is the handling code of that located? Or if anyone came accross this issue how did he solve it.

 

Thx

Link to comment
Share on other sites

It's good but, people should just move the vehicles xD (:

 

Yeah but sometimes they dont...usually people tow the newly spawned vehicle to their base, forget to get in to update its location and then on restart...bam...the vehicle is in the helipad...blocking everything else.

Btw i have to fix this as well....so you dont have to get in vehicle to update the location...also surprised this bug has been going on for ages now :P

Link to comment
Share on other sites

Do you see ###### TRADER BUY VEH: NO SPACE, spawning dead center ###### in the log file ?

Is _class defined a bit further up ?

Is _worldspace value given to the SQL query bellow ?

Are there any errors in the server's log file ?

 

Try this for position, without the class.

_position = _location findEmptyPosition [0,60];
Link to comment
Share on other sites

 

Do you see ###### TRADER BUY VEH: NO SPACE, spawning dead center ###### in the log file ?

Is _class defined a bit further up ?

Is _worldspace value given to the SQL query bellow ?

Are there any errors in the server's log file ?

 

Try this for position, without the class.

_position = _location findEmptyPosition [0,60];

 

No to all of those, and ill test it on my dev server later and report back

Link to comment
Share on other sites

 

Do you see ###### TRADER BUY VEH: NO SPACE, spawning dead center ###### in the log file ?

Is _class defined a bit further up ?

Is _worldspace value given to the SQL query bellow ?

Are there any errors in the server's log file ?

 

Try this for position, without the class.

_position = _location findEmptyPosition [0,60];

 

 

hi, not working bought 3 SUV´s and they spawned on top of each other, no RPT errors or other entries

 

 

cheers

Link to comment
Share on other sites

6252    1167111524070389    13    SUV_Camo_DZE4    2014-10-27 16:24:04    2014-10-27 16:31:11    8799    [289,[11671.1,15241.4,0]]    [[[],[]],[[],[]],[[],[]]]    []    1    0
6253    1167111524070344    13    Lada1_DZE1    2014-10-27 16:24:28    2014-10-27 16:31:11    10858    [220,[11671.1,15247.7,0]]    [[[],[]],[[],[]],[[],[]]]    []    1    0
6254    1167111524070349    13    Lada1_TK_CIV_EP1_DZE4    2014-10-27 16:25:52    2014-10-27 16:31:11    2206    [142,[11671.1,15247.7,0]]    [[[],[]],[[],[]],[[],[]]]    []    1    0
6255    1167111524070342    13    Lada1_DZE1    2014-10-27 17:42:04    2014-10-27 17:42:15    6374    [288,[11674.2,15235.2,0]]    [[[],[]],[[],[]],[[],[]]]    []    1    0
6256    11671115240701666    13    VWGolf_DZE1    2014-10-27 18:05:27    2014-10-27 18:05:27    7654    [209,[11674.2,15235.2,0]]    []    []    1    0

 

6252-6254 moved after restart

 

cheers

 

Link to comment
Share on other sites

hmm ok, lets try something different....

Because from what i see dayz_objectUID3 depends on the _wordspace, i changed the function a bit....

 

Delete my fix first of all and

 

put this:

//Safe spawning of veh, not on top of eachother
_position = _location findEmptyPosition [0,60,_class];  //60m radius
if (count _position != 0) then {
    _safelocation = _position;
}else{
    //default spawner
    diag_log format["###### TRADER BUY VEH: NO SPACE, spawning dead center ######"];
    _safelocation = _location;
};
_worldspace = format["[%1,%2]", _dir,_safelocation];
_worldspace = call compile _worldspace;

ABOVE line:

_uid = _worldspace call dayz_objectUID3;
Link to comment
Share on other sites

no the same problem

 

6257    116680152352067    13    MtvrRefuel_DZ    2014-10-27 18:23:08    2014-10-27 18:23:08    12246    [2,[11668,15235.2,0]]    []    []    1    0
6258    1166801523200340    13    V3S_Refuel_TK_GUE_EP1_DZ    2014-10-27 18:24:07    2014-10-27 18:24:07    10781    [217,[11668,15232,0]]    []    []    1    0
 

but now i have a error in RPT

 

18:24:06 File z\addons\dayz_server\compile\server_tradeObject.sqf, line 9

 

 

cheers

Link to comment
Share on other sites

  • 2 weeks later...

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...