08.09.2012, 16:58
Basically I was working on a /fuel script and none of the mathematics seem to be working properly:
I am completely clueless on what I am doing wrong. ??
pawn Код:
command(fuel, playerid, vehicleid, params[])
{
new fuelamount;
new neededfuel = MAX_FUEL - Vehicles[vehicleid][Fuel];
if(sscanf(params, "d", fuelamount))
{
SendClientMessage(playerid, ERROR, "SYNTAX: /fuel [amount]");
}
else
{
if(IsPlayerInAnyVehicle(playerid))
{
new calculation = REFUEL_COST / fuelamount;
if(fuelamount > neededfuel)
{
SendClientMessage(playerid, ERROR, "Your vehicle cannot hold that much fuel!");
}
else
{
if(Player[playerid][Money] < calculation)
{
SendClientMessage(playerid, ERROR, "You do not have enough money to refuel your vehicle.");
}
else
{
new calculation2 = Player[playerid][Money] -= calculation;
new timertime = fuelamount * 1000;
SetPlayerMoney(playerid, calculation2);
TogglePlayerControllable(playerid, false);
SetTimerEx("Fueling", timertime, false, "i", playerid);
new ifuel = Vehicles[vehicleid][Fuel] + fuelamount;
Vehicles[vehicleid][Fuel] = ifuel;
}
}
}
}
return 1;
}