SA-MP Forums Archive
Help 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: Help with sscanf (/showthread.php?tid=427229)



Help with sscanf - Xabi - 31.03.2013

I need to be able to edit the name ingame of some houses, and I have a command like "/edithouse" that allows multiples names, like /edithouse owner, /edithouse name, /edithouse price.

So the question is, how could I use /edithouse name with sscanf supposing that the name could contain white spaces?
I have tried with this, but doesn't work.

pawn Код:
if(sscanf(params, "s[16]S[32]DU", action, name, value, player))
{
    SendClientMessage(playerid, White, "USE: /edithouse [Field]");
        return 1;
}
if(strcmp(action, "Name", true) == 0)
{
        if(sscanf(params, "s[16]s[32]", action, name)) return SendClientMessage(playerid, White, "USE: /edithouse name [Name]");
}
And when I try to write /edithouse name My House it returns the firms message "USE: /edithouse [Field]".

Thanks in advance.


Re: Help with sscanf - Vince - 31.03.2013

Optional specifiers must have default values.

pawn Код:
if(sscanf(params, "s[16]S(invalid)[32]D(-1)U(-1)", action, name, value, player))



Re: Help with sscanf - MP2 - 31.03.2013

If you want to allow white spaces in a string parameter, you have to make it the LAST parameter. Spaces are the delimiters ('separators') between parameters, and the script can't guess where one parameter ends and where the next starts.


Respuesta: Help with sscanf - Xabi - 01.04.2013

Tried both and sends the same message, still doesn't work as it should:

pawn Код:
if(sscanf(params, "s[16]D(-1)U(-1)S(invalid)[32]", action, value, player, name))