buying fuel issue
#1

whenever, i buy fuel from a gas station it takes the money away from me but then it resets back any ideas on i can fix this for me seems to be like a anti cheat system but i dont have any anti cheat yet..
Reply
#2

Code please
Reply
#3

Код:
CMD:fuel(playerid, params[])
{
	for(new i=1; i < MAX_FUEL_STATIONS; i++)
	{
		if(FuelStationCreated[i])
		{
			if(IsPlayerInRangeOfPoint(playerid, 15.0, FuelStationPos[i][0], FuelStationPos[i][1], FuelStationPos[i][2]))
			{
				SetPVarInt(playerid, "FuelStation", i);
				ShowDialog(playerid, DIALOG_FUEL);
				return 1;
			}
		}
	}
	SendClientMessage(playerid, COLOR_RED, "You are not in a fuel station!");
	return 1;
}

Код:
		case DIALOG_FUEL:
		{
			new info[128];
			strcat(info, "Refuel Vehicle  ($" #FUEL_PRICE ")\nBuy Gas Can  ($" #GAS_CAN_PRICE ")", sizeof(info));
			ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Fuel Station", info, "OK", "Cancel");
		}
Reply
#4

Is the second code you put the OnDialogResponse ? I can't see any "response" check and GivePlayerMoney ?!
Reply
#5

Yeah it is Macronix
Reply
#6

sorry for bumping but i really need this fixed. i know anti cheat makes this issue but i dont have any kind of anti cheat in my system.


EDIT: what happens is when i buy fuel the money goes down and back up again just like a reset..
Reply
#7

In code which you provided there aren't any functions which are related to changing money amount.
Reply
#8

Make sure you also set the player's Money value in the player array.
Reply
#9

this is the one am using can you please point out what i meant to be doing here i have no clue what u talking about money value stuff
https://sampforum.blast.hk/showthread.php?tid=276887


EDIT: i have this code below seems like the issue inside here maybe.

Код:
public MainTimer()
{
	new string[128];
	new Float:x, Float:y, Float:z;

	for(new i=0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
			{
				new vehicleid = GetPlayerVehicleID(i);
				if(!IsBicycle(vehicleid) && Fuel[vehicleid] > 0)
				{
					Fuel[vehicleid] -= GetPlayerSpeed(i)/1000.0;
					if(Fuel[vehicleid] <= 0)
					{
						ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
						GameTextForPlayer(i, "~r~out of fuel", 3000, 3);
						SendClientMessage(i, COLOR_RED, "This vehicle is out of fuel!");
					}
				}
			}
			if(RefuelTime[i] > 0 && GetPVarInt(i, "FuelStation"))
			{
				new vehicleid = GetPlayerVehicleID(i);
				Fuel[vehicleid] += 2.0;
				RefuelTime[i]--;
				if(RefuelTime[i] == 0)
				{
					if(Fuel[vehicleid] >= 100.0) Fuel[vehicleid] = 100.0;
					new stationid = GetPVarInt(i, "FuelStation");
					new cost = floatround(Fuel[vehicleid]-GetPVarFloat(i, "Fuel"))*FUEL_PRICE;
					if(GetPlayerState(i) != PLAYER_STATE_DRIVER || Fuel[vehicleid] >= 100.0 || GetPlayerMoney(i) < cost
					|| !IsPlayerInRangeOfPoint(i, 10.0, FuelStationPos[stationid][0], FuelStationPos[stationid][1], FuelStationPos[stationid][2]))
					{
						if(GetPlayerMoney(i) < cost) cost = GetPlayerMoney(i);
						GivePlayerMoney(i, -cost);
						format(string, sizeof(string), "~r~-$%d", cost);
						GameTextForPlayer(i, string, 2000, 3);
						format(string, sizeof(string), "You pay $%d for fuel", cost);
						SendClientMessage(i, COLOR_WHITE, string);
						SetPVarInt(i, "FuelStation", 0);
						SetPVarFloat(i, "Fuel", 0.0);
					}
					else
					{
						RefuelTime[i] = 5;
						format(string, sizeof(string), "~w~refueling...~n~~r~-$%d", cost);
						GameTextForPlayer(i, string, 2000, 3);
					}
				}
			}
			if(TrackCar[i])
			{
				GetVehiclePos(TrackCar[i], x, y, z);
				SetPlayerCheckpoint(i, x, y, z, 3);
			}
		}
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)