14.02.2013, 06:24
(
Last edited by ZayanImran; 14/02/2013 at 12:07 PM.
)
Hi guys, today i will show you a tutorial of how to make: /BAN & /KICK For RCON only
Start:
First we will include ZCMD at the top:
Now we will also include SScanf2:
Now at the end of your script or where your ZCMD commands are, add the commands there which i will show you.
Now lets begin
How to make a zcmd cmd?
Tips:
* You can replace "COMMAND:" with "CMD:".
* You can move the bracket up, i will give you a example.
Now lets start:
The /BAN cmd.
That is all :d.
& /KICK cmd
Start:
First we will include ZCMD at the top:
pawn Code:
#include ZCMD // Thanks to: ZeeX
pawn Code:
#include sscanf2 // Thanks to: Y_Less [(a.k.a): Alex Cole]
Now lets begin
How to make a zcmd cmd?
pawn Code:
COMMAND:/*Your Command Name Here*/(playerid, params[])
{ // this is the Bracket from which the code starts
//code here.
return 1; // you must return 1
} // & ends here
* You can replace "COMMAND:" with "CMD:".
* You can move the bracket up, i will give you a example.
pawn Code:
CMD:/*Your Command Name Here*/(playerid, params[]) /*>>*/ { /*<<*/
//code here.
return 1;//here also you must.
} // end of the cmd
The /BAN cmd.
pawn Code:
COMMAND:ban(playerid,params[])
{
if(IsPlayerAdmin(playerid)) // This will check if the player is admin. (The code [if] checks IF something is true.
{
new Target; // This is the target we will ban.
new Reason[100]; // This will be
if(!sscanf(params, "us", Target, Reason)) // this will check the string ([u] is for a integer & [s] is for a string.
{
if(Target == playerid) return SendClientMessage(playerid, 0xFFBBCC, "You will ban your self D:"); // this will check [if] the player is trying to ban him self. (Commands are performed by the player (playerid)
if(IsPlayerAdmin(Target)) return SendClientMessage(playerid, 0xFFBBCC, "You cant ban a RCON admin!"); // Checks [if] the Target is Rcon & another Rcon it trying to ban him.
new string[128]; // This is the out put which will be used to send the ban message to all
new name[MAX_PLAYER_NAME]; // getting the admin's name
new tname[MAX_PLAYER_NAME]; // getting the Target's name
GetPlayerName(playerid, name, sizeof(name)); // no need to enter a string (The banner is the player (playerid)
GetPlayerName(Target, tname, sizeof(tname)); // & the ban we are going to give is Target (which we made up | new Target; |
format(string, sizeof(string), "*Admin %s banned %s due to %s", name, tname, Reason); // this makes a format
SendClientMessageToAll(0xFFBBCC, string); // This will send the client message to all. (no need for string, we will add the output without "
new str[128]; // another output (oh i forget: new str[128] {[128]} is the number of chars (cells) it should not be higher than 999 or when you will test it in-game, you will disconnect for no reason.
format(str, sizeof(str), "*Banned by: %s | Ban reason: %s | Press F8 to take a screen shot & make a unban appeal on our forum", name, Reason);
SendClientMessage(Target, 0xFFBBCC, str); // sending the string of the output.
BanEx(Target, Reason); // it will ban the target with a reason & the ban will be saved in SAMP.BAN
}
else SendClientMessage(playerid, 0xFFBBCC, "USAGE: /ban <Target> <reason>"); // if he entered it wrong
}
else SendClientMessage(playerid, 0xFFBBCC, "umm, this wrong cmd, try /help xd."); // returning a err msg that he is not admin :L.
return 1; // you must i said it
}
& /KICK cmd
pawn Code:
COMMAND:kick(playerid,params[])
{
if(IsPlayerAdmin(playerid)) // This will check if the player is admin. (The code [if] checks IF something is true.
{
new Target; // This is the target we will kick.
new Reason[100]; // This will be
if(!sscanf(params, "us", Target, Reason)) // this will check the string ([u] is for a integer & [s] is for a string.
{
if(Target == playerid) return SendClientMessage(playerid, 0xFFBBCC, "You will Kick your self D:"); // this will check [if] the player is trying to kick him self. (Commands are performed by the player (playerid)
if(IsPlayerAdmin(Target)) return SendClientMessage(playerid, 0xFFBBCC, "You can Kick a RCON admin!"); // Checks [if] the Target is Rcon & another Rcon it trying to kick him.
new string[128]; // This is the out put which will be used to send the kick message to all
new name[MAX_PLAYER_NAME]; // getting the admin's name
new tname[MAX_PLAYER_NAME]; // getting the Target's name
GetPlayerName(playerid, name, sizeof(name)); // no need to enter a string (The kicker is the player (playerid)
GetPlayerName(Target, tname, sizeof(tname)); // & the kick we are going to give is Target (which we made up | new Target; |
format(string, sizeof(string), "*Admin %s Kicked %s due to %s", name, tname, Reason); // this makes a format
SendClientMessageToAll(0xFFBBCC, string); // This will send the client message to all. (no need for string, we will add the output without "
new str[128]; // another output (oh i forget: new str[128] {[128]} is the number of chars (cells) it should not be higher than 999 or when you will test it in-game, you will disconnect for no reason.
format(str, sizeof(str), "*Kicked by: %s | Kick reason: %s ", name, Reason);
SendClientMessage(Target, 0xFFBBCC, str); // sending the string of the output.
Kick(Target); // it will kick the target with a reason.
}
else SendClientMessage(playerid, 0xFFBBCC, "USAGE: /Kick <Target> <reason>"); // if he entered it wrong
}
else SendClientMessage(playerid, 0xFFBBCC, "umm, this wrong cmd, try /help xd."); // returning a err msg that he is not admin :L.
return 1; // you must i said it
}