14.02.2011, 10:10
So, first of all, this is my first tutorial, but ill try to give my best.
You will need:
- zcmd plugin by its creator (Zeex?)
- sscanf plugin by ******
So let's start.
First of all, on the top of the script lets make these lines:
Explanation: These add the functions such as COMMAND:help(playerid, params[]) into the script, so it wouldnt make us any errors.
Now, lets go somewhere down, and lets make a simple /help command:
Explanation:
COMMAND:help(playerid, params[]) makes the command into our script
Brackets
Sending our message to the player, SendClientMessage(playerid, colour(in our case its white), and the text is what it sends us.
return 1; makes it fix the problem that it will not show SERVER:Unknown Command, it means it returns it.
Brackets end.
Now if you compile and go ingame, you will get the message: This is your text! In white.
Lets make a /kick command, using sscanf and zcmd, for RCON admins only.
Command what are we going to make:
That's it! Now you can go ingame and type /kick when logged in as an admin, /kick 0 Cheating: 0 is the ID, Cheating is the reason.
If you get any errors/warning, let me know, I just wrote it and im not really sure it will work
.
You will need:
- zcmd plugin by its creator (Zeex?)
- sscanf plugin by ******
So let's start.
First of all, on the top of the script lets make these lines:
pawn Код:
#include <zcmd>
#include <sscanf>
Now, lets go somewhere down, and lets make a simple /help command:
pawn Код:
COMMAND:help(playerid, params[])
{
SendClientMessage(playerid, 0xFFFFFFF,"This is your text!");
return 1;
}
COMMAND:help(playerid, params[]) makes the command into our script
Brackets
Sending our message to the player, SendClientMessage(playerid, colour(in our case its white), and the text is what it sends us.
return 1; makes it fix the problem that it will not show SERVER:Unknown Command, it means it returns it.
Brackets end.
Now if you compile and go ingame, you will get the message: This is your text! In white.
Lets make a /kick command, using sscanf and zcmd, for RCON admins only.
Command what are we going to make:
pawn Код:
COMMAND:kick(playerid, params[])
{
new name[MAX_PLAYER_NAME];
new giveplayerid;
new result[128]; // makes a new function, so we wouldnt get any errors
GetPlayerName(playerid, name, sizeof(name)); // pretty self-explanatory
if(IsPlayerAdmin(playerid)) { // Checks if the player is a RCON admin
if (!sscanf(params, "is", giveplayerid, (result))) { // sscanf checking, if its in the right format
if(giveplayerid != INVALID_PLAYER_ID) { // if the player is online
new string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"%s has been kicked by %s, Reason: %s ",giveplayerid,playerid,reason);
SendClientMessageToAll(0xFFFFFFF,string);
return Kick(playerid); // returns the command to kick the player
}
else {// else if the player is offline/wrong ID
SendClientMessage(playerid, COLOR_GREY, "[ERROR:] Invalid ID.");
}
}
else { // else if is the wrong usage
SendClientMessage(playerid, COLOR_GREY, "[ERROR:] Please use the correct usage!");
}
}
else { // else if the player isnt a RCON admin
SendClientMessage(playerid, COLOR_GREY, "[ERROR:] You are not an admin!");
}
return 1; // returns the whole command
}
If you get any errors/warning, let me know, I just wrote it and im not really sure it will work
