Author Topic: Vehicle Recovery (Idle Time Requirement)  (Read 1414 times)

It's supposed to start a timer when the driver leaves. However, I can hop in, drive five feet, hit the recover event, and it recovers before the time requirement is met.

Why is it not working?

Code: [Select]
$Vehicles::RecoveryIdleRequirement = 90;



function Vehicle::makeRecoverable(%obj)
{
%obj.isRecoverable = 1;
}



function Vehicle::refreshCanBeRecoveredSchedule(%obj)
{
if(isEventPending(%obj.canBeRecoveredSchedule))
cancel(%obj.canBeRecoveredSchedule);

%obj.canBeRecoveredSchedule = %obj.schedule($Vehicles::RecoveryIdleRequirement*1000,"makeRecoverable");
}

if(isPackage(RecoveryIdleRequirement))
deActivatePackage(RecoveryIdleRequirement);

package RecoveryIdleRequirement
{
//when the driver leaves, the idle timer begins.
function Vehicle::onDriverLeave(%obj,%player)
{
Parent::onDriverLeave(%obj,%player);

if(isObject(%obj))
{
%obj.isRecoverable = 0;
refreshCanBeRecoveredSchedule(%obj);
}
}

function fxDTSBrick::recoverVehicle(%obj)
{
//make it recoverable if it's never been scheduled. (sometimes vehicle sink below spawns, etc)
if(!isEventPending(%obj.canBeRecoveredSchedule))
%obj.isRecoverable = true;

//driver has left for 90 seconds, we will now recover, provided the requirements of the parent function are met (no passengers)
if(%obj.isRecoverable == true)
parent::recoverVehicle(%obj);
else
return;
}
};
activatePackage(RecoveryIdleRequirement);

Does ::onDriverLeave even exist?

-Dannu
« Last Edit: April 01, 2016, 04:58:35 AM by Dannu »

yes; I also tried:

Code: [Select]
function Armor::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
Parent::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);

if(isObject(%obj.spawnBrick) && isObject(%player.client) && %obj.getDatablock().rideable)
{
%obj.isRecoverable = 0;
refreshCanBeRecoveredSchedule(%obj);
}
}

same result
« Last Edit: April 01, 2016, 12:24:47 AM by Tezuni 2.0 »

Are you sure the ::onUnMount arguments are correct? Despite the current layout predicatement, I found a help topic where there were two. %this (player) and %obj (object that was unmounted from). I can't really verify how reliable the person is obviously.

-Dannu

I am pretty sure we went over a similar issue with onDriverLeave before.
onDriverLeave is a datablock (vehicleData) function.
You are using it as an object function, which should explain why it does not work.

-Lordician
Never mind, i  confused things.

Code: [Select]
//when the driver leaves, the idle timer begins.
function Vehicle::onDriverLeave(%obj,%player)
{
Parent::onDriverLeave(%obj,%player);

if(isObject(%obj))
{
%obj.isRecoverable = 0;
>>>>>>>> refreshCanBeRecoveredSchedule(%obj); <<<<<<<<
                }
         }
shouldn't that be %obj.refreshCanBeRecoveredSchedule();

- gytyyhgfffff

Code: [Select]
-snip-
shouldn't that be %obj.refreshCanBeRecoveredSchedule();

- gytyyhgfffff
Yep.
« Last Edit: April 06, 2016, 07:08:08 AM by jes00 »

Updated the code with this.
Code: [Select]
%obj.refreshCanBeRecoveredSchedule();

Now the echos in all the functions are all calling on time. That's good!

But
Code: [Select]
if(%obj.isRecoverable == true)is still passing when it shouldn't. So the vehicle are able to be recovered immediately still.



-Tezuni

You're trying to check against the actual brick (%obj), not the vehicle (%obj.vehicle).

You're making it way too complicated. Use this:

Code: [Select]
$Vehicles::RecoveryIdleRequirement = 90;

package RecoveryIdleRequirement
{
function Vehicle::onDriverLeave(%this, %player)
{
parent::onDriverLeave(%this, %player);
%this.driverExitTime = $Sim::Time;
}

function FxDtsBrick::recoverVehicle(%this)
{
%exitTime = %this.vehicle.driverExitTime;
if(!strLen(%exitTime) || $Sim::Time - %exitTime >= $Vehicles::RecoveryIdleRequirement)
parent::recoverVehicle(%this);
}
};
activatePackage(RecoveryIdleRequirement);
« Last Edit: April 06, 2016, 01:15:14 PM by Greek2me »

that's much better Greek, thanks

works nicely, just had to add a missing semicolon here
Code: [Select]
%exitTime = %this.vehicle.driverExitTime;


Am I missing something?
Notice how these were posted on April 1st. On that day, everyone was anonymous and nobody knew who was who.

Notice how these were posted on April 1st. On that day, everyone was anonymous and nobody knew who was who.
Ah, I see now.