02.03.2014, 14:42
(
Последний раз редактировалось rakshith122; 02.03.2014 в 14:52.
Причина: Spelling mistakes
)
Hello guys, This is my first tutorial. Have fun looking at this!
What are we going to see in this tutorial? This tutorial will show you how to make some simple commands using sscanf and zcmd
You can get zcmd.inc by clicking on me.
You can get sscanf.inc by clicking on me.
Let's include the necessary files for making commands.
You need to have sscanf.inc and zcmd.inc files inside your pawno/includes folder. Else, It'll give you an error just like
fatal error 100: cannot read from file: "sscanf" or fatal error 100: cannot read from file: "zcmd"
Let's start now.
Great! You completed one command.
You can make it short by using it like this
If I'm wrong with that first and fourth command in (if(sscanf(params,"u",ID)), Please let me know it. Since, i'm very much confused with it.
What are we going to see in this tutorial? This tutorial will show you how to make some simple commands using sscanf and zcmd
You can get zcmd.inc by clicking on me.
You can get sscanf.inc by clicking on me.
Shall we start?
First Step.Let's include the necessary files for making commands.
You need to have sscanf.inc and zcmd.inc files inside your pawno/includes folder. Else, It'll give you an error just like
fatal error 100: cannot read from file: "sscanf" or fatal error 100: cannot read from file: "zcmd"
INCLUDES
pawn Код:
#include <sscanf>
#include <zcmd>
Let's also define some colors.
pawn Код:
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xFF0000AA
Код:
At first, I'm going to say how to make a simple /heal and /armour command. (I mean like healing and armouring other players)
Let's see the /heal command now.
pawn Код:
CMD:heal(playerid,params[]) First line.
{ // Opening bracket
new string[128], ID, name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME]; // Here ID is the target, name is your name.(the player who is going to execute it) and aname is the target's name.
if(sscanf(params,"u",ID)) // "u" can be defined for inserting a name or an ID
{ // then
SendClientMessage(playerid,COLOR_RED,"[ERROR] /heal (Player Name/ID)"); //When the player didn't enter the fields correctly, It'll say this message to him.
return 1;
}
if(!IsPlayerAdmin(playerid)) // If the player is not an RCON admin
{ // then
SendClientMessage(playerid,COLOR_RED,"[ERROR] You are not authorized to use this command.");
return 1;
}
if(!IsPlayerConnected(ID)) // If the target ID is not connected
{ // then
SendClientMessage(playerid,COLOR_RED,"[ERROR] Entered player ID is not connected.");
return 1;
}
GetPlayerName(playerid,aname,sizeof(aname)); // Getting the name of the player who executes the command.
GetPlayerName(ID,name,sizeof(name)); // Getting the name of the target ID.
format(string,sizeof(string),"[ADMIN] RCON Administrator %s(%d) has healed %s(%d).",aname,playerid,name,ID);
SendClientMessageToAll(COLOR_GREEN,string); // Sends a message to everyone who is connected.
SetPlayerHealth(ID,100); // Sets the target ID's health to 100.
return 1;
} // Closing bracket.
You can make it short by using it like this
pawn Код:
CMD:heal(playerid,params[])
{
new string[128], ID, name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME];
if(sscanf(params,"u",ID)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] /heal [player name/id]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You are not authorized to use this command.");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] Entered player ID is not connected.");
GetPlayerName(playerid,aname,sizeof(aname)); // Getting the name of the player who executes the command.
GetPlayerName(ID,name,sizeof(name)); // Getting the name of the target ID.
format(string,sizeof(string),"[ADMIN] RCON Administrator %s(%d) has healed %s(%d).",aname,playerid,name,ID);
SendClientMessageToAll(COLOR_GREEN,string); // Sends a message to everyone who is connected.
SetPlayerHealth(ID,100); // Sets the target ID's health to 100.
return 1;
}
Let's see /armour now
pawn Код:
CMD:armour(playerid,params[])
{
new string[128], ID, name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME];
if(sscanf(params,"u",ID)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] /armour [player name/id]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You are not authorized to use this command.");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] Entered player ID is not connected.");
GetPlayerName(playerid,aname,sizeof(aname)); // Getting the name of the player who executes the command.
GetPlayerName(ID,name,sizeof(name)); // Getting the name of the target ID.
format(string,sizeof(string),"[ADMIN] RCON Administrator %s(%d) has armoured %s(%d).",aname,playerid,name,ID);
SendClientMessageToAll(COLOR_GREEN,string); // Sends a message to everyone who is connected.
SetPlayerArmour(ID,100); // Sets the target ID's armourto 100.
return 1;
}
Let's see another command : /me 
Let's make this simple

Let's make this simple
pawn Код:
CMD:me(playerid,params[])
{
new string[128];
new name[MAX_PLAYER_NAME];
if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] /me [message]"); // if the player didn't enter the fields it'll say this.
if(IsSpawned[playerid] != 1) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You must be spawned to use this command."); // if the player is not spawned it'll say this
format(string,sizeof(string),"%s %s",name,params); // Here the first %s defines the player's name, and the second %s defines the text entered by the player(params)
SendClientMessageToAll(COLOR_GREEN,string); // Sending a message to all with the color green.
return 1;
}
Final Command.
Its /kick
Its /kick
pawn Код:
CMD:kick(playerid,params[])
{
new string[128], name[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], ID, cmdreason;
if(sscanf(params,"us",ID,cmdreason)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] /kick [player name/id] [reason]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You are not authorized to use this command.");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] Entered player ID is not connected.");
GetPlayerName(playerid,aname,sizeof(aname)); // Getting the name of the player who executes the command.
GetPlayerName(ID,name,sizeof(name)); // Getting the name of the target ID.
format(string,sizeof(string),"[ADMIN] RCON Administrator %s(%d) has kicked %s(%d) for the reason : %s",aname,playerid,name,ID,cmdreason);
SendClientMessageToAll(COLOR_GREEN,string);
Kick(ID);
return 1;
}
Credits
Me(rakshith122) - For making this tutorial
Y-Less - For sscanf
Zeex - For zcmd
You for looking on this tutorial.
Me(rakshith122) - For making this tutorial
Y-Less - For sscanf
Zeex - For zcmd
You for looking on this tutorial.

Код:
If you like this tutorial, Please +rep me. :)