Is there a callback like.. -
wouter0100 - 01.09.2011
IsPlayerInRangeOfPoint
That is callend ONCE when a player ENTERS a the range..
Else, can somebody make it maybe?
Or explain how.
thanks!
Re: Is there a callback like.. -
=WoR=Varth - 01.09.2011
That's samp function.
Re: Is there a callback like.. -
wouter0100 - 01.09.2011
Not a function, callback, and when he enters, it need to called once, and when he exit and enters again, called once.
Re: Is there a callback like.. -
KoczkaHUN - 01.09.2011
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;
}
Re: Is there a callback like.. -
=WoR=Varth - 01.09.2011
Just make a timer or use OnPlayerUpdate.
Re: Is there a callback like.. -
KoczkaHUN - 01.09.2011
DO NOT use OnPlayerUpdate for this.
Re: Is there a callback like.. -
wouter0100 - 01.09.2011
Fixed, thanks
Re: Is there a callback like.. -
Kar - 01.09.2011
Quote:
Originally Posted by wouter0100
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;
}
Re: Is there a callback like.. -
KoczkaHUN - 01.09.2011
erm you're right. I just forgot those.