How do I make a 'mullti' cmd?
#4

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
I downloaded another GM wthat uses zcmd and sscanf to see if I could get a tip from there.
pawn Код:
CMD:sign(playerid, params[])
{
    new
    give[5];

    if(sscanf(params, "s[5]", give)) return SendClientMessage(playerid, COLOR_GREY, "[Usage]: /sign [1-4]");
    if(!strcmp(give, "1", true))
    {
        ApplyAnimation(playerid, "GHANDS", "gsign2", 4.1, 1, 1, 1, 1, 1, 1);
    }
    else if(!strcmp(give, "2", true))
    {
        ApplyAnimation(playerid, "GHANDS", "gsign3", 4.1, 1, 1, 1, 1, 1, 1);
    }
    else if(!strcmp(give, "3", true))
    {
        ApplyAnimation(playerid, "GHANDS", "gsign5", 4.1, 1, 1, 1, 1, 1, 1);
    }
    else if(!strcmp(give, "4", true))
    {
        ApplyAnimation(playerid, "GHANDS", "gsign4LH", 4.1, 1, 1, 1, 1, 1, 1);
    }
    return 1;
}
Is this really how you do it?? Then why do you use zcmd and sscanf if you still gonna use strcmp in the command?? Or am I missing something??

EDIT: Saw what you said now and understand why strcmp is being used. Thanks!
Not exactly. That code is really badly made.

The command checks for strings when it should check for an integer: "[Usage]: /sign [1-4]" 1-4 is a numeric input, therefor sscanf should read an integer, not a string:

pawn Код:
new anim;
sscanf(params,"i",anim);
then what number can be easily checked with if(anim == 1) .. else if(anim == 2) or even with switch statements.

strcmp is for strings, (str prefix (string), cmp suffix (compare)), it essentialy compares two strings. That command should be done with integers, not with strings.
Reply


Messages In This Thread
How do I make a 'mullti' cmd? - by Don_Cage - 02.02.2014, 02:18
Re: How do I make a 'mullti' cmd? - by CuervO - 02.02.2014, 03:05
Re: How do I make a 'mullti' cmd? - by Don_Cage - 02.02.2014, 03:10
Re: How do I make a 'mullti' cmd? - by CuervO - 02.02.2014, 03:16
Re: How do I make a 'mullti' cmd? - by Don_Cage - 02.02.2014, 03:40

Forum Jump:


Users browsing this thread: 1 Guest(s)