SA-MP Forums Archive
Regarding 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Regarding sscanf (/showthread.php?tid=219742)



Regarding sscanf - Antonio [G-RP] - 02.02.2011

I've noticed that with sscanf, if you put a string before an interger or even another array...

pawn Код:
if(sscanf(params, "s[123]ddd", string, var1, var2, var3)) return sendclien...(playerid, color, "usage: /bla [string] [var1] [var2] [var3]);
The problem is that, if the "string" contains any spaces at all, it basically tells you to go fuck yourself, and counts the space as a change to the next variable (?).

Is there any way to fix this without putting the strings at the end of the command (if that would even work..?)


Re: Regarding sscanf - (SF)Noobanatior - 02.02.2011

hmm interesting i thing you would have to make a bit of code to manualy check it and replace the ' ' in the sting with another character as long as there is not a number after it then sscanf it then if you want you print the string you would need to change the character you inserted back to a ' ' so it read to the player as it was entered

hmm i kinda wanna try this now sounds like a fun little project really just a work around though

edit: and reading the sscanf command looks like putting it at the end would only return 1 word too


Re: Regarding sscanf - Antonio [G-RP] - 02.02.2011

Lol have fun, any other suggestions on how to make this work?


Re: Regarding sscanf - (SF)Noobanatior - 02.02.2011

rewrite sscanf lol
i think ill have a go tomorrow i dont think my first suggestion would be to bad but we will see


Re: Regarding sscanf - Retardedwolf - 02.02.2011

Use - instead of space in the string?


Re: Regarding sscanf - Joe Staff - 02.02.2011

Sscanf(params[1],"p<\">s[32]p< >dd");

This would make the player have to type
/MyCommand "my string" 1 2


Re: Regarding sscanf - Joe Staff - 02.02.2011

Well wouldn't the space after "my string" force a parameter change? Which would make the 1 in "/MyCommand "My String" 1 2" be the 2nd parameter and not the 1st. I say this because both the double quote and the space are delimiters and they're right next to each other.

So my revised code would be

pawn Код:
if(sscanf(params[1],"p<\">s[32]p< > dd",string,var1,var2) || (params[0]!='\"'))//erroneous code
//  /MyCommand "My String" 1 2
using the space between 'p< >' and 'dd' as a way to skip the expected space


Re: Regarding sscanf - nemesis- - 02.02.2011

Код:
if(sscanf(params, "ddds[123]", var1, var2, var3,string)) return sendclien...(playerid, color, "usage: /bla [var1] [var2] [var3] [string]);
Stick string at the end instead, problem solved.


Re: Regarding sscanf - Antonio [G-RP] - 02.02.2011

Alright thanks everybody for the replies. I'll take the easy route and stick the string at the end.