[Include] iCmds - New system of Commands
#1

Introduction
I had launched a system command,but is epic fail
So I decided to create a command like zcmd,without multi params.

So here it is

Include:

pawn Код:
#define cmd(%1,%2,%3)\
    forward @%1(%2,%3); \
        public @%1(%2,%3)

forward OnPlayerReceivedCommand(iPlayer,cmdtext[],sucess);
public OnPlayerReceivedCommand(iPlayer,cmdtext[],sucess)
{

    return true;
}

public
    OnPlayerCommandText(iPlayer,cmdtext[])
{
    if(strfind(cmdtext, " ", true) == -1)
    {
        cmdtext[0] = '@';
        return CallLocalFunction("OnPlayerReceivedCommand","isd",iPlayer,cmdtext,CallLocalFunction(cmdtext,"is",playerid," "));
    }

    new iLoop = 0,iSpaces = 0,iStr[32];
    while(iSpaces != 1) if(cmdtext[++iLoop] == ' ') ++iSpaces;
    ++iLoop,format(iStr,32,cmdtext[iLoop]),cmdtext[iLoop - 1] = '\0';
    printf("Cmd: %s | Param: %s",cmdtext,iStr);
    return CallLocalFunction("OnPlayerReceivedCommand","isd",iPlayer,cmdtext,CallLocalFunction(cmdtext,"is",playerid,iStr));
}
Example for Use Ban Using sscanf:

pawn Код:
//In Final Command
cmd(ban,iPlayer,params[])
{  
    if (!IsPlayerAdmin(iPlayer))
        return SendClientMessage(iPlayer, VERMELHO, "[ERROR] Not Admin");

    new id,message[64];
    if (sscanf(params, "us[64]", id,message))
        return SendClientMessage(iPlayer,AMARELO, "Use: /ban [id/nick] [reason]");

    if (!IsPlayerConnected(id))
        return SendClientMessage(iPlayer,VERMELHO, "[ERRO] Player is Offline");

    if (id  == iPlayer)
        return SendClientMessage(iPlayer,VERMELHO, "[ERRO] Not ban your");

    BanEx(id,message);
    return true;
}

Testing?

pawn Код:
#include "../Includes1/a_samp.inc"

#define icmd(%1,%2,%3)\
    forward @%1(%2,%3); \
        public @%1(%2,%3)


public OnFilterScriptInit()
{
    #define MAX_TEST (990000)
   
    // ICMD TEST
    new dcmdtest = GetTickCount();
    for(new a; a < MAX_TEST; ++a)
        OnPlayeriCmdCommandText(0,"/icmd mans");
    printf("# ICMD in %d",GetTickCount() - dcmdtest);

    //ZCMD TEST
    new zcmdtest = GetTickCount();
    for(new a; a < MAX_TEST; ++a)
        OnPlayerCommandText(0, "/zcmd test");
    printf("# ZCMD in %d",GetTickCount() - zcmdtest);
    return true;
}

//Include ICMD
forward OnPlayerReceivedCommandICMD(iPlayer,cmdtext[],sucess);
public OnPlayerReceivedCommandICMD(iPlayer,cmdtext[],sucess)
{

    return true;
}

forward OnPlayeriCmdCommandText(iPlayer,cmdtext[]);
public  OnPlayeriCmdCommandText(iPlayer,cmdtext[])
{
    if(strfind(cmdtext, " ", true) == -1)
    {
        cmdtext[0] = '@';
        return CallLocalFunction("OnPlayerReceivedCommandICMD","isd",iPlayer,cmdtext,CallLocalFunction(cmdtext,"is",iPlayer," "));
    }
    new iLoop = 0,iSpaces = 0,iStr[32];
    while(iSpaces != 1) if(cmdtext[++iLoop] == ' ') ++iSpaces;
    ++iLoop,format(iStr,32,cmdtext[iLoop]),cmdtext[iLoop - 1] = '\0';
    return CallLocalFunction("OnPlayerReceivedCommandICMD","isd",iPlayer,cmdtext,CallLocalFunction(cmdtext,"is",iPlayer,iStr));
}


//INCLUDE ZCMD
#define MAX_FUNC_NAME (32)

#define zCOMMAND:%1(%2)          \
            forward zcmd_%1(%2); \
            public zcmd_%1(%2)

#define zCMD:%1(%2) \
            zCOMMAND:%1(%2)

