Command says Im not near a vehicle.
#1

I am trying to make it so when these 3 factions are near a vehicle they can access the factions locker.
When I am standing on the vehicle evan it says Im not near the vehicle.
Anyone that can help?
Thanks

Here is the code:
Код:
CMD:trunk(playerid, params[])
{
	new Float:X, Float:Y, Float:Z;
	for(new a = 0; a < MAX_VEHICLES; a++)
	{
		GetVehiclePos(a, X, Y, Z);
		if(IsPlayerInRangeOfPoint(a, 5.0, X+5, Y, Z))
		{
		    if(PlayerInfo[playerid][pFaction] == 1)
		    {
		        ShowPlayerDialog(playerid, DIALOG_LSPD, DIALOG_STYLE_LIST, "Locker", "Duty\nEquipment\nUniform\nSelect Skin", "Ok", "Close");
				return 1;
		    }
		    if(PlayerInfo[playerid][pFaction] == 2)
		    {
                ShowPlayerDialog(playerid, DIALOG_FBI, DIALOG_STYLE_LIST, "Locker", "Duty\nEquipment\nUniform\nSelect Skin\nChange Name", "Ok", "Close");
				return 1;
		    }
            if(PlayerInfo[playerid][pFaction] == 3)
		    {
                ShowPlayerDialog(playerid, DIALOG_LAFMD, DIALOG_STYLE_LIST, "Locker", "Duty\nEquipment\nUniform", "Ok", "Close");
				return 1;
		    }
		    else return SendClientMessage(playerid, COLOR_GREY, "You are not in a faction.");
		}
		else return SendClientMessage(playerid, COLOR_GREY, "You are not near a vehicle.");
	}
	return 1;
}
Reply
#2

Hi, You have an error on your IsPlayerInRangeOfPoint line, you're checking to see if playerID "a"(a is the var that is used in the vehicle loop so the server will be trying to find out if playerid 345 is near the vehicle but instead you want the playerid that used that command).

Change if(IsPlayerInRangeOfPoint(a, 5.0, X+5, Y, Z))

to if(IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z))

It should work now that the server is checking if that player id is close to that vehicle.

Hopefully that does the trick - Hayden.
Reply
#3

Nope still same problem .
Still says I am not near a vehicle
Reply
#4

Oh sorry mate, I'm not quite sure what else would be causing it, you could try making the range larger? see if that affects anything then lower it to what you want.

Is MAX_VEHICLES high enough?

Other than that I don't have any other ideas, good luck with the script .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)