Kick all CMD
#1

Hey,

How can i make a kickall command that only kicks non admin players?

Thanks inadvance
Reply
#2

Untested:

pawn Код:
if(!strcmp(cmdtext, "/kickall", true, 8))
{
    for(new i = 0; i < MAX_PLAYERS; i++))
    {
        if(!IsPlayerAdmin(i))
        {
            if(IsPlayerConnected(i))
            {
                SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin.");

                Kick(i);

                return 1;
               
            } else return SendClientMessage(playerid,-1,"There Are No Players Connected.");
        }
    }
}
Reply
#3

pawn Код:
if(!strcmp("/kickall", cmdtext, true))
    {
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(pInfo[i][pLevel] < 1)
            {
                    if(IsPlayerConnected(i))
                    {
                    Kick(i);
                     }
        }
    }
       
        return 1;
    }
very simple and easy, you cann add some more stuff like messages and stuff...
just remmeber that after the loop and after the pLevel if statment i represents every player that hasn't got an admin level.
also change the pLevel array into the array that u use for your admin level

EDIT: damn u poster above!, like ur name btw
Reply
#4

Thank you
Reply
#5

You people check if the person is an administrator before even checking if the person is connected, pointless.

Plus that Otto guys code will break the loop if one player isn't connected.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)