[Tutorial] Using PawnCMD Command Processor
#1

• Introduction

Hi everyone, I'm bringing a tutorial on how to use the PawnCMD command processor.
to the forum because I see that few members talk about and use.
Although very simple many do not know yet or are afraid to use it.
I use it for some time and I recommend it, very simple to use and in my opinion much faster and more practical.

Pawn.CMD - a new command processor that works through a plugin.
This plugin is compatible with any version of SA: MP.

Its use is very similar to ZCMD, but in the author's tests,
PawnCMD stands out in the comparative speed of response among the other command processors.
See the image:





• Installation

To get started, we must download the updated version of Plugin / Include Download

Код:
Pawn.CMD.inc
Add to include in the include folder of Pawno.

Код:
pawncmd.dll
Add the plugin in the plugins folder at the root of the server. .dll if it's windowns
Код:
pawncmd.so
.so if it's linux.

Edit "server.cfg" and add pawncmd in line plugins.



• Example of use

Example of use with simple command without use of parameters:

PHP код:
#include <Pawn.CMD>
CMD:jetpack(playeridparams[]) // simple command to create a jetpack
{
    
SetPlayerSpecialAction(playerid2);
    
SendClientMessage(playerid, -1"Jetpack created successfully.");
    return 
1;
}
CMD:armour(playeridparams[]) // simple command to create a armour
{
    
SetPlayerArmour(playerid100);
    
SendClientMessage(playerid, -1"Armour created successfully.");
    return 
1;


Example of use with parameters. We use sscanf for example:

PHP код:
#include <Pawn.CMD>
#include <sscanf2>
CMD:kick(playeridparams[])
{
    new 
ID;
    if(
sscanf(params"u"ID)) return SendClientMessage(playerid, -1"Use /kick [ID]");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid, -1"Error, id invalid.");
    
SendClientMessage(playerid, -1"Command performed successfully.");
    
SendClientMessage(ID, -1"You have been kicked by an admin.");
    
SetTimerEx("Kickar"100false"i"ID);
    return 
1;
}
forward Kickar(playerid);
public 
Kickar(playerid) return Kick(playerid); 

• Using additional commands

To use additional commands with the same functions we will use alias example:


PHP код:
CMD:jetpack(playeridparams[]) // simple command to create a jetpack
{
    
SetPlayerSpecialAction(playerid2);
    
SendClientMessage(playerid, -1"Jetpack created successfully.");
    return 
1;
}
alias:jetpack("createjetpack""cjet"); // /createrjetpack or /cjet has the same function as /jetpack 

• Use of constraints on commands

To create a constraint on the commands we can use the callback OnPlayerCommandReceived
See examples:

PHP код:
#include <Pawn.CMD>
#include <sscanf2>
new CMD_ADMIN 1;
flags:jetpack(CMD_ADMIN); // Use flags:cmd(CMD_ADMIN) to restrict the command, remember to create the constraint in OnPlayerCommandReceived
flags:kick(CMD_ADMIN);
CMD:jetpack(playeridparams[]) // simple command to create a jetpack
{
    
SetPlayerSpecialAction(playerid2);
    
SendClientMessage(playerid, -1"Jetpack created successfully.");
    return 
1;
}
CMD:kick(playeridparams[])
{
    new 
ID;
    if(
sscanf(params"u"ID)) return SendClientMessage(playerid, -1"Use /kick [ID]");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid, -1"Error, id invalid.");
    
SendClientMessage(playerid, -1"Command performed successfully.");
    
SendClientMessage(ID, -1"You have been kicked by an admin.");
    
SetTimerEx("Kickar"100false"i"ID);
    return 
1;

PHP код:
public OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    if((
flags CMD_ADMIN) && Admin[playerid] == 0// You should change "Admin [playerid]" to the admin variable used in your GM.
    
{
        
SendClientMessage(playerid, -1"Error, Command Restricted to Administrators.");
         return 
0;
    }
    return 
1;


• No typed command

Use the callback OnPlayerCommandPerformed for the player to receive the no-command message:

PHP код:
public OnPlayerCommandPerformed(playeridcmd[], params[], resultflags)
{
    if(
result == -1)
    {
        
SendClientMessage(playerid, -1"Error, nonexistent command.");
        return 
0;
    }
    return 
1;


• Download & Credits

Download GitHub
Creator of PawnCMD: YourShadow
Reply
#2

Wait wow so i can actually switch THAT EASY from ZCMD to this? it's exactly the same params?
EDIT: freaking awesome thanks to you and Yourshadow for the amazing release.
Reply
#3

Very good again.

@RogueDrifter Yes.
Reply
#4

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Wait wow so i can actually switch THAT EASY from ZCMD to this? it's exactly the same params?
EDIT: freaking awesome thanks to you and Yourshadow for the amazing release.
Yes my friend..
Reply
#5

Why use the new keyword when the value of it is never modified, just use const keyword instead of new OR use bitwise flags by defining an enumeration and using (<<= 2) with it.
Reply
#6

@Logic_ What do you mean guy? Cleyson removes the params [] from the commands it does not have.
Reply
#7

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Why use the new keyword when the value of it is never modified, just use const keyword instead of new OR use bitwise flags by defining an enumeration and using (<<= 2) with it.
Quote:
Originally Posted by Marllun
Посмотреть сообщение
@Logic_ What do you mean guy? Cleyson removes the params [] from the commands it does not have.
Why use this:
PHP код:
new CMD_ADMIN 1
when the fuckin' value of it is never modified. Instead use:
PHP код:
const CMD_ADMIN 1
Or more better:
PHP код:
enum (<<=2)
{
    
CMD_ADMIN 1// first one should always start from 1 so the flags are different for each level.
    //CMD_ADMIN_LVL1,
    //CMD_ADMIN_LVL2,
    //...

Reply
#8

PHP Code:
enum (<< = 1

    
CMD_ADMIN 1// first one should always start from 1 so the flags are different for each level because of 0b01
    //CMD_ADMIN_LVL1, 
    //CMD_ADMIN_LVL2, 
    //... 

By the way, 1 is enough
Reply
#9

Code:
CMD:jetpack(playerid, params[]) // simple command to create a jetpack 
{ 
    SetPlayerSpecialAction(playerid, 2); 
    SendClientMessage(playerid, -1, "Jetpack created successfully."); 
    return 1; 
} 


CMD:armour(playerid, params[]) // simple command to create a armour 
{ 
    SetPlayerArmour(playerid, 100); 
    SendClientMessage(playerid, -1, "Armour created successfully."); 
    return 1; 
}
You use this code in example in which u really don't the extra parameter of params[]
Reply
#10

Quote:
Originally Posted by Logic_
Посмотреть сообщение
PHP код:
const CMD_ADMIN 1
PHP код:
#define CMD_ADMIN (1) 
Reply
#11

Quote:
Originally Posted by iKarim
Посмотреть сообщение
PHP код:
#define CMD_ADMIN (1) 
No, it shouldn't be that either. It should be shown as bits because that's the whole point of the feature...
If you define them as integers like that ("1") then you won't be able set multiple flags, that defeats the purpose.

Look at http://forum.sa-mp.com/showpost.php?...&postcount=274
Reply
#12

Quote:
Originally Posted by Crayder
Посмотреть сообщение
No, it shouldn't be that either. It should be shown as bits because that's the whole point of the feature...
If you define them as integers like that ("1") then you won't be able set multiple flags, that defeats the purpose.

Look at http://forum.sa-mp.com/showpost.php?...&postcount=274
Right, I am aware of the binary flags but mainly my reply was to show him that it's invalid, I didn't probably express that correctly. Thanks though.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)