Asi puedes hacer comandos con multiples opciones y parametros distintos para cada uno de ellos (fue hecho de manara mas amigable y sencillo para el usuario, por ejemplo, al poner /cmd 1st, te da el uso del opcion "1st"):
pawn Код:
// ** INCLUDES
#include <a_samp>
#include <sscanf>
#include <zcmd>
// ** DEFINES
// *** FUNCTIONS
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
// ** MAIN
main()
{
print("Loaded \"one_command_multiple_syntaxes.amx\".");
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// ** COMMANDS
CMD:cmd(playerid, params[])
{
new space_pos = strfind(params, " ", true), option[128];
if(space_pos != -1)
{
strmid(option, params, 0, space_pos);
}
else
{
strcpy(option, params, 128);
}
if(isnull(option))
{
SendClientMessage(playerid, -1, "Usage: /cmd (1st/2nd/3rd) [arguments]");
}
else if(!strcmp(option, "1st", true))
{
new integer_1;
if(sscanf(params, "{s[128]}i", integer_1))
{
SendClientMessage(playerid, -1, "Usage: /cmd 1st (integer)");
}
else
{
new string[144];
format(string, sizeof(string), "Integer 1: %d", integer_1);
SendClientMessage(playerid, -1, string);
}
}
else if(!strcmp(option, "2nd", true))
{
new integer_1, integer_2;
if(sscanf(params, "{s[128]}ii", integer_1, integer_2))
{
SendClientMessage(playerid, -1, "Usage: /cmd 2nd (integer) (integer)");
}
else
{
new string[144];
format(string, sizeof(string), "Integer 1: %d, integer 2: %d", integer_1, integer_2);
SendClientMessage(playerid, -1, string);
}
}
else if(!strcmp(option, "3rd", true))
{
new integer_1, integer_2, integer_3;
if(sscanf(params, "{s[128]}iii", integer_1, integer_2, integer_3))
{
SendClientMessage(playerid, -1, "Usage: /cmd 2nd (integer) (integer) (integer)");
}
else
{
new string[144];
format(string, sizeof(string), "Integer 1: %d, Integer 2: %d, Integer 3: %d", integer_1, integer_2, integer_3);
SendClientMessage(playerid, -1, string);
}
}
else
{
SendClientMessage(playerid, -1, "Usage: /cmd (1st/2nd/3rd) [arguments]");
}
return 1;
}