Transport Smallest Vehicles in Large Vehicles Problem

meshguru99

New Member
I'm working out the last details in a mod that will allow players to move bikes, motorbikes, and ATVs in Urals, Prahas, Mi17s ... bikes in MH6s, Land Rovers, open pickups... etc.

I have everything working perfectly EXCEPT updating the transportable in the data base at the instant of "unloading". Here's an excerpt from the very last section of the UnloadVehicle.sqf script:

// find the player's position
_posPlayer = getPos player;

// find the vector from the transport to the player
_fOffsetX = ( _posPlayer select 0 ) - ( _posTransport select 0 );
_fOffsetY = ( _posPlayer select 1 ) - ( _posTransport select 1 );

// determine the relative direction of the player to the transport
// and then find the position to offload the transportable behind the player
if ( _fOffsetX < 0 ) then {
_fNewX = ( _posTransport select 0 ) - 5;
} else {
_fNewX = ( _posTransport select 0 ) + 5;
};

if ( _fOffsetY < 0 ) then {
_fNewY = ( _posTransport select 1 ) - 5;
} else {
_fNewY = ( _posTransport select 1 ) + 5;
};

// start with a known position data type to avoid the position type constructor bug
_posDestination = getPos _objTransportable;
_posDestination set [0 , _fNewX];
_posDestination set [1 , _fNewY];

// move the transportable there
_objTransportable setpos _posDestination;

// make the transportable bounce
_objTransportable setvelocity [0,0,1];

// damage it a little bit to help force updates / pay for feature use with a tradeoff
_fDamage = getDammage _objTransportable;
_fDamageNew = _fDamage + 0.005;
_objTransportable setDamage _fDamageNew;

// update in the data base
_vehicleType = typeOf _objTransportable;
[_objTransportable , _vehicleType] call server_updateObject;

// a message to the player
titleText ["You should drive your unloaded vehicle a little to update its database entry." , "PLAIN DOWN", 3];

The call to server_updateObject is the same as that used by salvage routines, and for that it works perfectly. I've looked at the code for that script and it appears to handle position as well with a separate hive update call, but the issue I'm having is that the transportable vehicle moves to the position it occupied prior to being loaded on the transport at the next restart UNLESS someone gets into it and drives it some minimal distance after it's unloaded. In which case everything is hunky dory.

How do I force a vehicle position update into the data base?
 
Back
Top