OnPlayerEnterVehicle
Код:
format(string,sizeof(string),"~w~Vehicle: ~b~%s",VehicleName[GetVehicleModel(vehicleid)-400]);
TextDrawSetString(Textdraw3,string);
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
TextDrawShowForPlayer(playerid,Textdraw3);
Fuel = SetTimerEx("FuelUpdate", 300, true, "i", playerid);
Engine = SetTimerEx("EngineUpdate", 300,true, "i", playerid);
new public: FuelUpdate
Код:
public FuelUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
new vehicle = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
if(Gas[vehicle] >= 1)
{
if(Gas[vehicle] >= 0 && Gas[vehicle] <= 0)
{
TextDrawSetString(Textdraw2,"~w~Fuel: ----------");
SendClientMessage(playerid,COLOR_LIGHTRED,"There is no fuel in the fuel's tank please fill your car or /exit");
TogglePlayerControllable(playerid, 0);
}
if(Gas[vehicle] >= 0 && Gas[vehicle] <= 10)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -~w~---------");
}
if(Gas[vehicle] >= 10 && Gas[vehicle] <= 20)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ --~w~--------");
}
else if(Gas[vehicle] >= 20 && Gas[vehicle] <= 30)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ---~w~-------");
}
else if(Gas[vehicle] >= 30 && Gas[vehicle] <= 40)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ----~w~------");
}
else if(Gas[vehicle] >= 40 && Gas[vehicle] <= 50)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -----~w~-----");
}
else if(Gas[vehicle] >= 50 && Gas[vehicle] <= 60)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ------~w~----");
}
else if(Gas[vehicle] >= 60 && Gas[vehicle] <= 70)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -------~w~---");
}
else if(Gas[vehicle] >= 70 && Gas[vehicle] <= 80)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ --------~w~--");
}
else if(Gas[vehicle] >= 80 && Gas[vehicle] <= 90)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ---------~w~-");
}
else if(Gas[vehicle] >= 90 && Gas[vehicle] <= 100)
{
TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ----------");
}
}
}
}
return 1;
}
new public: EngineUpdate
Код:
public EngineUpdate(playerid)
{
new Float:health;
GetVehicleHealth(GetPlayerVehicleID(playerid),health);
if (IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(health >= 0 && health <= 0)
{
TextDrawSetString(Textdraw1,"~w~Engine: ----------");
}
else if(health >= 0 && health <= 100)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~-~w~---------");
}
else if(health >= 100 && health <= 200)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~--~w~--------");
}
else if(health >= 200 && health <= 300)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~---~w~-------");
}
else if(health >= 300 && health <= 400)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~----~w~------");
}
else if(health >= 400 && health <= 500)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~-----~w~-----");
}
else if(health >= 500 && health <= 600)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~------~w~----");
}
else if(health >= 600 && health <= 700)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~-------~w~---");
}
else if(health >= 700 && health <= 800)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~--------~w~--");
}
else if(health >= 800 && health <= 900)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~---------~w~-");
}
else if(health >= 900 && health <= 1000)
{
TextDrawSetString(Textdraw1,"~w~Engine: ~r~----------");
}
}
return 1;
}