Pragma unused (zcmd question)
#1

Does anything get affected if i use this
#pragma unused params
pawn Код:
CMD:hi(playerid,params[])
{
     #pragma unused params
     SendClientMessage(playerid,-1,"Hi");
     return 1;
}
Well what does it do if i use
pawn Код:
#pragma unused params
for unused params for my zcmd commands?

I got some questions so you guys can help, and thanks.
1. Does it compile faster if i used #pragma unused params for unused params?
2. Does it Reduces Lag?
Reply
#2

1 Not that i know of everything always compiled the same to me never any different
2 I dont think params causes any lag.. as it is Coded to Be Quick..
Reply
#3

It eliminates a warning.
Reply
#4

i don't get warnings when i don't use params...
Reply
#5

its only in dcmd u get warning
Reply
#6

pawn Код:
new myvar;
#pragma unused myvar
What it basically does it that, it marks "myvar" as 'USED' so you don't get compiler warnings.

Nothing more/nothing less.

If you see warnings because of unused variables, you either need to use this or delete the variable.

In case of ZCMD, it's not necessary to add the "unused" symbol at all..
Reply
#7

Little council: When you don't use params, strcmp is better (and faster) than ZCMD/YCMD
Reply
#8

Depending on the method used to separate the parameters from the command string, it is possible that ZCMD will turn out to be beneficial only with more commands, but there are still 2 different algorithms:
1) your algorithm which executes strcmp until it finds a match
2) CallLocalFunction algorithm which is more clever (I explain it here)
Using or not using parameters in your commands does not alter that part of the command processing process.

So you're wrong.
Reply
#9

STRCMP:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/mycommand", cmdtext, true)==0)
    {
        //Lol
        return 1;
    }
    return 0;
}
ZCMD:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new
        pos,
        funcname[MAX_FUNC_NAME];
    while (cmdtext[++pos] > ' ')
    {
        funcname[pos-1] = tolower(cmdtext[pos]);
    }
    format(funcname, sizeof(funcname), "cmd_%s", funcname);
    while (cmdtext[pos] == ' ') pos++;
    if (!cmdtext[pos])
    {
        if (zcmd_g_HasOPCE)
        {
            return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, "\1"));
        }
        return CallLocalFunction(funcname, "is", playerid, "\1");  
    }
    if (zcmd_g_HasOPCE)
    {
        return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos]));
    }
    return CallLocalFunction(funcname, "is", playerid, cmdtext[pos]);
}

COMMAND:mycommand(playerid, params[])
{
    //lol
    return 1;
}
So you're wrong.
Reply
#10

Quote:
Originally Posted by Kilou
Посмотреть сообщение
STRCMP:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/mycommand", cmdtext, true)==0)
    {
        //Lol
        return 1;
    }
    return 0;
}
ZCMD:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new
        pos,
        funcname[MAX_FUNC_NAME];
    while (cmdtext[++pos] > ' ')
    {
        funcname[pos-1] = tolower(cmdtext[pos]);
    }
    format(funcname, sizeof(funcname), "cmd_%s", funcname);
    while (cmdtext[pos] == ' ') pos++;
    if (!cmdtext[pos])
    {
        if (zcmd_g_HasOPCE)
        {
            return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, "\1"));
        }
        return CallLocalFunction(funcname, "is", playerid, "\1");  
    }
    if (zcmd_g_HasOPCE)
    {
        return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos]));
    }
    return CallLocalFunction(funcname, "is", playerid, cmdtext[pos]);
}

COMMAND:mycommand(playerid, params[])
{
    //lol
    return 1;
}
So you're wrong.
You don't know what you're talking about.. zcmd and ycmd is far more better AND faster than strcmp..
And what's all that in OnPlayerCommandText !? I do
pawn Код:
CMD:mycommand(playerid, params[])
{
    //code
    return 1;
}
And my OnPlayerCommandText only have a spam checker..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)