commands with two possible parameters - 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: commands with two possible parameters (
/showthread.php?tid=538916)
commands with two possible parameters -
GwENiko - 25.09.2014
what i am trying to create is very simple, but i noticed i never really got into this specific part, i guess its about time i learned this.
What i want to do is a cmd called "toggle", and depending on the parameter the player use, for example:
/toggle pm, it would toggle the player PM. If he types /toggle stats that would toggle his stats, how can i write it using CMD:command(playerid, params[])?
Re: commands with two possible parameters -
IceBilizard - 25.09.2014
pawn Код:
CMD:toggle(playerid, params[])
{
new options[128];
if(sscanf(params, "s[128]",options))
{
SendClientMessage(playerid, COLOR_WHITE, "Usage: /toggle [options]");
SendClientMessage(playerid, COLOR_SILVER, "OPTIONS: stats | pm");
return 1;
}
else if(!strcmp(options, "stats", true, 5))
{
//do stuff here
}
else if(!strcmp(options, "pm", true, 5))
{
//do stuff here
}
else SendClientMessage(playerid, COLOR_RED, "Invalid Option.");
return 1;
}
Re: commands with two possible parameters -
Pottus - 25.09.2014
@IceBilizard why bother using sscanf() you don't need it nor an extra variable just use isnull(params) of course.