CMD:Ban(playerid,params[])//this is the command
{
//down there is the reason of the ban , so other players will know about it
new reason[150];//the reason of the ban
// and this one is the playerid of the player who you want to ban.
new id;// the id of the player
//here if the admin didn't write the ban command correctly
if (sscanf(params, "rs[100]", id, reason))
return SendClientMessage(playerid, 0xFFFF0000, "{FF0000}Error:{FFFFFF}/Ban [playerid] [reason]");//if the player didn't write The command correctly like /ban without the id or the reason
//this one will check if the player is connected or not
if (!IsPlayerConnected(id))
return SendClientMessage(playerid, 0xFF0000AA, "Player not found");//if the player is invalid
//to prevent abuse this command will check if you are an admin or not
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFF0000,"{FF0000}Error:{FFFFFF}You Are not allowed to use this command");//if the player is not an admin
//this is the admin name //this is the message to player
new admin[MAX_PLAYER_NAME]//adminname, msgtoall1[150]//first message, msgtoall2[150];//second one
//this will get the name of the admin to post it
GetPlayerName(playerid, admin, sizeof(admin));//get the name of the admin
format(msgtoall1, sizeof(msgtoall1), "{FFFFFF}Player {FF0000}%s{FFFFFF} was banned from the server by {FF0000}%s", GetName(id), admin);//message to all players
SendClientMessageToAll(0xFFFF00AA, msgtoall1);//same thing
format(msgtoall2, sizeof(msgtoall2), "Reason : %s", reason);//reason of the ban
SendClientMessage(id, 0xFFFF00AA, msgtoall2);//the message
Ban(id);//ban the player
return Kick(id);//then kick him
}
CMD:kick(playerid, params[])
{
//the reason of the ban , and the id is the playerid of the one you want to kick
new reason[150], id;
//an error message if you didn't write the kick command correctly
if (sscanf(params, "rs[100]", id, reason))
return SendClientMessage(playerid, 0xFFFF0000, "{FF0000}Error:{FFFFFF}/Kick [player name/part of name] [reason]");//if the player didn't mention the id or the reason
//if the player is invalid or not connected
if (!IsPlayerConnected(id))
return SendClientMessage(playerid, 0xFF0000AA, "Player not found");//if the player is not connected
//this one will check if the player is an admin to prevent bug abuses
if(IsPlayerAdmin(playerid)))//if this player is an admin
{
//the name of the admin, msg to player, and message to all
new admin[MAX_PLAYER_NAME], msg1[150], msgtoall1[150];
// this will get the name of the admin
GetPlayerName(playerid, admin, sizeof(admin));
//message to the kicked player
format(msg1, sizeof(msg1), "You were kicked from the server by %s |Reason : %s|", admin,reason);
SendClientMessage(id, 0xFFFF00AA, msg1);//message from the kicked player
//message to all the players
format(msgtoall1, sizeof(msgtoall1), "Player %s was kicked from the server by %s | Reason : %s|", GetName(id), admin,reason);
SendClientMessageToAll(0xFFFF00AA, msgtoall1);//message to everyone
Kick(id);//kick the player
}
else
{
// if the player is not an admin , this message wil prevent him from typing this command
SendClientMessage(playerid,-1,"You Are not an admin " );//if the player is not an admin it will show this message
}
return 1;
}
CMD:slap(playerid,params[])
{
//the name of the slapped player,msgtoplayer,name of the admin, message to the slapped player, the floot x , y and z
new OtherPlayer, Msg[170], Name4[24], Message[150], OtherPlayerName[24], Float:x, Float:y, Float:z;
if(!IsPlayerAdmin(playerid))) return SendClientMessage(playerid, 0xFFFFFFFF, "[ERROR]: you are not an admin!");//if the player is not admin
else if(sscanf(params, "rs[170]", OtherPlayer, Message)) return SendClientMessage(playerid,COLOR_RED, "{FF0000}Error:{FFFFFF}/slap [playerid] [reason]");// if the player didn't write the command correctly
GetPlayerName(playerid, Name4, sizeof(Name4));//get the name of the admin
GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));//get the name of player
format(Msg, sizeof(Msg), "AdmCmd:{FF6600}%s {FFFFFF}slaps {FF6600}%s {FFFFFF}reason: {FF6600}%s", Name4, OtherPlayerName, Message);//the message
SendClientMessageToAll(0xFFFFFFFF, Msg);//send the above message to all
GetPlayerPos(OtherPlayer, x, y, z);//get the pos of the player
SetPlayerPos(OtherPlayer, x, y, z+5);// then set his pos to a higher place
new muted[MAX_PLAYERS];
CMD:mute(playerid, params[])
{
new
cmdid,
reason[80],
minutes,
string[128];
if(!IsPlayerAdmin(playerid)))
return 0;//if this player is not connected
if(sscanf(params, "uis[80]", cmdid, minutes,reason))
return SendClientMessage(playerid,0xFFFF0000,"Usage: /mute [id/name] [minutes] [reason]");//if the player didn't write the command correctly
if(!IsPlayerConnected(cmdid) || cmdid == INVALID_PLAYER_ID)
return SendClientMessage(playerid,0xFFFF0000,"Player not found!");//if the player is not connected it will show an error
{
new oname[MAX_PLAYER_NAME];//the name of the player
GetPlayerName(cmdid, oname, sizeof(oname));
format(string, sizeof(string), "AdmCmd:~ %s has been muted for %i minutes. Reason: '%s' by %s ", oname, minutes,reason,GetName(playerid));//The message to players that this player is muted
SetTimerEx("unmuteTimer", 60*1000*minutes, false, "i", cmdid);//set timer for the player
muted[cmdid] = 1;//mute the player
}
SendClientMessageToAll(0xFFFF0000, string);//send message to everyone
return 1;
}
forward unmuteTimer(playerid);
public unmuteTimer(playerid)
{
muted[playerid]= 0;//unmute the player
return SendClientMessage(playerid,0x00FF0000,"You're no longer muted!");//notify the player
}
public OnPlayerText(playerid,text[])
{
if(muted[playerid] == 1)//if the player is muted
{
SendClientMessage(playerid,COLOR_BLUE,"You are muted! you can't talk");
return 0;//prevent him from talking
}
return 1;
}
CMD:unmute(playerid,params[])
{
new
cmdid,
string[128];
if(!IsPlayerAdmin(playerid))
return 0;//if the player is not an admin
if(sscanf(params, "uis[80]", cmdid))
return SendClientMessage(playerid,0xFFFF0000,"Usage: /unmute [playerid]");//if the player didn't type this command
if(!IsPlayerConnected(cmdid) || cmdid == INVALID_PLAYER_ID)
return SendClientMessage(playerid,COLOR_RED,"Player not found!");//if the player is invalid
{
new oname[MAX_PLAYER_NAME];//player name
GetPlayerName(cmdid, oname, sizeof(oname));//get the player name by getting his id
format(string, sizeof(string), "AdmCmd:~ %s has been un muted by %s", oname,GetName(playerid));//message
muted[cmdid] = 0;//unmute the player
}
SendClientMessageToAll(0xFFFF0000, string);
return 1;
}
So you are going to give RCON password to everyone those who are willing to join administrator team?
|