Updating vehicle damage - when? -
liam1412 - 11.04.2013
So I am saving all vehicle damage to the enum which in turn goes to the database. At what point should I update the enum??
Re: Updating vehicle damage - when? -
Faisal_khan - 11.04.2013
Run a loop under OnPlayerUpdate to check the vehicles. Maybe this will work out. Not sure.
Re: Updating vehicle damage - when? -
liam1412 - 11.04.2013
I was thinking about doing a processVehicleDamage() function on a timer every 30 seconds. Would that be heavy on resources.
Re: Updating vehicle damage - when? -
LetsOWN[PL] - 11.04.2013
Hi.
... I don't want to give bad advise or something, but I would do it when player leaves vehicle (using OnPlayerExitVehicle public).
Seems most optimal.
Greetz,
LetsOWN
Re: Updating vehicle damage - when? -
park4bmx - 11.04.2013
Quote:
Originally Posted by Faisal_khan
Run a loop under OnPlayerUpdate to check the vehicles. Maybe this will work out. Not sure.
|
simply the worst way you can think of !
Quote:
Originally Posted by LetsOWN[PL]
Hi.
... I don't want to give bad advise or something, but I would do it when player leaves vehicle (using OnPlayerExitVehicle public).
Seems most optimal.
Greetz,
LetsOWN
|
What if the player never leaves the car ?
e.g explodes.
A good way is going to be to use the vehicles
damage status update callback
OnVehicleDamageStatusUpdate
NOTE: if you want to go fully
pro on this u can make it check how fast its updating the status so there is no overwriting.
Re: Updating vehicle damage - when? -
Faisal_khan - 11.04.2013
Quote:
Originally Posted by liam1412
I was thinking about doing a processVehicleDamage() function on a timer every 30 seconds. Would that be heavy on resources.
|
Yeah that won't cause a problem. That was what I thought earlier before posting here.
Quote:
Originally Posted by LetsOWN[PL]
Hi.
... I don't want to give bad advise or something, but I would do it when player leaves vehicle (using OnPlayerExitVehicle public).
Seems most optimal.
Greetz,
LetsOWN
|
No I won't do that.
Quote:
Originally Posted by park4bmx
simply the worst way you can think of !
What if the player never leaves the car ?
e.g explodes.
A good way is going to be to use the vehicles damage status update callback
OnVehicleDamageStatusUpdate
|
Damn this was added in 0.3a and how could I never come across this!
Re: Updating vehicle damage - when? -
liam1412 - 11.04.2013
Quote:
Originally Posted by park4bmx
simply the worst way you can think of !
What if the player never leaves the car ?
e.g explodes.
A good way is going to be to use the vehicles damage status update callback
OnVehicleDamageStatusUpdate
NOTE: if you want to go fully pro on this u can make it check how fast its updating the status so there is no overwriting.
|
I could see this getting nasty. IE if someone goes on a rampage smashing into vehicles etc, that's a lot of writes. I'm not sure how I would check the speed it was updating to prevent this.
Re: Updating vehicle damage - when? -
park4bmx - 11.04.2013
after each update store the current time by how much it passed
pawn Код:
//global variables!
new Hour, Minute, Second;
//the callback
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
new nHour, nMinute, nSecond;
gettime(nHour, nMinute, nSecond);
if(nHour => Hour && nMinute => Minute && nSecond > Second+2)//the simplest check, ofc it can be more advanced(the +2 add another 2sec)
{
gettime(Hour, Minute, Second);//update the last time it updated
//run your save
}
return 1;
}
im not sure about the check as the
gettime is using
Unix time