SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 01/06/2016, 06:45 PM   #1
YourShadow
Big Clucker
 
YourShadow's Avatar
 
Join Date: Apr 2016
Posts: 120
Reputation: 236
Thumbs up Pawn.CMD

Pawn.CMD 3.2.0


Description:
Pawn.CMD is a command processor that works through a plugin.
This plugin is compatible with any SA:MP version 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();
forward OnPlayerCommandReceived(playeridcmd[], params[], flags);
forward OnPlayerCommandPerformed(playeridcmd[], params[], resultflags); 
How to install:
Extract archive in server folder. Update your server.cfg.

- Windows
Code:
plugins pawncmd.dll
- Linux
Code:
plugins pawncmd.so
Example command:
PHP Code:
#include <Pawn.CMD>

cmd:help(playeridparams[]) // you can also use 'CMD' and 'COMMAND' instead of 'cmd'
{
    
// code here
    
return 1;

Registering aliases:
You can register aliases for a command.

PHP Code:
#include <Pawn.CMD>

cmd:help(playeridparams[])
{
    
// code here
    
return 1;
}
alias:help("commands""cmds"); // case insensitive 
Using flags:
You can set flags for a command.

PHP Code:
#include <Pawn.CMD>

enum (<<= 1)
{
    
CMD_ADMIN 1// 0b00000000000000000000000000000001
    
CMD_MODER,     // 0b00000000000000000000000000000010
    
CMD_JR_MODER   // 0b00000000000000000000000000000100
};

new 
pPermissions[MAX_PLAYERS];

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

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

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

public 
OnPlayerCommandReceived(playeridcmd[], params[], flags)
{
    if (!(
flags pPermissions[playerid]))
    {
        
printf("player %d doesn’t have access to command '%s'"playeridcmd);

        return 
0;
    }

    return 
1;
}

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

        return 
0;
    }

    return 
1;
}

public 
PC_OnInit()
{
    const 
testAdminPlayerId 1testModerPlayerId 2testJrModerPlayerId 3testSimplePlayerId 4;

    
pPermissions[testAdminPlayerId] = CMD_ADMIN CMD_MODER CMD_JR_MODER;
    
pPermissions[testModerPlayerId] = CMD_MODER CMD_JR_MODER;
    
pPermissions[testJrModerPlayerId] = CMD_JR_MODER;
    
pPermissions[testSimplePlayerId] = 0;

    
PC_EmulateCommand(testAdminPlayerId"/ban 4 some reason"); // ok
    
PC_EmulateCommand(testModerPlayerId"/ban 8 some reason"); // not ok, moder doesn’t have access to 'ban'
    
PC_EmulateCommand(testModerPlayerId"/kick 15 some reason"); // ok
    
PC_EmulateCommand(testModerPlayerId"/jail 16 some reason"); // ok, moder can use commands of junior moderator
    
PC_EmulateCommand(testJrModerPlayerId"/jail 23 some reason"); // ok
    
PC_EmulateCommand(testSimplePlayerId"/ban 42 some reason"); // not ok

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:
- 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"
- Parameter "cmdtext" 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
3.2.0:
- Increased stability

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

Last edited by YourShadow; 23/07/2018 at 11:11 AM.
YourShadow is offline   Reply With Quote
Old 01/06/2016, 07:06 PM   #2
povargek
Big Clucker
 
Join Date: Oct 2012
Posts: 79
Reputation: 16
Default Re: Pawn.CMD - the fastest and most functional command processor

consecrated, +rep
__________________
Sorry for my bad English
povargek is offline   Reply With Quote
Old 01/06/2016, 07:09 PM   #3
vannesenn
Gangsta
 
vannesenn's Avatar
 
Join Date: Feb 2011
Posts: 662
Reputation: 15
Default Re: Pawn.CMD - the fastest and most functional command processor

Lol, bro, it's not micro, it's mini. 12 ms for ... comands? 100?
vannesenn is offline   Reply With Quote
Old 01/06/2016, 07:11 PM   #4
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 579
Reputation: 71
Default Re: Pawn.CMD - the fastest and most functional command processor

Cool.
iKevin is offline   Reply With Quote
Old 01/06/2016, 07:14 PM   #5
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,113
Reputation: 754
Default Re: Pawn.CMD - the fastest and most functional command processor

Any benchmark with ZCMD?
SickAttack is offline   Reply With Quote
Old 01/06/2016, 07:24 PM   #6
YourShadow
Big Clucker
 
YourShadow's Avatar
 
Join Date: Apr 2016
Posts: 120
Reputation: 236
Default Re: Pawn.CMD - the fastest and most functional command processor

Quote:
Originally Posted by SickAttack View Post
Any benchmark with ZCMD?
Obvious that Pawn.CMD faster than zcmd, because it works through memory hack.
YourShadow is offline   Reply With Quote
Old 01/06/2016, 07:28 PM   #7
vannesenn
Gangsta
 
vannesenn's Avatar
 
Join Date: Feb 2011
Posts: 662
Reputation: 15
Default 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
vannesenn is offline   Reply With Quote
Old 01/06/2016, 08:11 PM   #8
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,595
Reputation: 314
Default Re: Pawn.CMD - the fastest and most functional command processor

how much faster than zcmd?
Crystallize is offline   Reply With Quote
Old 01/06/2016, 08:31 PM   #9
vannesenn
Gangsta
 
vannesenn's Avatar
 
Join Date: Feb 2011
Posts: 662
Reputation: 15
Default 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.
vannesenn is offline   Reply With Quote
Old 01/06/2016, 08:32 PM   #10
zSuYaNw
Godfather
 
zSuYaNw's Avatar
 
Join Date: Apr 2010
Location: Santa Catarina
Posts: 6,846
Reputation: 660
Default Re: Pawn.CMD - the fastest and most functional command processor

hoho Niice woork!
zSuYaNw is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] Vectoral Pawn - STL Data containers for pawn Rancho Plugin Development 70 03/05/2017 07:41 PM
Forum bug with [pawn][/pawn] BBCODE Yuripe Everything and Nothing 4 06/10/2012 12:58 PM
[Tool/Web/Other] PAWN Scanner - Scan PAWN files for information. Slice Tools and Files 10 15/07/2012 07:09 PM
[Help With Pawn] Pawn and compiler is not working..... D_Less Client Support 3 09/03/2012 04:49 AM


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


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