04.08.2012, 02:21
I am trying to script the fuel system and I'm having a weird issue. Everytime I pull a vehicle into the gas station area the players SA:MP client will crash. There are no script errors or warnings in pawn, and nothing in the server log or crash log. It simply just crashes the players client. Here is the code being used for it.
OnGameModeInit
public PlayerIsAtPump(playerid)
/fill Command
I am using Streamer 2.6 and 0.3e. I use 2.6 because 2.6.1 will not run on the server. The PlayerIsAtPump function worked fine and the vehicle could use the command in the area yesterday when I had an older version of the streamer loaded. Now that I upgraded to 2.6 it compiles fine, but will crash the client as I said before.
Any help would be greatly appreciated.
OnGameModeInit
pawn Код:
GasArea[0] = CreateDynamicRectangle(40.35, 1213.57, 61.37, 1222.19);
pawn Код:
public PlayerIsAtPump(playerid) {
for(new i; i < sizeof(GasArea); i++) {
if(IsPlayerInDynamicArea(playerid, GasArea[i])) {
return 1;
}
}
return 0;
}
pawn Код:
CMD:fill(playerid, params[]) {
new cv, vehd, model, fuelprice;
new Float:gal, Float:needgal, capacity, perc, Float:costa, Float:cost, finalcost;
cv = GetClosestCar(playerid);
vehd = GetDistanceToCar(playerid, cv);
model = GetVehicleModel(cv);
if(PlayerIsAtPump(playerid)) {
if(vehd <= 5.00) {
// not actually filling the vehicle or charging the person money for debugging purposes
// VehicleData[cv-1][vFuel] = 100;
// format(myquery, sizeof(myquery), "UPDATE saes_vehicles SET fuel='100' WHERE id='%i'", cv);
// mysql_query(myquery);
capacity = VehicleFuelCapacity[model-400];
gal = capacity/100;
perc = 100-VehicleData[cv-1][vFuel];
fuelprice = 3;
costa = floatmul(gal,perc);
cost = floatmul(costa, fuelprice);
needgal = floatmul(gal,perc);
finalcost = floatround(cost, floatround_ceil);
format(msgstring, sizeof(msgstring), "Car filled, %f gallons at $%i", needgal, finalcost);
SendClientMessage(playerid, -1, msgstring);
} else {
SendClientMessage(playerid, COLOR_YELLOW, "[ ! ] You are not near a vehicle.");
}
} else {
SendClientMessage(playerid, COLOR_YELLOW, "[ ! ] You are not at a gas pump.");
}
return 1;
}
Any help would be greatly appreciated.