SA-MP Forums Archive
[Include] fCommand - (Multiple Parameters and the Fastest) [V2.0] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] fCommand - (Multiple Parameters and the Fastest) [V2.0] (/showthread.php?tid=214651)



fCommand - (Multiple Parameters and the Fastest) [V2.0] - SlashPT - 21.01.2011

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


Respuesta: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 21.01.2011

Stay tuned for updates


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - Zh3r0 - 21.01.2011

This could be good,


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - HACKHERS - 21.01.2011

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


Respuesta: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 21.01.2011

#- 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;
}



Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - anonymousx - 21.01.2011

What's this shit? Is it faster than zcmd?


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - [L3th4l] - 21.01.2011

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


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - Mike Garber - 21.01.2011

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


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - Ryan_Howllet - 21.01.2011

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.


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - DiDok - 21.01.2011

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


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - [03]Garsino - 24.01.2011

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


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - SeQualX - 24.01.2011

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


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - [03]Garsino - 24.01.2011

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.


Respuesta: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 24.01.2011

Sorry then, just tried to help.


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - DiDok - 24.01.2011

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


Respuesta: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 24.01.2011

I understand man ..


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - RyDeR` - 24.01.2011

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.


Respuesta: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 24.01.2011

Ryder. So please forget it ok?


Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - Romanius - 24.01.2011

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


Respuesta: Re: fCommand - (Multiple Parameters and the Fastest) [V2.0] - ipsBruno - 24.01.2011

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