Help with sscanf
#1

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.
Reply
#2

Optional specifiers must have default values.

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

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.
Reply
#4

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))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)