Fuel System
#1

Hello, I want to make every gas station to have maximum 5000 liters, also I made 3d text to show how many liters have the gas station, but where I am in the game and refill my car with 2 liters the 3d text does not change in 4998 but its standing in 5000.
Here's the codes:

Код:
new fuelstations;


public OnFilterScriptInit()
{
	fuelstations = 5000;
	new stringa[256];
        format(stringa,sizeof(stringa),"{0040FF}%d liters",fuelstations);
        Create3DTextLabel(stringa,0xE60000FF,1941.6099,-1764.9050,13.6406,40.0,0);
	return 1;
}


public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
 if(dialogid==FUELDIALOG && response)
 {
 if(VehicleFuel[GetPlayerVehicleID(playerid)]>=100) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}The vehicle is full with fuel.");
 if(strval(inputtext)<=0 || strval(inputtext)>100)  return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}Error: inserit a number between 0 and 100 liters.");
 if(VehicleFuel[GetPlayerVehicleID(playerid)]+ strval(inputtext) > 100.0) return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}You can't refill your vehicle with so many liters.");
 if(strval(inputtext) > fuelstations) return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}Gas station does not have as many liters of fuel.");
 VehicleFuel[GetPlayerVehicleID(playerid)]=VehicleFuel[GetPlayerVehicleID(playerid)]+strval(inputtext);
 fuelstations = fuelstations - strval(inputtext);
 GivePlayerMoney(playerid,-strval(inputtext)*5);
 return 1;
 }
 return 1;
}
Reply
#2

Each time you refill the car you need to update the 3d text on the FUELDIALOG
Reply
#3

So what is the function to update 3d text ?
Reply
#4

pawn Код:
Update3DTextLabelText(id,color,text);
You could have search on wiki x)
Reply
#5

Thanks StuffBoy, Working

Right here in this thread I'll ask another question.Now the codes as I do that by charging a gas station fuel in liters and to take from others and the question is how to do to take liters only station where the charge?

Sorry for my bad english :<
Reply
#6

Create a stock and check the coordinates of the gas stations by range points and discount the litre from the one where the player is.
Reply
#7

Your words are not help me.If codes you can do.
Here coordinates:

Код:
           if(IsPlayerInRangeOfPoint(playerid,15,1596.0629,2199.1621,10.8203) || IsPlayerInRangeOfPoint(playerid,15,2202.0964,2474.6543,10.8203) || IsPlayerInRangeOfPoint(playerid,15,2114.8044,919.7510,10.8203) ||
           IsPlayerInRangeOfPoint(playerid,15,2640.2517,1106.5508,10.8203) || IsPlayerInRangeOfPoint(playerid,15,2147.6653,2747.9827,10.8203) || IsPlayerInRangeOfPoint(playerid,15,-1471.7313,1864.0991,32.6328) ||
           IsPlayerInRangeOfPoint(playerid,15,-2410.8113,975.2512,45.4609) || IsPlayerInRangeOfPoint(playerid,15,-2244.1819,-2560.9412,31.9219) || IsPlayerInRangeOfPoint(playerid,15,1940.9292,-1772.8572,13.6406) ||
           IsPlayerInRangeOfPoint(playerid,15,-91.1604,-1169.3730,2.4222) || IsPlayerInRangeOfPoint(playerid,15,1004.6492,-936.6988,42.3281) || IsPlayerInRangeOfPoint(playerid,5,622.4417,1679.9636,6.9922) ||
           IsPlayerInRangeOfPoint(playerid,5,618.6267,1684.9540,6.9922) || IsPlayerInRangeOfPoint(playerid,5,615.3784,1689.7960,6.9922) || IsPlayerInRangeOfPoint(playerid,5,612.0988,1694.8252,6.9922) ||
           IsPlayerInRangeOfPoint(playerid,5,608.7755,1699.7362,6.9922) || IsPlayerInRangeOfPoint(playerid,5,605.2301,1704.7760,6.9922) || IsPlayerInRangeOfPoint(playerid,5,-1329.4805,2672.1658,50.0625) ||
           IsPlayerInRangeOfPoint(playerid,5,-1328.9458,2677.4929,50.0625) || IsPlayerInRangeOfPoint(playerid,5,-1328.1654,2682.8352,50.0625) || IsPlayerInRangeOfPoint(playerid,5,-1609.6621,-2718.2073,48.5391) ||
           IsPlayerInRangeOfPoint(playerid,5,-1606.3370,-2713.9016,48.5335) || IsPlayerInRangeOfPoint(playerid,5,-1603.2050,-2709.6497,48.5335) || IsPlayerInRangeOfPoint(playerid,10,1382.3110,460.1322,20.3452) ||
           IsPlayerInRangeOfPoint(playerid,20,-1675.7123,413.1389,7.1797))
