Updating vehicle damage - when?
#1

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??
Reply
#2

Run a loop under OnPlayerUpdate to check the vehicles. Maybe this will work out. Not sure.
Reply
#3

I was thinking about doing a processVehicleDamage() function on a timer every 30 seconds. Would that be heavy on resources.
Reply
#4

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
Reply
#5

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.
Reply
#6

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!
Reply
#7

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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)