Is player near a player & more.
#1

Hello, I want to know how to check is player near a player for some commands like give, pay and similar.
Also how can I make that only the players that are near a player can see his messages, I've been trying to find that everywhere but I can't.

I tried this:
Код:
new id;
GetPlayerPos(id, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, id, 3.0))
{
        //EXAMPLE
}
but it doesn't work.
If anybody has a filterscript or something, I would be very thankful.

Thank you for any kind of help.
Reply
#2

PHP код:
CMD:message(playerid,params[])
{
   new 
text[32];
   if(
sscanf(params,"s[32]",text)) return SendClientMessage(playerid,-1,"/message [message]");
   new 
Float:x,Float:y,Float:z;
   
GetPlayerPos(playerid,x,y,z);
   new 
pName[24];
   
GetPlayerName(playerid,pName,sizeof(pName));
   new 
string[250];
   
format(string,sizeof(string),"[MESSAGE] %s[%d]: %s",pName,playerid,text);
   for(new 
i=0;i<=MAX_PLAYERS;i++)  // Looping through MAX PLAYERS
   
{
    if(
IsPlayerInRangeOfPoint(i,15.0,x,y,z)) return SendClientMessage(i,-1,string); // sending the message to the nearest player , between 15 metres.
   
}
 return 
1;

An example, which sends the message to the nearest player,
Reply
#3

Ok, thank you. I'll try to adjust that to OnPlayerText.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)