[Include] fCommand - (Multiple Parameters and the Fastest) [V2.0]
#1

Introduction:

Hello there
Today im posting [FeK]Drakins system and made with my help (DarK TeaM PT).
This Commands system has support for multiple params without needing other systems like sscanf,strtok,etc...

Accesibility:

#Multi Params:

It works with multiple params wich makes an easier use...

@Example:

#Command:
/health 0 100

Код:
/health = iParams[0]
0	= iParams[1]
100	= iParams[2]
So from the params '1' it will take all the 'spaces' and it will make the divisions, all in the commands system, wich makes easier to use.

making finally this

pawn Код:
fcmd(health,playerid)
{
    if(!iParams[1][0] || !iParams[2][0])
        return SendClientMessage(playerid,0xF60000AA,"Usage: {FFFFFF}/health [PlayerID] [0-100]");
    SetPlayerHealth(strval(iParams[1]),strval(iParams[2]));
    return true;
}
#Accesibility with the CMD's:

As ZCMD, all the commands are created out of ANY public, like it ise a stock function

pawn Код:
fcmd(command,playerid)
{
    return true;
}
Making easier to use!

Speed:

#How it works:
fCommand uses the same base as zcmd.
It uses basicly CallLocalFunctions that will make the CallBack work, without needing strcmp for compare the command,in the callback case if it doesn't exists it will just return false, making this, one Speed-Up

#Comparations
Unfortunately i didn't test's with other commands processors than the fastest: Zcmd

By DarK TeaM PT

Код:
# ZCMD - 52
# FCMD - 25


So it wasn't necessary other verifications

Codes:

#Code

pawn Код:
#define fcmd(%1,%2) \
            forward fcmd_%1(%2);    \
                public fcmd_%1(%2)

#define MaxFrequence (066)
#define MaxParameter (064)
#define MaxFunctions (032)
#define MaxLenString (128)

new
    sIndex = 0,
    iLenPart = 0,
    iPosPart = 0,
    iStrMid = 0,
    iLenght = 0,
    cmds[ MaxFunctions ]
;

public OnFilterScriptInit()
{
    OnPlayerCommandText(0,"/me Hoje me sinto bem");
    return true;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
    //Here you can write cmds witout params!
    return DelimiterCommand(playerid,cmdtext);
}
new iParams[ MaxFrequence ][ MaxParameter ],iTotalParams[MaxLenString];

stock
    DelimiterCommand(playerid,sStringSource[])
{
    iLenght = strlen(sStringSource);
    sIndex = 0;
    iLenPart = 0;
    iPosPart = 0;
    iStrMid = 0;
    for(new aIndex = 1; aIndex < MaxFrequence; ++aIndex) iParams[aIndex][0] = '\0';
    iTotalParams[0] = '\0';
    while(sIndex <= iLenght)
    {

        if(sStringSource[sIndex] == ' ' && sStringSource[sIndex - 1] != ' ' || sIndex == iLenght)
        {
            iStrMid = strmid(iParams[iPosPart], sStringSource, iLenPart, sIndex, 128);
            iParams[iPosPart][iStrMid] = 0,iLenPart = (sIndex + 1), ++iPosPart;
            if(iPosPart == 1)
                format(iTotalParams,MaxLenString, "%s",sStringSource[sIndex]);
        }
        ++sIndex;
    }
    format(cmds, sizeof cmds,"fcmd_%s",iParams[0][1]);
    return CallLocalFunction(cmds,"i",playerid);
}


//iTotalParams = All Params in One String
//iParams[id] = Only one Parameter

fcmd(me,playerid)
{
    new Name[24],zFormat[MaxLenString];
    GetPlayerName(playerid,Name,24);
    format(zFormat,MaxLenString,"Player: %s | Say: %s",Name,iTotalParams);
    SendClientMessageToAll(0xFFFFFF,zFormat);
    return true;
}

fcmd(ban,playerid)
{
    new Name[24],zFormat[MaxLenString];
    GetPlayerName(playerid,Name,24);
    format(zFormat,MaxLenString,"Player: %s | Say: %s",Name,iTotalParams);
    SendClientMessageToAll(0xFFFFFF,zFormat);
    return true;
}
Or Click me for download!

Credits:
Commands System FeK Squad it's created by:


# [FeK]DraKiNs
# DarK TeaM PT

Thanking all the Team [FeK]Squad and DracoBlue
Reply
#2

Stay tuned for updates
Reply
#3

This could be good,
Reply
#4

Can you add /health command source for how it works ?
Reply
#5

#- Updated 20/01/2011:

Removed bugs of iParams[0]


Thanks special to Gil Herique for reporting.


@Hackhers:

pawn Код:
fcmd(health,playerid)
{
    if(!iParams[1][0])
        return print("Use: /health [quant]");
    SetPlayerHealth(playerid,strval(iParams[1]));
    return true;
}
Reply
#6

What's this shit? Is it faster than zcmd?
Reply
#7

WOW O.O if those speed results are correct Great job FeK team!
Reply
#8

Thank you very much
I guess I now I'll only need FCMD (this) and FINI instead of sscanf2.0 (as a plugin), ZCMD AND y_ini/dini like before,
now I'll only have to keep updated on two includes.

Awesome work
Reply
#9

Quote:
Originally Posted by anonymousx
Посмотреть сообщение
What's this shit? Is it faster than zcmd?
Yes, it is faster than Zcmd.

I also did some testing, I liked it and added in my GM.
Reply
#10

Maybe it's faster but I don't think anyone will leave incredibly handy sscanf's automated values assigning, isnull checking and optional parameters function
Will check it out anyway
Reply
#11

Theres no way dkcmd can be faster using the method you provided in your post...
Reply
#12

Thats pathetic how you guys try to get any error or bug to make him realize that his cmd processor is lower, cant just accept that he made a good one? O_o
Reply
#13

Look at it this way: would you play on a gamemode full of bugs? Or would you play on the same gamemode with no bugs? The answer is easy I assume.
Reply
#14

Sorry then, just tried to help.
Reply
#15

You must face the fact that when you do something and claiming it's better than the best systems made your every single mistake will be pointed out, next time don't be so cocky about "THE FASTEST, THE BEST" because that's people who decide if it's really good and useful not you
Reply
#16

I understand man ..
Reply
#17

Don't be mad man. He's just telling the truth. Noone wants to use bugged stuff that crashes or doesn't work properly.

He's very experienced because it's kinda his job. He only tries to help so please don't accuse him.
Reply
#18

Ryder. So please forget it ok?
Reply
#19

You can see my one http://romanius.pastebin.com/rCSUKhtA

use:

PHP код:
PCMD:heal(playeridparams[], num_params)
{
    if(
num_params != 2) return SendClientMessage(playerid0xFF0000"USAGE: /heal playerid health");

    
/// strtok sscanf etc.

    
SetPlayerHealth(idhealth);
    return 
1;

It uses packed strings, so it use minimal number of memory
Reply
#20

Quote:
Originally Posted by Romanius
Посмотреть сообщение
You can see my one http://romanius.pastebin.com/rCSUKhtA

use:

PHP код:
PCMD:heal(playeridparams[], num_params)
{
    if(
num_params != 2) return SendClientMessage(playerid0xFF0000"USAGE: /heal playerid health");
    
/// strtok sscanf etc.
    
SetPlayerHealth(idhealth);
    return 
1;

It uses packed strings, so it use minimal number of memory
LOL,is a good man.
Is Faster? Good Work
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)