15.11.2013, 22:14
I have problem, that i cant refuel my car. I write /refuel but the gas dont filll up.
Where is the problem?
PHP код:
new Float: VehicleFuel[MAX_VEHICLES] = 100.0;
new VehicleStatus[MAX_VEHICLES char] = 0; // 0 == none, 1 == vehicle dead about to respawn
new RefuelingVehicle[MAX_PLAYERS];
new RefuelingVehiclePrice[MAX_PLAYERS];
new RefuelingVehicleTimer[MAX_PLAYERS];
new Bar:FuelBar[MAX_PLAYERS] = INVALID_BAR_ID;
PHP код:
stock StopRefueling(playerid)
{
GivePlayerCash(playerid, -100);
new mypoint = -1;
for (new i=0; i<MAX_POINTS; i++)
{
if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
{
mypoint = i;
}
}
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
{
FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
}
}
RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid] = 6000);
return true;
}
IsAtFuelStation(playerid)
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(Carrier[0], X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid,10,1595.5406, 2198.0520, 10.3863) || IsPlayerInRangeOfPoint(playerid,10,2202.0649, 2472.6697, 10.5677) ||
IsPlayerInRangeOfPoint(playerid,10,2115.1929, 919.9908, 10.5266) || IsPlayerInRangeOfPoint(playerid,10,2640.7209, 1105.9565, 10.5274) ||
IsPlayerInRangeOfPoint(playerid,10,608.5971, 1699.6238, 6.9922) || IsPlayerInRangeOfPoint(playerid,10,618.4878, 1684.5792, 6.9922) ||
IsPlayerInRangeOfPoint(playerid,10,2146.3467, 2748.2893, 10.5245) || IsPlayerInRangeOfPoint(playerid,10,-1679.4595, 412.5129, 6.9973) ||
IsPlayerInRangeOfPoint(playerid,10,-1327.5607, 2677.4316, 49.8093) || IsPlayerInRangeOfPoint(playerid,10,-1470.0050, 1863.2375, 32.3521) ||
IsPlayerInRangeOfPoint(playerid,10,-2409.2200, 976.2798, 45.2969) || IsPlayerInRangeOfPoint(playerid,10,-2244.1396, -2560.5833, 31.9219) ||
IsPlayerInRangeOfPoint(playerid,10,-1606.0544, -2714.3083, 48.5335) || IsPlayerInRangeOfPoint(playerid,10,1937.4293, -1773.1865, 13.3828) ||
IsPlayerInRangeOfPoint(playerid,10,-91.3854, -1169.9175, 2.4213) || IsPlayerInRangeOfPoint(playerid,10,1383.4221, 462.5385, 20.1506) ||
IsPlayerInRangeOfPoint(playerid,10,660.4590, -565.0394, 16.3359) || IsPlayerInRangeOfPoint(playerid,10,1381.7206, 459.1907, 20.3452) ||
IsPlayerInRangeOfPoint(playerid,10,-1605.7156, -2714.4573, 48.5335) || IsPlayerInRangeOfPoint(playerid,20,1882.2546,-2393.9824,16.5144) ||
IsPlayerInRangeOfPoint(playerid,10,1386.5360,-271.5511,-0.4857) || IsPlayerInRangeOfPoint(playerid,10,2017.3016,-229.9219,-0.2183) ||
IsPlayerInRangeOfPoint(playerid,10,279.1325,1940.4025,17.6406) || IsPlayerInRangeOfPoint(playerid,250,X, Y, Z))
{ return true; }
return false;
}
forward ReFill(playerid);
public ReFill(playerid)
{
if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
{
StopRefueling(playerid);
}
else
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON) return StopRefueling(playerid);
VehicleFuel[GetPlayerVehicleID(playerid)] += 1.0; RefuelingVehiclePrice[playerid] += 30;
if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0) VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
}
return true;
}
PHP код:
CMD:refuel(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON) return SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine or press 2).");
if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
if(VehicleFuel[vehicleid] >= 100.0) return SendClientMessageEx(playerid, COLOR_RED, "This vehicle's tank is already full.");
if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
SendClientMessageEx(playerid, COLOR_GREY, "Refueling your vehicle's tank, please wait.");
RefuelingVehicle[playerid] = 1;
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
}
return 1;
}
PHP код:
Timer:VehicleUpdate[10000]()
{
new engine,lights,alarm,doors,bonnet,boot,objective,modelid;
for(new v = 0; v < MAX_VEHICLES; v++) if(GetVehicleModel(v)) {
modelid = GetVehicleModel(v);
GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
switch(modelid) {
case 520, 476, 593, 553, 513, 512, 577, 592, 511, 539, 464, 519: VehicleFuel[v] = 100;
case 509, 481, 510: VehicleFuel[v] = 100, arr_Engine{v} = 1, SetVehicleParamsEx(v,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
if(engine == VEHICLE_PARAMS_ON) {
if(VehicleFuel[v] > 0.0 && !IsVIPcar(v) && !IsATruckerCar(v))
{
VehicleFuel[v]-=0.01;
if(VehicleFuel[v] <= 0.0) SetVehicleParamsEx(v,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
if(arr_Engine{v} == 0) SetVehicleParamsEx(v,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
}
}