Code not working(IsPlayerInRangeOfPoint)
#1

Why is this code not working?
When i press the ENTER(F) key i get the message "You pressed KEY_SECONDARY_ATTACK" but my position does not change!

Код:
if (newkeys & KEY_SECONDARY_ATTACK)
	{
		SCM(playerid, -1, "You pressed KEY_SECONDARY_ATTACK");
		if(IsPlayerInRangeOfPoint(playerid, 4.0, 389.8058,173.8332,1008.3828))//Vijecnica Izlaz
		{
			SetPlayerPos(playerid, 1481.0699,-1772.3137,18.7958);
			SetPlayerInterior(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 1554.62,-1675.63,16.20))//PD Ulaz
		{
			SetPlayerPos(playerid, 246.79,63.21,1003.64);
			SetPlayerInterior(playerid, 6);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 246.79,63.21,1003.64))//PD Izlaz
		{
			SetPlayerPos(playerid, 1554.62,-1675.63,16.20);
			SetPlayerInterior(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 1464.9257,-1010.6413,26.8438))//Banka Ulaz
		{
			SetPlayerPos(playerid, 2305.7893,-16.1171,26.7496);
			SetPlayerInterior(playerid, 0);
			SetPlayerVirtualWorld(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 2305.7893,-16.1171,26.7496))//Banka Izlaz
		{
			SetPlayerPos(playerid, 1464.9257,-1010.6413,26.8438);
			SetPlayerInterior(playerid, 0);
			SetPlayerVirtualWorld(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 2495.3174,-1690.3535,14.7656) && PlayerInfo[playerid][Clan] == 7 || IsPlayerInRangeOfPoint(playerid, 1.0, 2495.3174,-1690.3535,14.7656) && PlayerInfo[playerid][Lider] == 7)//GSF Ulaz
		{
			SetPlayerPos(playerid, 2496.049804,-1695.238159,1014.742187);
			SetPlayerInterior(playerid, 3);
			SetPlayerVirtualWorld(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 2496.049804,-1695.238159,1014.742187) && PlayerInfo[playerid][Clan] == 7 || IsPlayerInRangeOfPoint(playerid, 1.0, 2496.049804,-1695.238159,1014.742187) && PlayerInfo[playerid][Lider] == 7)//GSF Izlaz
		{
			SetPlayerPos(playerid, 2495.3174,-1690.3535,14.7656);
			SetPlayerInterior(playerid, 0);
			SetPlayerVirtualWorld(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 2439.5942,-1338.8033,24.1016) && PlayerInfo[playerid][Clan] == 8 || IsPlayerInRangeOfPoint(playerid, 1.0, 2439.5942,-1338.8033,24.1016) && PlayerInfo[playerid][Lider] == 8)//ESL Ulaz
		{
			SetPlayerPos(playerid, 318.564971,1118.209960,1083.882812);
			SetPlayerInterior(playerid, 5);
			SetPlayerVirtualWorld(playerid, 0);
		}
		if(IsPlayerInRangeOfPoint(playerid, 1.0, 318.564971,1118.209960,1083.882812) && PlayerInfo[playerid][Clan] == 8 || IsPlayerInRangeOfPoint(playerid, 1.0, 318.564971,1118.209960,1083.882812) && PlayerInfo[playerid][Lider] == 8)//ESL  Izlaz
		{
			SetPlayerPos(playerid, 2439.5942,-1338.8033,24.1016);
			SetPlayerInterior(playerid, 0);
			SetPlayerVirtualWorld(playerid, 0);
		}
        }
Reply
#2

