sscanf Help - 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: sscanf Help (
/showthread.php?tid=444502)
sscanf Help -
Rokzlive - 17.06.2013
I feel like a proper idiot for asking this but i COMPLETELY forgot how to use sscanf and the tutorial is like Mandarin to me.
Im making a ZCMD command which is as follows: /ban [username/id] [days] [reason]
Can someone show me how that is processed with ZCMD and SSCANF?
Re: sscanf Help -
park4bmx - 17.06.2013
pawn Код:
COMMAND:mycommand(playerid, params[])
{
new target,days,reason[80];
if (sscanf(params, "uis[80]", target,days,reason)) return //param missing
return 1;
}
U do the rest
Or
pawn Код:
COMMAND:mycommand(playerid, params[])
{
if (sscanf(params, "uis[80]", params[0],params[1],params[2])) return //param missing
}
Re: sscanf Help -
Pottus - 17.06.2013
If you want definite results use sscanf like this.
pawn Код:
CMD:ban(playerid, params[])
{
new pid, days, reason[128];
if(sscanf(params, "uis[128]", pid, days, reason)) return SendClientMessage(playerid, 0xFF00FFFF, "Usage /ban <ID> <Days> <Reason>");
........
}
Ok well suppose you wanted your ban to work without days or a reason you can just do it like this then make some checks after to determine which gives a more specific result for instance.
pawn Код:
CMD:ban(playerid, params[])
{
new pid, days, reason[128];
sscanf(params, "uis[128]", pid, days, reason)
if(days < 0) days = 1; // Default days
........
}
I prefer this method hands down.
Re: sscanf Help -
Rokzlive - 17.06.2013
Thanks guys! Its starting to come back to me now! I appreciate it.