How to do IsPlayerNearPlayer
#1

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.
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)