problem with 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: problem with sscanf (
/showthread.php?tid=649349)
problem with sscanf -
FelixAquero - 07.02.2018
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?
Re: problem with sscanf -
DobbysGamertag - 07.02.2018
They're being parsed, you're just not actually showing the second parameters.
pawn Код:
SendClientMessage(playerid, -1, params[1]);
Re: problem with sscanf -
FelixAquero - 07.02.2018
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
Re: problem with sscanf -
Dayrion - 07.02.2018
The "lost element" is the integer in the ASCII table.
Type: "/test commandtest.2 65" and you will have "c
Ammandtest.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.
Re: problem with sscanf -
OneDay - 07.02.2018
PHP код:
CMD:test(playerid, params[]) {
new string[16], number;
sscanf(params, "s[16]d", string, number);
SendClientMessage(playerid, -1, string);
return true;
}