SA-MP Forums Archive
Get everyone except playerid - 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: Get everyone except playerid (/showthread.php?tid=572263)



Get everyone except playerid - Lirbo - 26.04.2015

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;}



Re : Get everyone except playerid - StreetRP - 26.04.2015

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;}


Re: Re : Get everyone except playerid - Lirbo - 26.04.2015

Quote:
Originally Posted by StreetRP
Посмотреть сообщение
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;}
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.


Re: Get everyone except playerid - TakeiT - 26.04.2015

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.


Re: Get everyone except playerid - Evocator - 26.04.2015

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);
    }
}



Re: Get everyone except playerid - Konstantinos - 26.04.2015

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)!