problem with sscanf
#1

Hello. My command:
Код:
CMD:test(playerid, params[]) {
    sscanf(params, "s[16]d", params[0], params[1]);
    SendClientMessage(playerid, -1, params[0]);
    return true;
}
I enter "/test commandtest.2 5", and I get this:

What is the problem? Why does it lose an element of a string?
Reply
#2

They're being parsed, you're just not actually showing the second parameters.

pawn Код:
SendClientMessage(playerid, -1, params[1]);
Reply
#3

You did not understand. I need it to scan 2 parameters, i.e.
params[0] = commandtest.2
params[1] = 5
I tried to output through format, but this did not lead to any results.
I need: commandtest.2
It outputs: c mmandtest.2
Reply
#4

The "lost element" is the integer in the ASCII table.
Type: "/test commandtest.2 65" and you will have "cAmmandtest.2". Why? The character 'A' (or the "lost character") is the second element of params which is an array.
I'll be more explicit:
Код:
params[] = {'c', 'o', 'm', 'm', 'a', 'n', ...
and you replace 'o' by the integer. 65 mean A in ASCII table. That's why you get that.
Make two separate variable instead of reusing params.
Reply
#5

PHP код:
CMD:test(playeridparams[]) {
    new 
string[16], number;
    
sscanf(params"s[16]d"stringnumber);
    
SendClientMessage(playerid, -1string);
    return 
true;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)