ID / Part of Name on Commands written with ZCMD and sscanf. -
Prolawl - 11.03.2014
Hey,
I'm writing a game mode which includes ZCMD for Command Processing.
I want to write commands which are able to either have a playerid or a Part of the name as an input.
Problem is with ZCMD I'm only able to get a certain type of variable like so:
pawn Код:
if(sscanf(params, "s[48]", iName)) return SendClientMessage(playerid, COLOR_AQUA, "USAGE: ...");
or
pawn Код:
if(sscanf(params, "ii", iName)) return SendClientMessage(playerid, COLOR_AQUA, "USAGE: ...");
Any toughts?
Re: ID / Part of Name on Commands written with ZCMD and sscanf. -
Matess - 11.03.2014
try u parameter:
pawn Код:
if(sscanf(params, "u", iName)) return SendClientMessage(playerid, COLOR_AQUA, "USAGE: ...");
Re: ID / Part of Name on Commands written with ZCMD and sscanf. -
PrivatioBoni - 11.03.2014
Quote:
Originally Posted by Matess
try u parameter:
pawn Код:
if(sscanf(params, "u", iName)) return SendClientMessage(playerid, COLOR_AQUA, "USAGE: ...");
|
I can confirm that this will act both as an ID and part of a name/full name.
Re: ID / Part of Name on Commands written with ZCMD and sscanf. -
CuervO - 12.03.2014
Quote:
Originally Posted by PrivatioBoni
I can confirm that this will act both as an ID and part of a name/full name.
|
It will not use part of name unless you define this previous to the 'u' specifier: ?<MATCH_NAME_PARTIAL=1>
pawn Код:
if (sscanf(params, "?<MATCH_NAME_PARTIAL=1>u", target)) return ...
https://sampforum.blast.hk/showthread.php?tid=120356
Alternatively you can use
SSCANF_Option(MATCH_NAME_PARTIAL, 1);
Quote:
MATCH_NAME_PARTIAL:
Currently sscanf will search for players by name, and will ALWAYS search for player whose name STARTS with the specified string. If you have, say "[CLAN]******" connected and someone types "******", sscanf will not find "[CLAN]******" because there name doesn't start with the specified name. This option, when set to 1, will search ANYWHERE in the player's name for the given string.
|
Re: ID / Part of Name on Commands written with ZCMD and sscanf. -
Mattakil - 12.03.2014
Let me demonstrate...
pawn Код:
CMD:pm(playerid, params[])
{
new target, message[150];
if(sscanf(params, "us[150]", target, message)) return SendClientMessage(playerid, -1, "USAGE: /pm [playerid/partofname] [message]");
What the guy above me said is really only needed for a database search, for example an MDC.
by doing it his way, if I wanted to PM someone named John_Smith I can do /pm smith, but this way requires to do /pm john. My way is how most servers do it
Re: ID / Part of Name on Commands written with ZCMD and sscanf. -
Prolawl - 12.03.2014
Thanks very much you guys, I didn't know about the 'u' specifier.
Guess I should've digged trough the documentation some more.