15.09.2015, 16:29
hello i search a good code pawn for ban/kick system ; anyone can help me please ?
CMD:kick(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 3) { new PID; //define the playerid we wanna kick new reason[64]; //the reason, put into a string new str[128]; //a new message string new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get GetPlayerName(PID, Playername, sizeof(Playername)); if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here) if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!"); format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names SendClientMessageToAll(COLOR_RED, str); //send that message to all Kick(PID); //kick the playerid we've defined } else //if he has not got the permissions { SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!"); //return this message } return 1; }
CMD:ban(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 3) { new PID; //define the playerid we wanna ban new reason[64]; //the reason, put into a string new str[128]; //a new message string new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get GetPlayerName(PID, Playername, sizeof(Playername)); if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here) if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!"); format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names SendClientMessageToAll(COLOR_RED, str); //send that message to all Ban(PID); //Ban the playerid we've defined } else //if he has not got the permissions { SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message } return 1; }
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
new targetplayer, reason[50];
if(sscanf(params, "u", targetplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /kick [ID] (Reason)");
sscanf(params, "us[50]", targetplayer, reason);
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
if(targetplayer == playerid)
return SendClientMessage(playerid, COLOR_RED, "Error: You cannot kick yourself!");
new string[150], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
GetPlayerName(targetplayer, pName2, MAX_PLAYER_NAME);
format(string, sizeof string, "~ %s has been kicked from the server for '%s'", pName, reason);
SetTimerEx("DelayedKick", 50, false, "i", targetplayer);
printf("[KICK] %s has kicked %s from the server", pName, pName2);
SendClientMessageToAll(COLOR_RED, string);
return 1;
}
forward DelayedKick(playerid);
public DelayedKick(playerid) Kick(playerid);
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
if(PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
new targetplayer, reason[50];
if(sscanf(params, "u", targetplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /ban [ID] (Reason)");
sscanf(params, "us[50]", targetplayer, reason);
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
if(targetplayer == playerid)
return SendClientMessage(playerid, COLOR_RED, "Error: You cannot ban yourself!");
new string[150], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
GetPlayerName(targetplayer, pName2, MAX_PLAYER_NAME);
format(string, sizeof string, "~ %s has been banned from the server for '%s'", pName, reason);
SetTimerEx("DelayedBan", 50, false, "i", targetplayer);
printf("[BAN] %s has banned %s from the server", pName, pName2);
SendClientMessageToAll(COLOR_RED, string);
return 1;
}
forward DelayedBan(playerid);
public DelayedBan(playerid) Ban(playerid);
Here you go dude:
/kick Command: Код:
CMD:kick(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 3) { new PID; //define the playerid we wanna kick new reason[64]; //the reason, put into a string new str[128]; //a new message string new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get GetPlayerName(PID, Playername, sizeof(Playername)); if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here) if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!"); format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names SendClientMessageToAll(COLOR_RED, str); //send that message to all Kick(PID); //kick the playerid we've defined } else //if he has not got the permissions { SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!"); //return this message } return 1; } Код:
CMD:ban(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 3) { new PID; //define the playerid we wanna ban new reason[64]; //the reason, put into a string new str[128]; //a new message string new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get GetPlayerName(PID, Playername, sizeof(Playername)); if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here) if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!"); format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names SendClientMessageToAll(COLOR_RED, str); //send that message to all Ban(PID); //Ban the playerid we've defined } else //if he has not got the permissions { SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message } return 1; } If I helped you, please REP+ me. |