Is there a callback like..
#1

IsPlayerInRangeOfPoint

That is callend ONCE when a player ENTERS a the range..
Else, can somebody make it maybe?
Or explain how.

thanks!
Reply
#2

That's samp function.
Reply
#3

Not a function, callback, and when he enters, it need to called once, and when he exit and enters again, called once.
Reply
#4

Just make a timer, for example 1 seconds, which loops through all players, and check if their position is in range of the point.
Edit: added non-tested code for base
pawn Code:
#define COORD 0.0, 0.0, 10.0
#define RANGE 10.5
#deinfe CHECK_INTERVAL 1000 // ms

new bool:isplayerinrange[MAX_PLAYERS] = {false,...};

forward RangeTimer();
forward OnPlayerEnterIRP(playerid);
forward OnPlayerLeaveIRP(playerid);

public RangeTimer()
{
    foreach(Player, i)
    {
        if (IsPlayerInRangeOfPoint(i, RANGE, COORD))
        {
            if (isplayerinrange[i]) continue;
            isplayerinrange[i] = true;
            CallRemoteFunction("OnPlayerEnterIRP", "i", playerid);
        }
        else
        {
            if (!isplayerinrange[i]) continue;
            isplayerinrange[i] = false;
            CallRemoteFunction("OnPlayerLeaveIRP", "i", playerid);
        }
    }
}

public OnFilterScriptInit()
{
    SetTimer("RangeTimer", CHECK_INTERVAL, 1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    isplayerinrange[playerid] = false;
}
Reply
#5

Just make a timer or use OnPlayerUpdate.
Reply
#6

DO NOT use OnPlayerUpdate for this.
Reply
#7

Fixed, thanks
Reply
#8

Quote:
Originally Posted by wouter0100
View Post
Fixed, thanks
NO!, bugs pls

pawn Code:
#define COORD 0.0, 0.0, 10.0
#define RANGE 10.5
#deinfe CHECK_INTERVAL 1000 // ms

new bool:isplayerinrange[MAX_PLAYERS] = {false,...};

forward RangeTimer();
forward OnPlayerEnterIRP(playerid);
forward OnPlayerLeaveIRP(playerid);

public RangeTimer()
{
    foreach(Player, i)
    {
        if (IsPlayerInRangeOfPoint(i, RANGE, COORD))
        {
            if (isplayerinrange[i]) continue;
            isplayerinrange[playerid] = true;
            CallRemoteFunction("OnPlayerEnterIRP", "i", playerid);
        }
        else
        {
            if (!isplayerinrange[i]) continue;
            isplayerinrange[playerid] = false;
            CallRemoteFunction("OnPlayerLeaveIRP", "i", playerid);
        }
    }
}

public OnFilterScriptInit()
{
    SetTimer("RangeTimer", CHECK_INTERVAL, 1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    isplayerinrange[playerid] = false;
    return 1;
}
Reply
#9

erm you're right. I just forgot those.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)