SA-MP Forums Archive
Lose money after car crash - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Lose money after car crash (/showthread.php?tid=274599)



Lose money after car crash - Superthijs - 06.08.2011

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


Re: Lose money after car crash - Mean - 06.08.2011

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;
}



Re: Lose money after car crash - =WoR=Varth - 06.08.2011

I suggest you make a timer instead use OnPlayerUpdate.


Re: Lose money after car crash - Tigerkiller - 06.08.2011

yes because onplayerupdate will be used 23 times per seconds


Re: Lose money after car crash - =WoR=Varth - 06.08.2011

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


Re: Lose money after car crash - Calgon - 06.08.2011

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.


Re: Lose money after car crash - Vince - 06.08.2011

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

?


Re: Lose money after car crash - =WoR=Varth - 06.08.2011

Quote:
Originally Posted by Vince
Посмотреть сообщение
What if the vehicle element already broken but the health still > 800?
Timer is the best idea IMO.


Re: Lose money after car crash - Mean - 07.08.2011

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.