Stealfuel - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stealfuel (
/showthread.php?tid=446619)
Stealfuel -
RALL0 - 26.06.2013
Hey guys, I got this command called /stealfuel it's working fine but I wonder how can I make it limited? Like that the gascan can only contain 20 fuel and can get the maximum out of a vehicle for example if the vehicle got 10 fuel that the gascan gains 10 fuel instead 20. I hope you get what I mean.
Here are the codes
pawn Код:
CMD:stealfuel(playerid, params[])
{
if(PlayerInfo[playerid][pScrewdriver] == 1 && PlayerInfo[playerid][pCan] == 1 && PlayerInfo[playerid][pHosePipe] == 1)
{
new closestcar = GetClosestCar(playerid);
if(IsPlayerNearVehicle(playerid, closestcar, 7.0))
{
if(Fuel[closestcar] == 0)
{
SendClientMessage(playerid, COLOR_YELLOW,"This vehicle is out of fuel.");
}
else if(Fuel[closestcar] > 0)
{
if(PlayerInfo[playerid][pCanFuel] == 20) return SendClientMessage(playerid, COLOR_YELLOW,"Your gascan is full.");
PlayerInfo[playerid][pCanFuel] += ;
Fuel[closestcar] -= ;
}
else
{
SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You aren't near any vehicle.");
}
}
else
{
SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}Make sure you got a gascan, hosepipe and a screwdriver in order to steal fuel.");
}
return 1;
}
Re: Stealfuel -
Pottus - 26.06.2013
pawn Код:
else if(Fuel[closestcar] > 0)
{
if(PlayerInfo[playerid][pCanFuel] == 20) return SendClientMessage(playerid, COLOR_YELLOW,"Your gascan is full.");
new Float:FillAmount = 20 - PlayerInfo[playerid][pCanFuel];
if((Fuel[closestcar] - FillAmount) < 0)
{
PlayerInfo[playerid][pCanFuel] += Fuel[closestcar];
Fuel[closestcar] = 0.0;
}
else
{
PlayerInfo[playerid][pCanFuel] += FillAmount;
Fuel[closestcar] -= FillAmount;
}
}
Re: Stealfuel -
RALL0 - 26.06.2013
I don't get it it once I stealfuel from a vehicle with 10 fuel, it tells me that my gascan contains 11025631 fuel.
Re: Stealfuel -
Pottus - 26.06.2013
Ahh your fuel is probably not a float then you'll need to update it a bit.
Re: Stealfuel -
RALL0 - 26.06.2013
The fuel is actually a float
pawn Код:
new Float:Fuel[MAX_VEHICLES] = {100.0, ...};
Re: Stealfuel -
RALL0 - 26.06.2013
Oh yea, I see what I did wrong, like you just said %d are providing weird values and thats exactly what I used to see the amount of gas. Thanks both for helping me out on this one