SA-MP Forums Archive
Pragma unused (zcmd question) - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pragma unused (zcmd question) (/showthread.php?tid=316257)



Pragma unused (zcmd question) - Tanush123 - 06.02.2012

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?


Re: Pragma unused (zcmd question) - Buzzbomb - 06.02.2012

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..


Re: Pragma unused (zcmd question) - 2KY - 06.02.2012

It eliminates a warning.


Re: Pragma unused (zcmd question) - Tanush123 - 06.02.2012

i don't get warnings when i don't use params...


Re: Pragma unused (zcmd question) - jamesbond007 - 06.02.2012

its only in dcmd u get warning


Re: Pragma unused (zcmd question) - iPLEOMAX - 06.02.2012

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..


Re : Pragma unused (zcmd question) - Kilou - 08.02.2014

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


Re: Pragma unused (zcmd question) - AndreT - 08.02.2014

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.


Re : Pragma unused (zcmd question) - Kilou - 08.02.2014

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.


Re: Re : Pragma unused (zcmd question) - Don_Cage - 08.02.2014

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..