• 0
IcyAxe

Bug in ExileServer_object_vehicle_database_update.sqf

Question

Hi,

i found a bug with code for updating vehicle weapon and magazine cargo.

	_data =
	[
		_vehicleObject getVariable ["ExileIsLocked",-1],
		fuel _vehicleObject,
		damage _vehicleObject,
		_vehicleHitpoints,
		_position select 0,
		_position select 1,
		_position select 2,
		_vectorDirection select 0, 
		_vectorDirection select 1,
		_vectorDirection select 2,
		_vectorUp select 0,
		_vectorUp select 1,
		_vectorUp select 2,
		_vehicleObject call ExileServer_util_getItemCargo,
		magazinesAmmoCargo _vehicleObject,
		weaponsItemsCargo _vehicleObject,
		_vehicleObject call ExileServer_util_getObjectContainerCargo,
		_vehicleObject getVariable ["ExileMoney", 0],
		_vehicleID 
	];

 

Functions magazinesAmmoCargo && weaponsItemsCargo will on some vehicles(bikes) return nil or null variable... which will cause "<null>" to be written to database which will in return cause vehicles in question fail to load.

My proposed change(i am not sure about it if its ok this way or not, but it works on my server) is 
 

	_vehicleMagazineCargo = magazinesAmmoCargo _vehicleObject;
	if(isNil {_vehicleMagazineCargo})then
	{
		_vehicleMagazineCargo = [];
	};
	
	_vehicleWeaponItemsCargo = weaponsItemsCargo _vehicleObject;
	if(isNil {_vehicleWeaponItemsCargo})then
	{
		_vehicleWeaponItemsCargo = [];
	};
	
	_data =
	[
		_vehicleObject getVariable ["ExileIsLocked",-1],
		fuel _vehicleObject,
		damage _vehicleObject,
		_vehicleHitpoints,
		_position select 0,
		_position select 1,
		_position select 2,
		_vectorDirection select 0, 
		_vectorDirection select 1,
		_vectorDirection select 2,
		_vectorUp select 0,
		_vectorUp select 1,
		_vectorUp select 2,
		_vehicleObject call ExileServer_util_getItemCargo,
		_vehicleMagazineCargo,
		_vehicleWeaponItemsCargo,
		_vehicleObject call ExileServer_util_getObjectContainerCargo,
		_vehicleObject getVariable ["ExileMoney", 0],
		_vehicleID 
	];


Cheers, Icy.

Share this post


Link to post
Share on other sites

6 answers to this question

  • 0

Posted (edited)

On 7/4/2016 at 5:14 AM, IcyAxe said:

Hi,

i found a bug with code for updating vehicle weapon and magazine cargo.

Functions magazinesAmmoCargo && weaponsItemsCargo will on some vehicles(bikes) return nil or null variable... which will cause "<null>" to be written to database which will in return cause vehicles in question fail to load.

My proposed change(i am not sure about it if its ok this way or not, but it works on my server) is 
 


Cheers, Icy.

Did any vehicle other than bikes have a null value and did you make bikes available for purchase at the traders? Bikes have no cargo, and making them available for purchase creates a persistent bike and adds it to the database. When it writes, you get null values in cargo because it has no cargo capacity.

Edited by Timmay

Share this post


Link to post
Share on other sites
  • 0

Yes, thats true, i made bikes available for purchase(for now). But i anyway wanted to cover this case. Because i am using other mods. 

Share this post


Link to post
Share on other sites
Advertisement
  • 0
On 7/6/2016 at 11:19 PM, IcyAxe said:

Yes, thats true, i made bikes available for purchase(for now). But i anyway wanted to cover this case. Because i am using other mods. 

I would recommend you remove the bikes from traders, and purge your database of the ones that did write. It caused me problems and I learned the hard way. Players treat bikes like disposable objects so in the long run we just removed them and spawn in vehicles in spawn zones that have little or no value so others can't profit off them on restarts, they maintain that disposable factor but don't write incorrect data to the database. We made a few other cars that are persistent really cheap so the starting players aren't struggling too much in the start but it makes for a much less cluttered server (and better performance) and most players got over it real quick.

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

I justed edited my ExileServer_system_trading_network_purchaseVehicleRequest so bikes don't save to the db. Server restart? All bikes are purged since they aren't in the db and considered disposable.

Change this:

	_vehicleObject call ExileServer_object_vehicle_database_insert;
	_vehicleObject call ExileServer_object_vehicle_database_update;

to this:

//Don't save bikes
if !(_vehicleClass in ["Exile_Bike_MountainBike","Exile_Bike_OldBike"]) then
	 {
	_vehicleObject call ExileServer_object_vehicle_database_insert;
	_vehicleObject call ExileServer_object_vehicle_database_update;
	};

Save a copy and put it in your mission overrides.

Edited by ynpMOOSE
1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

11 hours ago, ynpMOOSE said:

I justed edited my ExileServer_system_trading_network_purchaseVehicleRequest so bikes don't save to the db. Server restart? All bikes are purged since they aren't in the db and considered disposable.

Change this:


	_vehicleObject call ExileServer_object_vehicle_database_insert;
	_vehicleObject call ExileServer_object_vehicle_database_update;

to this:


//Don't save bikes
if !(_vehicleClass in ["Exile_Bike_MountainBike","Exile_Bike_OldBike"]) then
	 {
	_vehicleObject call ExileServer_object_vehicle_database_insert;
	_vehicleObject call ExileServer_object_vehicle_database_update;
	};

Save a copy and put it in your mission overrides.

Nice idea! I will add this to my server :) only change I will do is to add values into config entry instead of directly hardcoding them. Is it possible to mark some of the vehicles at traders that they are non-persistant?

Edited by IcyAxe

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.