25.05.2017, 11:21
PHP код:
case 0:
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
ShowErrorDialog(playerid, "You are not driving a vehicle.");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(IsBicycle(vehicleid))
{
ShowErrorDialog(playerid, "Your vehicle doesn't have a fuel tank!");
return 1;
}
if(Fuel[vehicleid] >= 100.0)
{
ShowErrorDialog(playerid, "Your vehicle fuel tank is full.");
isrefuelling[playerid] = 0;
return 1;
}
if(GetPlayerMoney(playerid) < FUEL_PRICE)
{
ShowErrorDialog(playerid, "You don't have enough money.");
return 1;
}
RefuelTime[playerid] = 5;
SetPVarFloat(playerid, "Fuel", Fuel[vehicleid]);
GameTextForPlayer(playerid, "~g~refueling...", 2000, 3);
isrefuelling[playerid] = 1;
}
PHP код:
if(RefuelTime[i] > 0 && GetPVarInt(i, "FuelStation"))
{
new vehicleid = GetPlayerVehicleID(i);
RefuelTime[i]--;
if(RefuelTime[i] == 0)
{
new stationid = GetPVarInt(i, "FuelStation");
new cost = 100 - Fuel[vehicleid] * 3;
new vid = GetPlayerVehicleID(i);
Fuel[vid] = 100.0;
if(GetPlayerState(i) != PLAYER_STATE_DRIVER || !IsPlayerInRangeOfPoint(i, 10.0, FuelStationPos[stationid][0], FuelStationPos[stationid][1], FuelStationPos[stationid][2]))
{
GivePlayerMoney(i, -cost);
format(string, sizeof(string), "~r~-$%d", cost);
GameTextForPlayer(i, string, 2000, 3);
format(string, sizeof(string), "You have paid $%d for the fuel.", cost);
isrefuelling[i] = 0;
Fuel[vid] = 100.0;
SendClientMessage(i, COLOR_WHITE, string);
SetPVarInt(i, "FuelStation", 0);
SetTimer("SpeedoUpdate",100,1);
}
}
}