Get everyone except playerid
I want to get everyone except the player who using the command, how can i do this?

pawn Код:
`if (newkeys & KEY_CTRL_BACK){    if(YellowFish[playerid]){    for(new i=0;i<MAX_PLAYERS;i++){    GetPlayerPos(playerid,pX,pY,pZ);    if(IsPlayerInRangeOfPoint(i,7,pX,pY,pZ)){GivePlayerHealth(i,-5);}}}    return 1;}`
if (newkeys & KEY_CTRL_BACK){
if(YellowFish[playerid]){
for(new i=0;i<MAX_PLAYERS;i++){
if(i != playerid) {
GetPlayerPos(playerid,pX,pY,pZ);
if(IsPlayerInRangeOfPoint(i,7,pX,pY,pZ)){GivePlaye rHealth(i,-5);}}}}
return 1;}
Quote:
 Originally Posted by StreetRP if (newkeys & KEY_CTRL_BACK){ if(YellowFish[playerid]){ for(new i=0;i
ye very smart, if
pawn Код:
`i != playerid`
so it will cancel whole the function, i mean, it's won't damage the others too cause the playerid is around.
your indentations are giving me a stroke.

pawn Код:
`if (newkeys & KEY_CTRL_BACK){    if(YellowFish[playerid])    {        for(new i=0; i<MAX_PLAYERS; i++)        {            GetPlayerPos(playerid,pX,pY,pZ);            if(IsPlayerInRangeOfPoint(i,7,pX,pY,pZ) && i != playerid) GivePlayerHealth(i,-5);        }    }    return 1;}`
That should work.
Jesus Christ!
Wont you even check if the player is connected before getting the postion?

Код:
```for(new i = 0; i != MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i))
continue;

if (playerid == i)
continue;

GetPlayerPos(playerid, pX, pY, pZ);

if(IsPlayerInRangeOfPoint(i, 7, pX, pY, pZ)) {
GivePlayerHealth(i, -5);
}
}```
Two suggestions though; get the position of "playerid" outside of the loop and use foreach instead as it loops through connected ONLY players (much faster)!

Forum Jump: