06.02.2016, 02:27
(
Последний раз редактировалось itsCody; 06.02.2016 в 03:02.
)
Detect if the engine is off then kill the timer.
Or detect if the vehicle is moving by using some speed script
if((speed) > 1) Fuel --;
Could try something like
If you get errors post them cause this is untested and yeah
Or detect if the vehicle is moving by using some speed script
if((speed) > 1) Fuel --;
Could try something like
PHP код:
public timer_fuel_lower()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new vid = GetPlayerVehicleID(i);
new speed = GetPlayerSpeed(i, false)
if(isrefuelling[i]) continue;
if(fuel[vid] > 0)
{
if((speed) > 1) fuel[vid] --;
if(fuel[vid] >= 1 && fuel[vid] <= 15 && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
SendClientMessage(i, -1, "Vehicle low on fuel");
}
}
if(fuel[vid] <= 0)
{
fuel[vid] = 0;
// Turn the engine off here.
}
}
return 1;
}
GetPlayerSpeed(playerid, bool:kmh = false)
{
new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), Vx, Vy, Vz); else GetPlayerVelocity(playerid, Vx, Vy, Vz);
rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz, 2)));
return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}