#tryinclude < a_samp >
new KocsiTimer[MAX_PLAYERS];
new Float:vHealth[MAX_VEHICLES];
forward OnVehicleLoseHealth( playerid, vehicleid, Float:Health );
public OnVehicleLoseHealth( playerid, vehicleid, Float:Health ) {
if( Health >= 150.0 ) {
SendClientMessage( playerid, -1, \"nagyot ütköztél.\" );
}
return 1;
}
public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( newstate == PLAYER_STATE_DRIVER )
{
new Float:H; GetVehicleHealth( GetPlayerVehicleID(playerid), H );
vHealth[GetPlayerVehicleID(playerid)] = H;
KocsiTimer[playerid] = SetTimerEx( \"HealthCheck\", 400, true, \"ii\", playerid, GetPlayerVehicleID(playerid) );
}
else if( newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER )
{
KillTimer( KocsiTimer[playerid] );
}
}
forward HealthCheck( playerid, vehicleid );
public HealthCheck( playerid, vehicleid ) {
new Float:H;
GetVehicleHealth( vehicleid, H );
if( H < vHealth[vehicleid] )
{
new Float:veg;
veg = ( vHealth[vehicleid] - H );
CallLocalFunction( \"OnVehicleLoseHealth\", \"iif\", playerid, vehicleid, veg );
vHealth[vehicleid] = H;
}
}