Near Player
#1

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;

Reply
#2

Код:
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.
Reply
#3

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

Код:
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.
Reply
#5

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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)