Sub cmd sscanf
#1

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
Reply
#2

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

Optional string.
Juste S[150] displays warning...
Reply
#4

Well use s[150]. :P
Reply
#5

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 ....
...
Reply
#6

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))
Reply
#7

On thй other solution ? I prefer do otherwise ..
Reply
#8

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!
Reply
#9

It really is more practical ...

For restrictions, organization, etc. ...

Help!
Reply
#10

What do u want to make?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)