CMD:refuel(playerid, params[]) { if (GetPVarType(playerid, "Refueling")) { SetPVarInt(playerid, "Refueling", -1); } else { new vehicleid = GetPlayerVehicleID(playerid); new iBusinessID, iPumpID; GetClosestGasPump(playerid, iBusinessID, iPumpID); if (iBusinessID == INVALID_BUSINESS_ID) { SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station."); return 1; } if (!Businesses[iBusinessID][bStatus]) { SendClientMessageEx(playerid, COLOR_RED, "This fuel station is closed."); return 1; } if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessageEx(playerid, COLOR_WHITE, "You are not driving a vehicle!"); return 1; } if(VehicleFuel[vehicleid] >= 100.0) { SendClientMessageEx(playerid, COLOR_WHITE, "Your vehicle fuel tank is full!"); return 1; } if (IsVIPcar(vehicleid)) { SendClientMessageEx(playerid, COLOR_RED, "This is a vehicle from the VIP garage and it has already unlimited amount of fuel."); return 1; } if (CreatedCars[vehicleid] != INVALID_VEHICLE_ID) { SendClientMessageEx(playerid, COLOR_RED, "This is an admin-spawned vehicle and it has already unlimited amount of fuel."); return 1; } new engine,lights,alarm,doors,bonnet,boot,objective; GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); if(engine == VEHICLE_PARAMS_ON) { SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine)."); return 1; } if (Businesses[iBusinessID][GasPumpGallons][iPumpID] == 0.0) { SendClientMessageEx(playerid, COLOR_RED, "No gas left in the gas station tank."); return 1; } if (GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) { SendClientMessageEx(playerid,COLOR_RED,"This vehicle does not need fuel."); return 1; } if (Businesses[iBusinessID][GasPumpVehicleID][iPumpID] > 0) { SendClientMessageEx(playerid, COLOR_RED, "This gas pump is occupied."); return 1; } SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait."); SendClientMessageEx(playerid, COLOR_YELLOW, "Type /refuel again to stop refueling."); SetPVarInt(playerid, "Refueling", vehicleid); Businesses[iBusinessID][GasPumpSaleGallons][iPumpID] = 0; Businesses[iBusinessID][GasPumpSalePrice][iPumpID] = 0; Businesses[iBusinessID][GasPumpVehicleID][iPumpID] = vehicleid; Businesses[iBusinessID][GasPumpTimer][iPumpID] = SetTimerEx("GasPumpSaleTimer", 200, true, "iii", playerid, iBusinessID, iPumpID); } return 1; }
stock GetClosestGasPump(playerid, &businessid, &pumpslot) { new Float: minrange = 5.0, Float: range; businessid = INVALID_BUSINESS_ID; for(new b = 0; b < MAX_BUSINESSES; b++) { for(new i = 0; i < MAX_BUSINESS_GAS_PUMPS; i++) { range = GetPlayerDistanceFromPoint(playerid, Businesses[b][GasPumpPosX][i], Businesses[b][GasPumpPosY][i], Businesses[b][GasPumpPosZ][i]); if (range < minrange) { businessid = b; pumpslot = i; minrange = range; } } } }
Install crashdetect plugin. Probably one of arrays' size is to small.
|
new x = 99;
new string[10];
string[x] = "hello";