SA-MP Forums Archive
How to do IsPlayerNearPlayer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to do IsPlayerNearPlayer (/showthread.php?tid=273165)



How to do IsPlayerNearPlayer - Harry_Sandhu - 31.07.2011

I want to make a /pay command and whisper command but i dont know how to Add this IsPlayerNearPlayer

means The player should be near the Player For using these commands.


Re: How to do IsPlayerNearPlayer - Toreno - 31.07.2011

IsPlayerInRangeOfPoint is a ready function for such things.
Here you go;
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint


Re: How to do IsPlayerNearPlayer - wups - 31.07.2011

pawn Код:
stock IsPlayerNearPlayer(player1,player2,Float:distance)
{
   new:Coo[3];
   GetPlayerPos(player1,Coo[0],Coo[1],Coo[2]);
   return IsPlayerInRangeOfPoint(player2,distance,Coo[0],Coo[1],Coo[2]);
}
Distance should be 5-10.


Re: How to do IsPlayerNearPlayer - Toreno - 31.07.2011

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
stock IsPlayerNearPlayer(player1,player2,Float:distance)
{
   new:Coo[3];
   GetPlayerPos(player1,Coo[0],Coo[1],Coo[2]);
   return IsPlayerInRangeOfPoint(player2,distance,Coo[0],Coo[1],Coo[2]);
}
Distance should be 5-10.
Nice way... wups, shorter and easier, add this to Useful Functions.


Re: How to do IsPlayerNearPlayer - iPLEOMAX - 31.07.2011

pawn Код:
CMD:whisper( playerid, cmdtext[] )
{
    new name[MAX_PLAYER_NAME], message[128];
    if(sscanf(cmdtext, "s[128]", message)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /whisper [message]");
    GetPlayerName(playerid, name, sizeof(name));
    format(message, sizeof(message), "%s whispering: %s..", name, message);
    new N, Float:Pos[3]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    for(new i=0; i<MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i,5,Pos[0],Pos[1],Pos[2]))
            {
                N++;
                SendClientMessage(i, 0x00FFFFFF, message);
            }
        }
    }
    if(N == 1) SendClientMessage(playerid, 0xFFFF00FF, "No player is close enough to listen..");
    return true;
}
untested.