A little help with sscanf
#1

Hello.
I have a "problem" using multiple text string in sscanf params:

The cmd:
PHP Code:
 /sendinfo [JR_Junior] [Nick_Name] [No reason] [No details
PHP Code:
CMD:sendinfo(playerid,params[])
{
    new 
admin[25],account[25],reason[128],details[128];
    if(!
sscanf(params"s[25]s[25]s[128]s[128]",admin,account,reason,details))
    {
        
printf("%s | %s | %s | %s",admin,account,reason,details);
    }
    return 
1;

The result is:
PHP Code:
JR_Junior Nick_Name No reason No details 
Any solution?
Thank you!
Reply
#2

Code:
 CMD:sendinfo(playerid,params[])
{
    new admin[25],account[25],reason[128],details[128];

    if(sscanf(params, "s[25]s[25]s[128]s[128]",admin,account,reason,details)) return SendClientMessage(playerid, -1,  "/sendinfo <string> <string> <string> <string>");

    printf("%s | %s | %s | %s",admin,account,reason,details);
    return 1;
}
Worked fine for me?

Code:
 Testing | Testing | Tesing | TESTINGEVENLONGERTESTING
My discord if you want to discuss more "Shadow_#0001"

Edit: I also just tried the exact copy of your CMD and it worked fine. So maybe if you have an issues its likely with the rest of your command not this snippet you've put forward.
Reply
#3

Quote:
Originally Posted by Shadow_
View Post
Code:
 CMD:sendinfo(playerid,params[])
{
    new admin[25],account[25],reason[128],details[128];

    if(sscanf(params, "s[25]s[25]s[128]s[128]",admin,account,reason,details)) return SendClientMessage(playerid, -1,  "/sendinfo <string> <string> <string> <string>");

    printf("%s | %s | %s | %s",admin,account,reason,details);
    return 1;
}
Worked fine for me?

Code:
 Testing | Testing | Tesing | TESTINGEVENLONGERTESTING
My discord if you want to discuss more "Shadow_#0001"

Edit: I also just tried the exact copy of your CMD and it worked fine. So maybe if you have an issues its likely with the rest of your command not this snippet you've put forward.
Works fine only if you do not type more than 1 word in the reason, but try again this cmd:
PHP Code:
/sendinfo <Testing> <Testing> <Tesing again> <TESTINGEVENLONGERTESTING>
ResultTesting Testing Tesing again TESTINGEVENLONGERTESTING 
Reply
#4

I'm not sure you can use sscanf in that way. My advise would be to use dialogs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)