SA-MP Forums Archive
zcmd + sscanf.. problem! - 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: zcmd + sscanf.. problem! (/showthread.php?tid=543586)



zcmd + sscanf.. problem! - Baltimore - 27.10.2014

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


Re: zcmd + sscanf.. problem! - Glossy42O - 27.10.2014

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


Re: zcmd + sscanf.. problem! - dominik523 - 27.10.2014

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");
    }



Re : zcmd + sscanf.. problem! - Baltimore - 27.10.2014

No errors.

EDIT: dominik523: It's not work!


Re: zcmd + sscanf.. problem! - dominik523 - 27.10.2014

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


Re : zcmd + sscanf.. problem! - Baltimore - 27.10.2014

Not work ^^

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


Re: zcmd + sscanf.. problem! - nemesis- - 27.10.2014

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


Re : zcmd + sscanf.. problem! - Baltimore - 27.10.2014

It's good! ^^

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

thx