#define zcommand(%1,%2,%3) \
            zCOMMAND:%1(%2, %3)

#define zcmd(%1,%2,%3) \
            zCOMMAND:%1(%2, %3)

#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif


forward OnPlayerCommandReceived(iPlayer, cmdtext[]);
forward OnPlayerCommandPerformed(iPlayer, cmdtext[], success);

static
    bool:zcmd_g_HasOPCS = false,
    bool:zcmd_g_HasOPCE = false;

forward zcmd_OnFilterScriptInit();
public OnGameModeInit()
{
    zcmd_g_HasOPCS = funcidx("OnPlayerCommandReceived") != -1;
    zcmd_g_HasOPCE = funcidx("OnPlayerCommandPerformed") != -1;
    if (funcidx("zcmd_OnGameModeInit") != -1)
    {
        return CallLocalFunction("zcmd_OnGameModeInit", "");
    }
    return 1;
}

public OnPlayerCommandText(iPlayer, cmdtext[])
{
    if (zcmd_g_HasOPCS && !CallLocalFunction("OnPlayerCommandReceived", "is", iPlayer, cmdtext))
    {
        return 1;
    }
    new
        pos,
        funcname[MAX_FUNC_NAME];
    while (cmdtext[++pos] > ' ')
    {
        funcname[pos-1] = tolower(cmdtext[pos]);
    }
    format(funcname, sizeof(funcname), "zcmd_%s", funcname);
    while (cmdtext[pos] == ' ') pos++;
    if (!cmdtext[pos])
    {
        if (zcmd_g_HasOPCE)
        {
            return CallLocalFunction("OnPlayerCommandPerformed", "isi", iPlayer, cmdtext, CallLocalFunction(funcname, "is", iPlayer, "\1"));
        }
        return CallLocalFunction(funcname, "is", iPlayer, "\1");
    }
    if (zcmd_g_HasOPCE)
    {
        return CallLocalFunction("OnPlayerCommandPerformed", "isi", iPlayer, cmdtext, CallLocalFunction(funcname, "is", iPlayer, cmdtext[pos]));
    }
    return CallLocalFunction(funcname, "is", iPlayer, cmdtext[pos]);
}


//COMMANDS
zcmd(zcmd,iPlayer,params[])
{
    return true;
}

icmd(zcmd,iPlayer,params[])
{
    return true;
}
Код:
[12:01:38] # ICMD in 214
[12:01:39] # ZCMD in 221
Credits
Credits for [iPs]DraKiNs (iPs => FeK)

Thanks,Hugs
Reply
#2

Is it faster than YCMD though? As YCMD is faster than ZCMD + it has a ton of features.
Reply
#3

if its an epic fail why did you release it??
Reply
#4

Quote:
Originally Posted by Porsche911
Посмотреть сообщение
if its an epic fail why did you release it??
Not,lol,was the previous release.

My English is bad

Hugs
Reply
#5

There ain't reason to switch over from ycmd or zcmd to this system, is there?
Reply
#6

I really do like the fact that people like to have a competition with Zeex and ******, zeex with his command processor and ****** with his ini system, yet you guys manage to almost defeat them.
Maybe iCmds is better than ZCMD. Here we don't need to say, God knows, instead we say, ****** kows.

Sorry for acting like a bitch lately.

Good job
Reply
#7

Oh ... I don't get it why you want the have the fastest system.
Anyway.
Add a command in your script with your iCmds Include /ban ... use ingame /BaN. It won't work ( case sensitive ).
Reply
#8

Quote:
Originally Posted by Goldkiller
Посмотреть сообщение
Oh ... I don't get it why you want the have the fastest system.
Anyway.
Add a command in your script with your iCmds Include /ban ... use ingame /BaN. It won't work ( case sensitive ).
Indeed, which may be the reason that this is faster.
Reply
#9

zcmd would be even faster if
Код:
format(funcname, sizeof(funcname), "zcmd_%s", funcname);
was replaced with
Код:
strins(funcname, "zcmd_", 0);
And zcmd converts all characters to lower case, so it's definitely a factor why icmd is a little faster.
Reply
#10

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
I really do like the fact that people like to have a competition with Zeex and ******, zeex with his command processor and ****** with his ini system, yet you guys manage to almost defeat them.
Maybe iCmds is better than ZCMD. Here we don't need to say, God knows, instead we say, ****** kows.

Sorry for acting like a bitch lately.

Good job
(hesaidit)
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)