SA-MP Forums Archive
sscanf parameter help - 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: sscanf parameter help (/showthread.php?tid=618099)



sscanf parameter help - DTV - 01.10.2016

I can't remember how to do this or what to look up to figure out how to do this, but how do you make a command that has a "parameter tree" (idk what to call it)

pawn Код:
//example of what i mean
CMD:example(playerid,params[])
{
    new param1[128],param2;
    if(sscanf(params,"s[128]i",param1)) return SendClientMessage(playerid,-1,"example text");
    if(!strcmp(param1,"sometext",true))
    {
        if(sscanf(params,"s[128]i",param1,param2)) return SendClientMessage(playerid,-1,"example text 2");  //this is what I mean by "parameter tree"
        //code here
    }
}
I hope that what I'm asking isn't too confusing, I just don't know what it would be called.


Re: sscanf parameter help - Dayrion - 01.10.2016

If this one help you to understand :
PHP код:
CMD:set(playeridparams[])
{
    if(
pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playeridfalse);
    new
        
parametre[30+'\0'],
        
scmd[50];

    if(
sscanf(params"s[30]S()[130]"parametrescmd)) return SCM(playeridLBLUE"/set [money - score - kills - death - skin - vhp - hp - armor - v(irtual)w(orld) - int(erior)]");

    if(!
strcmp(parametre"money"))
    {
        if(
pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playeridfalse);

        new 
cible,
            
money;

        if(
sscanf(scmd"ui"ciblemoney)) return SCM(playeridLBLUE"/set money [playerid/name] [montant]");

        if(!
IsPlayerConnected(cible))
            return 
ErrorMsg(playerid_"Ce personne n'est pas connectйe.");

        
GivePlayerMoney(cibleGetPlayerMoney(cible) + money);
        if(
money 0
            return 
InfoAnnonce(cible"%i$ on йtй crйditйs sur votre agent de poche."money);
        else
            return 
InfoAnnonce(cible"%i$ ont йtй retirйs de votre argent de poche."0-money);
    } 



Re: sscanf parameter help - SickAttack - 01.10.2016

By wrapping around arguments in curly braces "{}". It will ignore each data type with the curly braces around them.


Re: sscanf parameter help - DTV - 01.10.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
By wrapping around arguments in curly braces "{}". It will ignore each data type with the curly braces around them.
All the arguments or just the initial argument?