How to kick all except playerid
#1

How would i kick every player in server except the person who types the command?
I was thinking something like this Kick(i); using that max players thingy,
But wouldnt that kick the person who typed the command aswell?
Reply
#2

if(i != playerid)
.........
Reply
#3

And that will do?
Reply
#4

pawn Код:
if(!strcmp(cmdtext, "/command")) {
  for(new i; i<MAX_PLAYERS; i++) {
    if(i != playerid) {
      Kick(i);
     }
     SendClientMessage(playerid, 0xFFFFFFFF, "You kicked all players except you!");
  }
  return true;
}
Reply
#5

How would i make it so it also dosent kick level 5 and over admins?

Format is: [b]PlayerInfo[IDHERE][AdminLevel]
Reply
#6

Quote:
Originally Posted by thiaZ_
pawn Код:
if(!strcmp(cmdtext, "/command")) {
  for(new i; i<MAX_PLAYERS; i++) {
    if(i != playerid) {
    if(PlayerInfo[i][AdminLevel] != 5){
      Kick(i);
     }}
     SendClientMessage(playerid, 0xFFFFFFFF, "You kicked all players except you!");
  }
  return true;
}
modified
Reply
#7

just change this code to whatever u want and change this to the way u define max admin level :

if(IsPlayerConnected(i) && (i != playerid) && i != ServerInfo[MaxAdminLevel]) {


Код:
dcmd_kickall(playerid,params[]) {
  #pragma unused params
	if(IsPlayerAdmin(playerid)) {
	  	for(new i = 0; i < MAX_PLAYERS; i++) {
			if(IsPlayerConnected(i) && (i != playerid) && i != ServerInfo[MaxAdminLevel]) {
				PlayerPlaySound(i,1057,0.0,0.0,0.0); Kick(i);
			}
		}
		new string[128]; format(string,sizeof(string),"Administrator \"%s\" has kicked all players", pName(playerid) );
		return SendClientMessageToAll(blue, string);
	} else return SendClientMessage(playerid,red,"ERROR: You Aren't Rcon Admin");
}
Reply
#8

Quote:
Originally Posted by adsy
Quote:
Originally Posted by thiaZ_
pawn Код:
if(!strcmp(cmdtext, "/command")) {
  for(new i; i<MAX_PLAYERS; i++) {
    if(i != playerid) {
    if(PlayerInfo[i][AdminLevel] != 5){
      Kick(i);
     }}
     SendClientMessage(playerid, 0xFFFFFFFF, "You kicked all players except you!");
  }
  return true;
}
modified
And that will not kick people who are level 5 admin and over?
Reply
#9

i tried the code i gave u many times and it didnt kick max admin level so it should work


Edit : u can tell me ur test server ip and i can come test with u if u want
Reply
#10

Quote:
Originally Posted by Joe Torran C
How would i make it so it also dosent kick level 5 and over admins?

Format is: [b]PlayerInfo[IDHERE][AdminLevel]
missed the over 5

if(PlayerInfo[i][AdminLevel] < 5){

The problem with && is that ALL the parts have to be true (or false)

So someone who !=playerid && <5 admin means that everyone who isnt playerid gets kicked (assuming playerid is an admin) hence each expression has to be seperate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)