30.10.2010, 04:51
Okay, first off, you can't do this:
You need to use format:
Second of all, you looked for an optional string but you didn't use it at all.
I suggest you to use sscanf ONLY if you have to look for more than two parameters in a command.
Example:
/mycommand [playerid] // 1 parameter
/mycommand [playerid] [something] // 2 parameters
/mycommand [playerid] [something] [something else] // more than 2 params
If you don't have a second parameter, use "params" as an everything.
I think you're using zcmd, this might be useful for you:
By the way: If you decide to use sscanf, this is the way:
pawn Код:
array[index][cell] = string;
pawn Код:
format(array, array_size, input);
format(Businesses[Player[playerid][Business]][bName], 16, Name); // in your case
I suggest you to use sscanf ONLY if you have to look for more than two parameters in a command.
Example:
/mycommand [playerid] // 1 parameter
/mycommand [playerid] [something] // 2 parameters
/mycommand [playerid] [something] [something else] // more than 2 params
If you don't have a second parameter, use "params" as an everything.
pawn Код:
strval(params) // same as sscanf(params, "d", variable);
format(string, sizeof(string), "%s", params); // instead of using sscanf + new non-used string
pawn Код:
command(businessname, playerid, params[])
{
new
string[57];
if(isnull(params)) return SendClientMessage(playerid, WHITE, "SYNTAX: /businessname [new name]");
else if(strlen(params) < 2 || strelen(params) > 15) return SendClientMessage(playerid, WHITE, "The name has to be between 2 and 15 characters long.");
else if(strfind(params, "~", true) != -1) return SendClientMessage(playerid, WHITE, "You may not use the '~' character.");
format(string, sizeof(string), "You have changed your business name to %s.", params);
SendClientMessage(playerid, WHITE, string);
SaveBusiness(Player[playerid][Business]);
Update3DTextLabelText(BIZ1, ORANGE, params);
Update3DTextLabelText(BIZ2, ORANGE, params);
Update3DTextLabelText(BIZ3, ORANGE, params);
format(Businesses[Player[playerid][Business]][bName], 16, params);
return 1;
}
pawn Код:
if(sscanf(params, "s", Name)) // I'm not sure about the "s", it is "s[size]" in sscanf 2.0...
{
// syntax message
}