Lose money after car crash
#1

Hi,
Is it possible to take 1 dollar away from the player every time he crashes while he's in a car?
I mean every time the car takes damage by a crash.
-Superthijs
Reply
#2

pawn Код:
new
    Float:oldvhp[ MAX_PLAYERS ]
    ,Float:newvhp[ MAX_PLAYERS ]
;
public OnPlayerUpdate( playerid ) {
    if( IsPlayerInAnyVehicle( playerid ) ) {
        GetVehicleHealth( GetPlayerVehicleID( playerid ), newvhp[ playerid ] );
        if( newvhp[ playerid ] < oldvhp[ playerid ] ) GivePlayerMoney( playerid, -1 );
    }
    GetVehicleHealth( GetPlayerVehicleID( playerid ), oldvhp[ playerid ] );
    return 1;
}
Reply
#3

I suggest you make a timer instead use OnPlayerUpdate.
Reply
#4

yes because onplayerupdate will be used 23 times per seconds
Reply
#5

Quote:
Originally Posted by Tigerkiller
Посмотреть сообщение
yes because onplayerupdate will be used 23 times per seconds
No it isn't.
https://sampwiki.blast.hk/wiki/OnPlayerUpdate
Reply
#6

There's not a static amount of how many calls there will be in a second, it's not 23, it's not 24, it depends on the client.
Reply
#7

https://sampwiki.blast.hk/wiki/OnVehicleDamageStatusUpdate

?
Reply
#8

What if the vehicle element already broken but the health still > 800?
Timer is the best idea IMO.
Reply
#9

You don't need to change to a timer unless the script actually lags, and no, OnPlayerUpdate doesn't get called 23 times a second.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)