Every Gas Station
#1

Hello, I made every gas station to have maximum 5000 liters, but 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?
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;
}
And here's all cordinates for Gas Stations:
Код:
{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}
Reply
#2

That if statement is just so messy, why not put all of the co-ordinates in an array and loop through them when you want to check? Although it kinda looks like that's what the original poster was trying to do, he has some weird syntax in his array. Here is an example of how you can do it:

pawn Код:
new Float: station_positions[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}
};

IsPlayerAtFuelStation(playerid)
{
    for(new i; i < sizeof(station_positions); i++)
        if(IsPlayerInRangeOfPoint(playerid, 5.0, station_positions[0][i], station_positions[1][i], station_positions[2][i])) return 1;
    return 0;
}
You can see more information about the IsPlayerInRangeOfPoint function here:

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)