01.02.2014, 16:48
pawn Код:
forward GasPumpSaleTimer(playerid, business);
public GasPumpSaleTimer(playerid, business)
{
new iVehicleID = GetPVarInt(playerid, "Refuelling"), Float: fPumpAmount = 0.1 / 4, szLabel[128];
if(fPumpAmount*10 + iVehicleFuel[iVehicleID] > 100.0)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* The vehicles fuel tank is now full. *");
StopRefuellingVehicle(playerid, business);
return 1;
}
else if(IsRefuelling[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* You have stopped refueling. *");
StopRefuellingVehicle(playerid, business);
KillTimer(GasPumpTimer[playerid]);
return 1;
}
else if(fPumpAmount > BusinessInfo[business][bI_GasPumpGallons])
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* There is no more gallons of gas left in the pump, please come back later. *");
StopRefuellingVehicle(playerid, business);
return 1;
}
else if(PlayerData[playerid][p_Money] < floatround(BusinessInfo[business][bI_GasSalePrice]))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "* You cannot afford anymore fuel. *");
StopRefuellingVehicle(playerid, business);
return 1;
}
else if(GetVehicleDistanceFromPoint(iVehicleID, BusinessInfo[business][bI_GasPumpPos][0], BusinessInfo[business][bI_GasPumpPos][1], BusinessInfo[business][bI_GasPumpPos][2]) > 5.0)
{
StopRefuellingVehicle(playerid, business);
return 1;
}
BusinessInfo[business][bI_GasPumpGallons] -= fPumpAmount;
iVehicleRefuel[iVehicleID] += fPumpAmount*10;
BusinessInfo[business][bI_SaleGallons] += fPumpAmount;
BusinessInfo[business][bI_GasSalePrice] += fPumpAmount * BusinessInfo[business][bI_GasPrice];
format(szLabel, sizeof(szLabel), "[ Sale Total: $%.2f\n[ Gallons: %.3f ]\n\n[ Price Per Gallon: $%.2f ]\n[ Gas Available: %.2f/%.2f gallons ]", BusinessInfo[business][bI_GasSalePrice], BusinessInfo[business][bI_SaleGallons], BusinessInfo[business][bI_GasPrice], BusinessInfo[business][bI_GasPumpGallons], BusinessInfo[business][bI_GasPumpCapacity]);
UpdateDynamic3DTextLabelText(BusinessInfo[business][bI_GasPumpText], COLOR_YELLOW, szLabel);
DeletePVar(playerid, "StoppingGasTimer");
return 1;
}
pawn Код:
StopRefuellingVehicle(playerid, business)
{
new iCost = floatround(BusinessInfo[business][bI_GasSalePrice]), iVehicleID = GetPVarInt(playerid, "Refuelling"), iPlayerVeh = GetPlayerVehicle(playerid, GetPlayerVehicleID(playerid));
format(szOutput, sizeof(szOutput), "* You have refilled your vehicle's fuel tank for: $%d. *", iCost);
SendClientMessage(playerid, COLOR_LIGHTBLUE, szOutput);
if(GetPlayerVehicle(playerid, GetPlayerVehicleID(playerid))) // Player Owned Veh
{
VehicleInfo[playerid][iPlayerVeh][pv_Fuel] += iVehicleRefuel[iVehicleID];
GivePlayerCash(playerid, -iCost);
}
if(IsAFactionVehicle(GetPlayerVehicleID(playerid))) // Fac Veh
{
iVehicleFuel[iVehicleID] += iVehicleRefuel[iVehicleID];
FactionInfo[PlayerData[playerid][p_Faction]][fI_vBalance] -= iCost;
SendClientMessage(playerid, COLOR_WHITE, "As this is a faction vehicle, they have paid for the fuel.");
}
else { // Random Veh
iVehicleFuel[iVehicleID] +=iVehicleRefuel[iVehicleID];
GivePlayerCash(playerid, -iCost);
}
DeletePVar(playerid, "Refuelling");
BusinessInfo[business][bI_GasPumpStatus] = 0;
KillTimer(GasPumpTimer[playerid]);
return 1;
}
Refuel CMD: http://pastebin.com/KP5YAYqf
Any idea why?
Thanks!