ID / Part of Name on Commands written with ZCMD and sscanf.
#1

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

try u parameter:
pawn Код:
if(sscanf(params, "u", iName)) return SendClientMessage(playerid, COLOR_AQUA, "USAGE: ...");
Reply
#3

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

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.

Reply
#5

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
Reply
#6

Thanks very much you guys, I didn't know about the 'u' specifier.
Guess I should've digged trough the documentation some more.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)