Ban/Kick Commands With Name..
#1

hello, im looking for a Ban Command and a Kick Command, but, you only can BAN with the name i need.. you understand?

i mean, only my name can BAN/KICK.. i dont have IDea :S

Код:
	if(strcmp(cmd, "/Ban", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Utiliza: /Ban [ID/Nombre] [Razon]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(PlayerInfo[giveplayerid][pAdmin] > 1337)
			{
  				GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				format(string, sizeof(string), "AdmCmdPro: Nothing xD", sendername);
				SendClientMessageToAll(COLOR_LIGHTRED, string);
				Ban(playerid);
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 1)
			{
			  if(IsPlayerConnected(giveplayerid))
			  {
			    if(giveplayerid != INVALID_PLAYER_ID)
			    {
					  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[64];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_GRAD2, "Utiliza: /Ban [ID/Nombre] [Razon]");
							return 1;
						}
						new year, month,day;
						getdate(year, month, day);
						format(string, sizeof(string), "AdmCmd: %s Fue Baneado Por: %s, Razуn: %s ", giveplayer, sendername, (result));
						BanLog(string);
						format(string, sizeof(string), "AdmCmd: %s Fue Baneado Por: %s, Razуn: %s", giveplayer, sendername, (result));
						SendClientMessageToAll(COLOR_LIGHTRED, string);
						PlayerInfo[giveplayerid][pAdmin] = PlayerInfo[giveplayerid][pLevel];
						PlayerInfo[giveplayerid][pLevel] = -999;
						Ban(giveplayerid);
						return 1;
					}
				}//not connected
			}
			else
			{
				format(string, sizeof(string), "  %d No es Un Jugador Activo.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
Reply
#2

Do you want a command that can Ban and or Kick a Player?

If so, use this,

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/ban (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Ban(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
 if (strcmp("/kick (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Kick(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
Hope this helps... I think there is 1 error in the code, but its an easy fix.
Reply
#3

Quote:
Originally Posted by SpanishMan
i mean, only my name can BAN/KICK.. i dont have IDea :S
Код:
if(strcmp(cmd, "/Ban", true) == 0)
{
new nick[24];
GetPlayerName(playerid,nick,24);
if(!strcmp(nick, "SpanishMan ", true))
{
//command
}// else U r not SpanishMan !!
return 1;
}
Reply
#4

I think he didn't mean that and your code doesn't even have sence, NPTechStudios:
pawn Код:
if (strcmp("/ban (playerid)", cmdtext, true, 10) == 0) // lolwut !!??
Quote:
Originally Posted by SpanishMan
i mean, only my name can BAN/KICK.. i dont have IDea :S
Answer: Use "if" and "strcmp".

pawn Код:
// I won't include the command code for banning or kicking people, I'll just show the basic stuff
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/command", true) == 0) // this could be any command
  {
    new
      Name[MAX_PLAYER_NAME];
   
    GetPlayerName(playerid, Name, 24);
    if(strcmp(Name, "thenameyouwant", true) == 0) // change "thenameyouwant" for the target name...
    {
      // this is what happens if that player's name is your name or whatever was the name you were looking for
    }
    else
    {
      // this is what happens if that name isn't the target name
    }
    return 1; // I almost forget it
  }
  return 0;
}
Reply
#5

Quote:
Originally Posted by NPTechStudios
Do you want a command that can Ban and or Kick a Player?

If so, use this,

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/ban (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Ban(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
 if (strcmp("/kick (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Kick(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
Hope this helps... I think there is 1 error in the code, but its an easy fix.
that will ban/kick the player who write the command
________
Hash Honey Oil
Reply
#6

Quote:
Originally Posted by [AC
Etch ]
Quote:
Originally Posted by NPTechStudios
Do you want a command that can Ban and or Kick a Player?

If so, use this,

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/ban (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Ban(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
 if (strcmp("/kick (playerid)", cmdtext, true, 10) == 0)
	{
		if(IsPlayerAdmin(playerid)) // This makes only RCON admins allowed to use this command.
		{
		Kick(playerid); //Bans the player.
		}
		else // If the person using command is not RCON
		{
		SendClientMessage(playerid, /*Your Color Here*/ , "The command entered is for RCON admins only!"); // Message sent if not RCON
		return 1;
		}
	}
	return 0;
 }
Hope this helps... I think there is 1 error in the code, but its an easy fix.
that will ban/kick the player who write the command
Ahh. Okay. Wow, I guess I wasn't thinking clearly.
Reply
#7

Best Answer = Jeff..

And Now xD? How i put two names? im noob, sorry
Reply
#8

Код:
if(!strcmp(nick, "SpanishMan", true) || !strcmp(nick, "SpanishMan2", true) || !strcmp(nick, "SpanishMan3", true))
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)