Mutliple Strings in Commands - 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: Mutliple Strings in Commands (
/showthread.php?tid=369693)
Mutliple Strings in Commands -
aintaro - 17.08.2012
Hey,
I was wondering how I would use something like strings in commands with Zcmd and Sscanf.
I am basically looking to create a '/duty' command for factions and jobs to use but I want to place it into one command. For example, if someone was in a cop they would do '/duty cop' to get their equipment or if someone had the taxi driver job and wanted to go on-duty they would do '/duty job'.
I know how to do this with integers in switches, just not sure with strings as this would make some of my commands a lot easier to use.
Thanks in advance.
Re: Mutliple Strings in Commands -
Kindred - 17.08.2012
Just an example:
pawn Код:
CMD:duty(playerid, params[])
{
new option[24];
if(sscanf(params, "s[24]", option)) return SendClientMessage(playerid, -1, "Usage: /duty [job/faction]");
if(!strcmp(option, "cop", true)) //If they typed cop for the option
{
//Do something
}
else if(!strcmp(option, "taxi", true)) //If they typed taxi for the option
{
//Do something
}
else return SendClientMessage(playerid, -1, "Incorrect option!");
return 1;
}
Re: Mutliple Strings in Commands -
aintaro - 17.08.2012
Quote:
Originally Posted by Kindred
Just an example:
pawn Код:
CMD:duty(playerid, params[]) { new option[24]; if(sscanf(params, "s[24]", option)) return SendClientMessage(playerid, -1, "Usage: /duty [job/faction]"); if(!strcmp(option, "cop", true)) //If they typed cop for the option { //Do something } else if(!strcmp(option, "taxi", true)) //If they typed taxi for the option { //Do something } else return SendClientMessage(playerid, -1, "Incorrect option!"); return 1; }
|
Thanks for that, it was just what I was looking for!