SA-MP Forums Archive
Sub cmd sscanf - 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: Sub cmd sscanf (/showthread.php?tid=483699)



Sub cmd sscanf - Noliax8 - 27.12.2013

Hi,

I had a problem with sscanf, warning about optional string. It's corrected : S(No Reason)[125]

But, my script don't work.

PHP код:
YCMD:admin(playeridparams[], help)
{
    new 
tmp[20],
        
nextParams[125]
    ;
    
    if( 
sscanf(params"s[25]S(No Reason)[125]"tmpnextParams) )
        return 
SendClientMessage(playerid, -1"{9DEB00}Usage: /admin [Choix]");
    else
    {
        if( !
strcmp(tmp"slap"true) )
        {
            new    
userid,
                
raison[50],
                
Float:POS[3]
            ;
            
            if( 
sscanf(nextParams"uS(No Reason)[50]"useridraison) )
                return 
SendClientMessage(playerid, -1"[Commande] /admin slap [ID/Partie du Nom] [Raison (facultatif)]");
            else
            {
                if( 
InvalidPlayerID(playeriduserid) ) return 1;
                
GetPlayerPos(useridPOS[0], POS[1], POS[2]);
                
SetPlayerPos(useridPOS[0], POS[1], POS[2]+5);
                if( 
strlen(raison) > 0)
                       
SendClientMessageToAllEx(-1"[ADMIN] L'admin %s a slap %s. Raison: %s"returnNameEx(playerid), returnNameEx(userid), raison);
                else
                    
SendClientMessageToAllEx(-1"[ADMIN] L'admin %s a slap %s."returnNameEx(playerid), returnNameEx(userid));
            }
        }
    }
    return 
1;

I write: /admin : ok : "/admin [choix]"
I write: /admin slap : not ok! : "Player not connected" (warning from InvalidPlayerID) ...

Help
Thanks


Re: Sub cmd sscanf - Hansrutger - 27.12.2013

What is S(No Reason)? :S Actually asking, first time I see it in a sscanf :P


Re : Sub cmd sscanf - Noliax8 - 27.12.2013

Optional string.
Juste S[150] displays warning...


Re: Sub cmd sscanf - Hansrutger - 27.12.2013

Well use s[150]. :P


Re : Sub cmd sscanf - Noliax8 - 27.12.2013

It's not a optional string.

But, it does not solve my problem...

I want do

/admin slap ID REASON
/admin ban ID REASON
/admin goto ....
...


Re: Sub cmd sscanf - Hansrutger - 27.12.2013

Tried that once, didn't work that way lol. I have tried to have more sscanf's inside sscanf's like you did above but it's not the way it works sadly. :/ Not for me at least. I solved it with having one sscanf for everything like:

if(sscanf(params, "s[len]s[len]s[len]u", firstString, firstOption, secondOption, targetID))


Re : Sub cmd sscanf - Noliax8 - 27.12.2013

On thй other solution ? I prefer do otherwise ..


Re: Re : Sub cmd sscanf - Hansrutger - 27.12.2013

Quote:
Originally Posted by Noliax8
Посмотреть сообщение
On thй other solution ? I prefer do otherwise ..
Good luck, tell me if you find a solution. I would also like to know it then haha. :P No really tell me if you get to some other conclusion!


Re : Sub cmd sscanf - Noliax8 - 28.12.2013

It really is more practical ...

For restrictions, organization, etc. ...

Help!


Re: Sub cmd sscanf - newbie scripter - 28.12.2013

What do u want to make?