zcmd + sscanf.. problem!
#1

Hello !

I have a cmd for display a SendClientMessage.

But it's not work!!

pawn Код:
CMD:ma(playerid, params[])
{
    if(isnull(params))
    {
        SendClientMessage(playerid, -1, "/ma <actions>");
        return SendClientMessage(playerid, COLOR_NOM, "Actions: ramasser, poser");
    }


    if(strcmp(params, "poser", false))
    {
        new quantite;
       
        if(sscanf(params, "d", quantite))
            return SendClientMessage(playerid, -1, "/ma poser <quantitй>");
       
        SendClientMessage(playerid, -1, "good");
    }

    return true;
}
Thx
Reply
#2

Do you have any errors? if yes please post them.
Reply
#3

Let's say you have written this: "/ma poser 5". You need to check with sscanf for 2 parameters, string which goes after /ma and integer which goes after the string.
Код:
new action[10];
 if(strcmp(params, "poser", false))
    {
        new quantite;
        
        if(sscanf(params, "s[10]d", action,quantite)) // <----
            return SendClientMessage(playerid, -1, "/ma poser <quantitй>");
        
        SendClientMessage(playerid, -1, "good");
    }
Reply
#4

No errors.

EDIT: dominik523: It's not work!
Reply
#5

Try this then:
Код:
CMD:ma(playerid, params[])
{
    new action[10], quantite;
    if(sscanf(params, s[10], action))
    {
        SendClientMessage(playerid, -1, "/ma <actions>");
        return SendClientMessage(playerid, COLOR_NOM, "Actions: ramasser, poser");
    }


    if(!strcmp(action, "poser", true, 5))
    {
       
        if(sscanf(params, "s[10]d",action, quantite))
            return SendClientMessage(playerid, -1, "/ma poser <quantitй>");
       
        SendClientMessage(playerid, -1, "good");
    }

    return true;
}
EDIT:Try now
Reply
#6

Not work ^^

This message "SendClientMessage(playerid, -1, "good");" does not appear, even if you have entered the correct order.
Reply
#7

Quote:

CMD:ma(playerid, params[])
{
new action[20], quantite;
if(sscanf(params,"s[20]d",action,quantite)
{
SendClientMessage(playerid, -1, "/ma <actions> <quantite>");
return SendClientMessage(playerid, COLOR_NOM, "Actions: ramasser, poser");
}


if(!strcmp(action, "poser")) SendClientMessage(playerid, -1, "good");
return 1;
}

See if that works. You'll need to fix the tabbing as I pasted it straight from Notepad++.
Reply
#8

It's good! ^^

Can you look this topic now please:
http://forum.sa-mp.com/showthread.ph...18#post3238518

thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)