Multiple IsPlayerInRangeOfPoint
#1

pawn Код:
//first gate
        if(IsPlayerInRangeOfPoint(playerid, 5.0, -363.6000100,932.7000100,12.2000000))
        {
                     SendClientMessage(playerid, -1, "lel!!!!!!!!!!!!!!!");
        }
        else
        {
                     SendClientMessage(playerid, -1, "le!!!!!!!!!!!!!!l");
        }
//second gate
        if(IsPlayerInRangeOfPoint(playerid, 5.0, -449.7998000,897.7998000,5.0000000))
        {
                     SendClientMessage(playerid, -1, "lel!!!!!");
        }
                else
                {
                     SendClientMessage(playerid, -1, "lel");
                }
I did put this on my OnPlayerUpdate, how do I check multiple IsPlayerInRangeOfPoint?
I can't do it on using the statement "else" on OnPlayerUpdate.
Reply
#2

Simply use a traditionnal "or" ("||")

PHP код:

if(IsPlayerInRangeOfPoint(playerid5.0, -363.6000100,932.7000100,12.2000000) || IsPlayerInRangeOfPoint(playerid5.0, -449.7998000,897.7998000,5.0000000)) return SCM(playerid, -1"you're in a 5.0 unities range of a gate !"); 
But for multiple checks, get prepared to a "input line too long (after subsitution)" error.
Reply
#3

A global timer that loops through connected players (foreach) and checks if each player is in range will be much better than using OPU callback.

If you want to do the same thing when the player is in range of one of those:
pawn Код:
// an example:
if (IsPlayerInRangeOfPoint(playerid, range, x, y, z)
    || IsPlayerInRangeOfPoint(playerid, range, x, y, z)
    || IsPlayerInRangeOfPoint(playerid, range, x, y, z)
    || IsPlayerInRangeOfPoint(playerid, range, x, y, z)
    || IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
If you want to check for different points and do different things:
pawn Код:
// an example:
if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
else if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
else if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
Reply
#4

Okay, my point is like Konstantinos said, checking for different points and do different things. My thing is, I have multiple gates.
pawn Код:
if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
else if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
else if (IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
    // code..
}
Yes, I can do this, but the problem is, what if they're not in range anymore? How do I reclose them?
Reply
#5

Then check for the inverse condition no ?

When your public function is called again by the timer, simply check for the inverse condition.

For example, with your coordinates above,

PHP код:

new closed[MAX_GATES] = true;
if(
IsPlayerInRangeOfPoint(playerid5.0, -449.7998000,897.7998000,5.0000000) && closed[i]) { /* Open the gate */ }
else { 
/* Close the gate */ 
i stands for the gate id the player is near of.

It's not harder than this.
Reply
#6

What if it mixed up?
Reply
#7

Add a boolean variable whichs checks the tate of the door : opened or closed.

Then check it before moving the door object (I think you'll use Move(Dynamic)Object). If it's opened and the player is near of the door, return 1.
If it's not open but the player is near of the door, open it.
If it's open but the player isn't near of the door, close it.
Reply
#8

Sounds it'll work. Let me PM you if I have another problem.
Thanks,guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)