SA-MP Forums Archive
Near Player - 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)
+--- Thread: Near Player (/showthread.php?tid=632071)



Near Player - silverms - 08.04.2017

so don't ask why I need this but I need it I have made this thing so that it give me the near players from 100meters away from me but this give me 1 player what if I need to get all the players that are near me what should I do here is the code:
PHP код:
CMD:pnear(playeridparams[])
{
        new 
string[64], Float:tx[MAX_PLAYERS], Float:ty[MAX_PLAYERS], Float:tz[MAX_PLAYERS], tname[MAX_PLAYER_NAME];
        if(
adlvl(playerid) <5) return 0;
        
SendClientMessage(playeridCOLOR_YELLOW"* Listing all Player(s) within 100 meters of you...");
        for(new 
i=1i<MAX_PLAYERS i++)
        {
            
GetPlayerPos(itx[i], ty[i], tz[i]);
            if(
IsPlayerInRangeOfPoint(playerid100.0tx[i], ty[i], tz[i]) && i!=playerid)
            {
                
GetPlayerName(itnamesizeof(tname));
                
format(stringsizeof(string), "Playerid: %d | Name: %s"itname);
                
SendClientMessage(playeridCOLOR_WHITEstring);
            }
        }
        return 
1;




Re: Near Player - LazzyBoy - 08.04.2017

Код:
GetPlayerPos(playerid,tx[i], ty[i], tz[i]);// First get player's pos 
if(IsPlayerInRangeOfPoint(i, 100.0, tx[i], ty[i], tz[i]) &&  i!=playerid) // loop throught all players that are near that pos
      {
not sure if it is what you wanted but give it a try.


Re: Near Player - silverms - 09.04.2017

no what I want is when it format the string it format It with all the players that are around nor only one


Re: Near Player - LazzyBoy - 09.04.2017

Код:
format(string, sizeof(string), "%s Playerid: %d | Name: %s",string, i, tname);
Not sure if this works for SendClientMessage but it works with GameText since im using that.


Re: Near Player - Threshold - 09.04.2017

PHP код:
CMD:pnear(playeridparams[])
{
    if(
adlvl(playerid) < 5) return 0;
    new 
string[48], Float:txFloat:tyFloat:tztname[MAX_PLAYER_NAME];
    
SendClientMessage(playeridCOLOR_YELLOW"* Listing all Player(s) within 100 meters of you...");
    
GetPlayerPos(playeridtxtytz);
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(!
IsPlayerConnected(i) || == playerid) continue;
        if(
GetPlayerDistanceFromPoint(itxtytz) < 100.0)
        {
            
GetPlayerName(itnamesizeof(tname));
            
format(stringsizeof(string), "Playerid: %d | Name: %s"itname);
            
SendClientMessage(playeridCOLOR_WHITEstring);
        }
    }
    return 
1;