SA-MP Forums

SA-MP Forums (http://forum.sa-mp.com/index.php)
-   Plugin Development (http://forum.sa-mp.com/forumdisplay.php?f=18)
-   -   [Plugin] Pawn.CMD (http://forum.sa-mp.com/showthread.php?t=608474)

YourShadow 01/06/2016 06:45 PM

Pawn.CMD
 
Pawn.CMD 3.1.4


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


Natives:
PHP Code:

native PC_RegAlias(const cmd[], const alias[], ...);
native PC_SetFlags(const cmd[], flags);
native PC_GetFlags(const cmd[]);
native PC_EmulateCommand(playerid, const cmdtext[]);
native PC_RenameCommand(const cmd[], const newname[]);
native PC_CommandExists(const cmd[]);   
native PC_DeleteCommand(const cmd[]);

native CmdArray:PC_GetCommandArray();
native CmdArray:PC_GetAliasArray(const cmd[]);
native PC_GetArraySize(CmdArray:arr);
native PC_FreeArray(&CmdArray:arr);
native PC_GetCommandName(CmdArray:arrindexdest[], size sizeof dest); 

Callbacks:
PHP Code:

forward PC_OnInit(); // calls after Pawn.CMD initialization
forward OnPlayerCommandReceived(playeridcmd[], params[], flags); // calls before a command 
forward OnPlayerCommandPerformed(playeridcmd[], params[], resultflags); // calls after a command 

How to install:
Extract archive in your server's folder. Edit "server.cfg":

- Windows
Code:

plugins pawncmd.dll
- Linux
Code:

plugins pawncmd.so
Example command:
PHP Code:

#include <Pawn.CMD>

cmd:help(playeridparams[]) // also possible to use CMD and COMMAND
{
    
// code here
    
return 1;


Registering aliases:
You can register aliases for a command. For example:
PHP Code:

#include <Pawn.CMD>

cmd:help(playeridparams[])
{
    
// code here
    
return 1;
}
alias:help("commands""cmds""menu"); // case insensitive 

Using flags:
You can set flags for a command. For example:
PHP Code:

#include <Pawn.CMD>

enum(<<=1)
{
    
CMD_ADMIN 1,
    
CMD_MODER,
    
CMD_USER
};

flags:ban(CMD_ADMIN);
cmd:ban(playeridparams[])
{
    
// code here
    
return 1;
}

public 
OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    if ((
flags CMD_ADMIN) && !pAdmin[playerid])
        return 
0;

    return 
1;


Full example:
PHP Code:

#include <Pawn.CMD>

enum(<<=1)
{
    
CMD_ADMIN 1,
    
CMD_MODER,
    
CMD_USER
};

flags:ban(CMD_ADMIN);
cmd:ban(playeridparams[])
{
    
// code here
    
return 1;
}
alias:ban("block");

public 
OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    if ((
flags CMD_ADMIN) && !pAdmin[playerid])
        return 
0;

    return 
1;
}

public 
OnPlayerCommandPerformed(playeridcmd[], params[], resultflags)
{
    if(
result == -1)
    {
        
SendClientMessage(playerid0xFFFFFFFF"SERVER: Unknown command.");
        return 
0;
    }

    return 
1;


If you want to use Pawn.CMD in a filterscript, put this define before including:
PHP Code:

#define FILTERSCRIPT 

Changelog:
1.0:
- First release.
2.0:
- Now plugin is fully compatible with zcmd command style.
2.1:
- Were fixed bugs.
3.0:
- Added macros "callcmd" to call a command. Example: callcmd::ban(playerid, "42");
- Added natives: PC_SetFlags, PC_GetFlags, PC_EmulateCommand, PC_RenameCommand, PC_DeleteCommand.
- Added macros "isnull" to check command's params.
- Removed call "logprintf" on command's registration.
- "cmdtext" was splitted into "cmd" and "params".
- Pawn.CMD is not compatible with zcmd style anymore.
3.1:
- Added natives: PC_CommandExists, PC_GetCommandArray, PC_GetAliasArray, PC_GetArraySize, PC_FreeArray, PC_GetCommandName.
- Added macros "PC_HasFlag".
- Added public "PC_OnInit".
- Changed native "PC_GetFlags".
- Compatibility with YSI.
3.1.1:
- Fixed bug in native "PC_RenameCommand".
3.1.2:
- Fixed bug in scripts queue.
3.1.3:
- Fixed error "File or function is not found"
3.1.4:
- Added support for OPCT

Download binaries:
https://github.com/urShadow/Pawn.CMD/releases

Source code:
https://github.com/urShadow/Pawn.CMD

Source code of the benchmark:
https://gist.github.com/urShadow/14d...17088cf2f23cbe

povargek 01/06/2016 07:06 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
consecrated, +rep

vannesenn 01/06/2016 07:09 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
Lol, bro, it's not micro, it's mini. 12 ms for ... comands? 100?

iKevin 01/06/2016 07:11 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
Cool.

SickAttack 01/06/2016 07:14 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
Any benchmark with ZCMD?

YourShadow 01/06/2016 07:24 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
Quote:

Originally Posted by SickAttack (Post 3709107)
Any benchmark with ZCMD?

Obvious that Pawn.CMD faster than zcmd, because it works through memory hack.

vannesenn 01/06/2016 07:28 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
Micro(μ) is x10 on -6, mili(m) is x10 on -3. That is from SI

Crystallize 01/06/2016 08:11 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
how much faster than zcmd?

vannesenn 01/06/2016 08:31 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
This looks like a troll. Look at guy's name, lol. Frist post was this topic, really? No way.

zSuYaNw 01/06/2016 08:32 PM

Re: Pawn.CMD - the fastest and most functional command processor
 
hoho Niice woork!


All times are GMT. The time now is 02:26 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.