Reply
#8

Your script does not support ids you need to make and enumeration to check what is the gas station where you refilling by coordinates and then remove the fuel from it using the enumeration.
Reply
#9

I made this:

Код:
new fuelstations;
new Text3D:fuels;

#define MAX_STATIONS 19
new Float:Stations[MAX_STATIONS][3]={
{1596.0629,2199.1621,10.8203},
{2202.0964,2474.6543,10.8203},
{2114.8044,919.7510,10.8203},
{2640.2517,1106.5508,10.8203},
{2147.6653,2747.9827,10.8203},
{-1471.7313,1864.0991,32.6328},
{-2410.8113,975.2512,45.4609},
{-2244.1819,-2560.9412,31.9219},
{1940.9292,-1772.8572,13.6406},
{-91.1604,-1169.3730,2.4222},
{1004.6492,-936.6988,42.3281},
{622.4417,1679.9636,6.9922 || 618.6267,1684.9540,6.9922 || 615.3784,1689.7960,6.9922 || 612.0988,1694.8252,6.9922 || 608.7755,1699.7362,6.9922 || 605.2301,1704.7760,6.9922},
{-1329.4805,2672.1658,50.0625 || -1328.9458,2677.4929,50.0625 || -1328.1654,2682.8352,50.0625},
{-1609.6621,-2718.2073,48.5391 || -1606.3370,-2713.9016,48.5335 || -1603.2050,-2709.6497,48.5335},
{1382.3110,460.1322,20.3452},
{-1675.7123,413.1389,7.1797},
{2325.1802,534.0493,1.2420},
{2781.0354,1770.6907,10.8203},
{85.9708,2542.7942,16.5446}
};

public OnFilterScriptInit()
{
        for(new i=0;i<MAX_STATIONS;i++)
        {
	     fuelstations[i] = 5000;
	}
	new stringa[256];
        format(stringa,sizeof(stringa),"{0040FF}%d liters,fuelstations);
        fuels = Create3DTextLabel(stringa,0xE60000FF,1941.6099,-1764.9050,13.6406,40.0,0);
	return 1;
}

public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
 if(dialogid==FUELDIALOG && response)
 {
 if(VehicleFuel[GetPlayerVehicleID(playerid)]>=100) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}The vehicle is full with fuel.");
 if(strval(inputtext)<=0 || strval(inputtext)>100)  return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}Error: inserit a number between 0 and 100 liters.");
 if(VehicleFuel[GetPlayerVehicleID(playerid)]+ strval(inputtext) > 100.0) return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}You can't refill your vehicle with so many liters.");
 if(strval(inputtext) > fuelstations) return SendClientMessage(playerid,0xFF0000FF,"{FFFFFF}Gas station does not have as many liters of fuel.");
 VehicleFuel[GetPlayerVehicleID(playerid)]=VehicleFuel[GetPlayerVehicleID(playerid)]+strval(inputtext);
 GivePlayerMoney(playerid,-strval(inputtext)*5);
 for(new i=0;i<MAX_STATIONS;i++)
 {
    if(IsPlayerInRangeOfPoint(playerid,20,Station[i][0],Station[i][1],Station[i][2]))
    {
    fuelstations[i] = fuelstations[i] - strval(inputtext);
    new stringa[256];
    format(stringa,sizeof(stringa),"{0040FF}%d liters",fuelstations);
    Update3DTextLabelText(fuels,0xE60000FF,stringa);
	}
  }
 return 1;
 }
 return 1;
}
And the errors is:

Код:
D:\_VIDEO FILMI\Нова папка (2)\Нова папка\Нова папка\0.3c\filterscripts\speedo.pwn(41) : error 028: invalid subscript (not an array or too many subscripts): "fuelstations"
D:\_VIDEO FILMI\Нова папка (2)\Нова папка\Нова папка\0.3c\filterscripts\speedo.pwn(41) : warning 215: expression has no effect
D:\_VIDEO FILMI\Нова папка (2)\Нова папка\Нова папка\0.3c\filterscripts\speedo.pwn(41) : error 001: expected token: ";", but found "]"
D:\_VIDEO FILMI\Нова папка (2)\Нова папка\Нова папка\0.3c\filterscripts\speedo.pwn(41) : error 029: invalid expression, assumed zero
D:\_VIDEO FILMI\Нова папка (2)\Нова папка\Нова папка\0.3c\filterscripts\speedo.pwn(41) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#10

Where's line 41?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)