Help with IsPlayerInRangeOfPoint
#1

This is a line in my duty system for the FD, For some reason I always get "You are not at the Firemen Lockers!" even when I am on the points that should make me on duty. Whats wrong and how can I fix this?

Here is the code:
pawn Код:
else if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12)
            {
                if (!IsPlayerInRangeOfPoint(playerid, 3.0, 2811.7837,-1167.3248,1025.5703) || !IsPlayerInRangeOfPoint(playerid, 3.0, 1924.24,-1876.71,12.94))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "You are not at the Firemen Lockers!");
                    return 1;
                }
                if(JobDuty[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "* You are now Off Duty from your Firemen Job and will not receive calls anymore.");
                    JobDuty[playerid] = 0;
                    SetPlayerColor(playerid, TEAM_HIT_COLOR);
                    SafeResetPlayerWeapons(playerid);
                    new originalskin = PlayerInfo[playerid][pModel];
                    SetPlayerSkin(playerid, originalskin);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_WHITE, "* You are now On Duty with your Firemen Job and will receive calls from people in need.");
                    JobDuty[playerid] = 1;
                    SetPlayerColor(playerid, 0xAA333300);
                    SafeGivePlayerWeapon(playerid, 42, 2500);
                    SafeGivePlayerWeapon(playerid, 6, 1);

                    new rand = random(2)//change it to the number of skins you want
                    switch(rand)
                    {
                    case 0: SetPlayerSkin(playerid, 277);
                    case 1: SetPlayerSkin(playerid, 278);
                    }
                }
            }
PS: When I removed the "!" to test the points, they worked perfectly... But whats wrong now!?!?

Thanks: jakejohnsonusa
Reply
#2

I can't see anything wrong, are you sure it's not factionwise, rather than lockers?
Reply
#3

Your if condition is meant to check if the player is at one of those two spots or not, therefore you should replace the || with &&. So that if the player is not any of those, a message will be sent and that's it.

pawn Код:
if (!IsPlayerInRangeOfPoint(playerid, 3.0, 2811.7837,-1167.3248,1025.5703) && !IsPlayerInRangeOfPoint(playerid, 3.0, 1924.24,-1876.71,12.94))
Reply
#4

OH!

So "&&" means one of the options, and "||" means both the options. Yea, I only wanted one them to be at one of these points at a time.

Thanks for the help guys,
+1 Rep
Reply
#5

Wait what? && means AND, and || means OR.
Don't mix these two or you will have more scripts that will fail.
Reply
#6

Oh, So wasn't I right then with my script at the beggining?

By using || to check if they were at one of the positions?
Reply
#7

U got me confused for a second but I figured it out,

Nah basically, your code translated to english would be:
if the player is not at xyz1 or if the player is not at xyz2
send error message
the'is not' thing is because of the '!' mark infront of the function.
Reply
#8

Yes, but why do I always get the error message? Even when I am at one of the points?
Reply
#9

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
Yes, but why do I always get the error message? Even when I am at one of the points?
Because you're using ||, so if you're at one of these points, the other one is still negative. In this case you should use &&. Then the condition won't be true anymore if you're at one of these points. I got confused too. LOL
Reply
#10

LOL thanks guys.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)