forward CheckCarHealth();
public CheckCarHealth()
{
new PlayerAvisado[MAX_PLAYERS] = 0;
for(new i=0; i<GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(i),health);
if(health <= 400)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(i);
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alar, por, cap, porma, ob);
SetVehicleHealth(carro, 400);
}
if(PlayerAvisado[i] == 0 && health <= 400 )
{
SendClientMessage(i, -1, "{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");
PlayerAvisado[i] = 1;
}
return 1;
}
}
}
return 1;
}
// Abaixo das Includes
new bool:PlayerAvisado[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
PlayerAvisado[playerid] = false;
return 1;
}
forward CheckCarHealth();
public CheckCarHealth()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] == false)
{
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(i),health);
if(health <= 400)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(i);
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alar, por, cap, porma, ob);
SetVehicleHealth(carro, 400);
}
SendClientMessage(i, -1, "{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");
PlayerAvisado[i] = true;
return 1;
}
}
}
return 1;
}
PHP код:
|
// Abaixo das Includes
new PlayerAvisado[MAX_PLAYERS] = { 0, ... };
forward CheckCarHealth();
public CheckCarHealth()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] <= gettime() )
{
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(i),health);
if(health <= 400)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new mot, lu, alar, por, cap, porma, ob;
new carro = GetPlayerVehicleID(i);
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alar, por, cap, porma, ob);
SetVehicleHealth(carro, 400);
}
SendClientMessage(i, -1, "{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");
PlayerAvisado[i] = gettime() + 10; // em 10 segundos ele receberб o aviso novamente
return 1;
}
}
}
return 1;
}
PHP код:
|