Change your code to this, this will tell you (if I'm correct in your problem) that your not in the 1.0 range of any of those spots.

pawn Код:
if (newkeys & KEY_SECONDARY_ATTACK)
    {
        SCM(playerid, -1, "[DEBUG] You pressed KEY_SECONDARY_ATTACK");
        if(IsPlayerInRangeOfPoint(playerid, 4.0, 389.8058,173.8332,1008.3828))//Vijecnica Izlaz
        {
            SetPlayerPos(playerid, 1481.0699,-1772.3137,18.7958);
            SetPlayerInterior(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 1554.62,-1675.63,16.20))//PD Ulaz
        {
            SetPlayerPos(playerid, 246.79,63.21,1003.64);
            SetPlayerInterior(playerid, 6);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 246.79,63.21,1003.64))//PD Izlaz
        {
            SetPlayerPos(playerid, 1554.62,-1675.63,16.20);
            SetPlayerInterior(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 1464.9257,-1010.6413,26.8438))//Banka Ulaz
        {
            SetPlayerPos(playerid, 2305.7893,-16.1171,26.7496);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2305.7893,-16.1171,26.7496))//Banka Izlaz
        {
            SetPlayerPos(playerid, 1464.9257,-1010.6413,26.8438);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2495.3174,-1690.3535,14.7656) && PlayerInfo[playerid][Clan] == 7 || IsPlayerInRangeOfPoint(playerid, 1.0, 2495.3174,-1690.3535,14.7656) && PlayerInfo[playerid][Lider] == 7)//GSF Ulaz
        {
            SetPlayerPos(playerid, 2496.049804,-1695.238159,1014.742187);
            SetPlayerInterior(playerid, 3);
            SetPlayerVirtualWorld(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2496.049804,-1695.238159,1014.742187) && PlayerInfo[playerid][Clan] == 7 || IsPlayerInRangeOfPoint(playerid, 1.0, 2496.049804,-1695.238159,1014.742187) && PlayerInfo[playerid][Lider] == 7)//GSF Izlaz
        {
            SetPlayerPos(playerid, 2495.3174,-1690.3535,14.7656);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2439.5942,-1338.8033,24.1016) && PlayerInfo[playerid][Clan] == 8 || IsPlayerInRangeOfPoint(playerid, 1.0, 2439.5942,-1338.8033,24.1016) && PlayerInfo[playerid][Lider] == 8)//ESL Ulaz
        {
            SetPlayerPos(playerid, 318.564971,1118.209960,1083.882812);
            SetPlayerInterior(playerid, 5);
            SetPlayerVirtualWorld(playerid, 0);
        }
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 318.564971,1118.209960,1083.882812) && PlayerInfo[playerid][Clan] == 8 || IsPlayerInRangeOfPoint(playerid, 1.0, 318.564971,1118.209960,1083.882812) && PlayerInfo[playerid][Lider] == 8)//ESL  Izlaz
        {
            SetPlayerPos(playerid, 2439.5942,-1338.8033,24.1016);
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
                          else
                          {
            SCM(playerid, -1, "[DEBUG] You are not in a 1.0 range of any teleport points!");
                          }

        }
Reply
#3

The coordinates of the entrance are same as the checkpoint ones and i m standing on the checkpoint!
Reply
#4

jakejohnsonusa you code will never work because you use "if" in every IsPlayerInRangeOfPoint not "else if"

Anyway, add a debug ( https://sampwiki.blast.hk/wiki/Debugging ) to see if IsPlayerInRangeOfPoint return true and the problem is another, or the code dont detect you in any of IsPlayerInRangeOfPoint places.
Reply
#5

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
jakejohnsonusa you code will never work because you use "if" in every IsPlayerInRangeOfPoint not "else if"

Anyway, add a debug ( https://sampwiki.blast.hk/wiki/Debugging ) to see if IsPlayerInRangeOfPoint return true and the problem is another, or the code dont detect you in any of IsPlayerInRangeOfPoint places.
Actually, you're wrong. The code will work even if it has "if" or "else if". A player cannot be in more than 1 place at the same time, so one of them will be called. However, you're correct on the debugging. He can debug his code to make sure if he's actually in range of point or not.
Reply
#6

IsPlayerInRangeOfPoint() is for chumps dynamic areas is the way to go these days
Reply
#7

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Actually, you're wrong. The code will work even if it has "if" or "else if". A player cannot be in more than 1 place at the same time, so one of them will be called. However, you're correct on the debugging. He can debug his code to make sure if he's actually in range of point or not.
will obtain the last msg only if the last will fail, in this case it's surely correct he cant be in more than 1 place, mine was just a suggestion for other cases
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)