Refuel system
#1

I have problem, that i cant refuel my car. I write /refuel but the gas dont filll up.

PHP код:
new FloatVehicleFuel[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=0i<MAX_POINTSi++)
    {
        if(
strcmp(Points[i][Name], "Fossil Fuel Company"true) == 0)
        {
            
mypoint i;
        }
    }
    for(new 
0sizeof(FamilyInfo); i++)
    {
        if(
strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
        {
            
FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
        }
    }
    
RefuelingVehicle[playerid] = 0RefuelingVehiclePrice[playerid] = 0KillTimer(RefuelingVehicleTimer[playerid] = 6000);
    return 
true;
}
IsAtFuelStation(playerid)
{
    new 
Float:XFloat:YFloat:Z;
    
GetObjectPos(Carrier[0], XYZ);
    if(
IsPlayerInRangeOfPoint(playerid,10,1595.54062198.052010.3863) || IsPlayerInRangeOfPoint(playerid,10,2202.06492472.669710.5677) ||
    
IsPlayerInRangeOfPoint(playerid,10,2115.1929919.990810.5266) || IsPlayerInRangeOfPoint(playerid,10,2640.72091105.956510.5274) ||
    
IsPlayerInRangeOfPoint(playerid,10,608.59711699.62386.9922) || IsPlayerInRangeOfPoint(playerid,10,618.48781684.57926.9922) ||
    
IsPlayerInRangeOfPoint(playerid,10,2146.34672748.289310.5245) || IsPlayerInRangeOfPoint(playerid,10,-1679.4595412.51296.9973) ||
    
IsPlayerInRangeOfPoint(playerid,10,-1327.56072677.431649.8093) || IsPlayerInRangeOfPoint(playerid,10,-1470.00501863.237532.3521) ||
    
IsPlayerInRangeOfPoint(playerid,10,-2409.2200976.279845.2969) || IsPlayerInRangeOfPoint(playerid,10,-2244.1396, -2560.583331.9219) ||
    
IsPlayerInRangeOfPoint(playerid,10,-1606.0544, -2714.308348.5335) || IsPlayerInRangeOfPoint(playerid,10,1937.4293, -1773.186513.3828) ||
    
IsPlayerInRangeOfPoint(playerid,10,-91.3854, -1169.91752.4213) || IsPlayerInRangeOfPoint(playerid,10,1383.4221462.538520.1506) ||
    
IsPlayerInRangeOfPoint(playerid,10,660.4590, -565.039416.3359) || IsPlayerInRangeOfPoint(playerid,10,1381.7206459.190720.3452) ||
    
IsPlayerInRangeOfPoint(playerid,10,-1605.7156, -2714.457348.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,XYZ))
    {    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.0RefuelingVehiclePrice[playerid] += 30;
        if(
VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
    }
    return 
true;

PHP код:
CMD:refuel(playeridparams[])
{
    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(playeridCOLOR_RED"You need to shut off the engine before filling up (/car engine or press 2).");
        if(!
IsAtFuelStation(playerid)) return SendClientMessageEx(playeridCOLOR_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(playeridCOLOR_RED"This vehicle's tank is already full.");
        if(
RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playeridCOLOR_RED"You are refilling your vehicle's tank.");
        
SendClientMessageEx(playeridCOLOR_GREY"Refueling your vehicle's tank, please wait.");
        
RefuelingVehicle[playerid] = 1;
        
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill"1000true"i"playerid);
    }
    return 
1;

PHP код:
Timer:VehicleUpdate[10000]()
{
    new 
engine,lights,alarm,doors,bonnet,boot,objective,modelid;
    for(new 
0MAX_VEHICLESv++) if(GetVehicleModel(v)) {
        
modelid GetVehicleModel(v);
        
GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
        switch(
modelid) {
            case 
520476593553513512577592511539464519VehicleFuel[v] = 100;
            case 
509481510VehicleFuel[v] = 100arr_Engine{v} = 1SetVehicleParamsEx(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.0SetVehicleParamsEx(v,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            }
            if(
arr_Engine{v} == 0SetVehicleParamsEx(v,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
    }

Where is the problem?
Reply
#2

Up Up Up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)