Multiple Parameter 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: Multiple Parameter Commands (
/showthread.php?tid=477739)
Multiple Parameter Commands -
2KY - 26.11.2013
I've got a command called /edit, I'm trying to get this to work, and unfortunately, it's just not turning out to be as simple as I thought it'd be, can't get it to work, and I always have this issue.
Think anyone could help me out, and figure out what I'm doing wrong? Thanks in advance guys.
pawn Код:
CMD:edit(playerid, params[])
{
// Command errors
#define INV_NAME SendClientMessage(playerid, -1, "Invalid 'name' parameter!")
if(isnull(params))
{
SendClientMessage(playerid, -1, "/edit [name]");
SendClientMessage(playerid, -1, " Available Names: 'faccfg', 'faction', 'player'");
return 1;
}
new
pname[50];
if(!sscanf(params, "s[50]", pname))
{
if(!strcmp(pname, "faccfg"))
{
new
action[25];
if(sscanf(params, "s[25]", action))
{
SendClientMessage(playerid, -1, "/edit factionconfig [action]");
SendClientMessage(playerid, -1, " Available Actions: 'chatcol', 'usenametags', 'nametagcol'");
return 1;
}
if(!strcmp(action, "chatcol"))
{
new
col[15];
if(sscanf(params, "s[15]", col))
return SendClientMessage(playerid, -1, "/edit factionconfig chatcol [hex color]");
FactionConfig[ChatCol] = col;
SaveFactionConfigFile();
return 1;
}
}
else if(!strcmp(pname, "faction"))
{
new
fid,
action[25];
if(sscanf(params, "is[25]", fid, action))
{
SendClientMessage(playerid, -1, "/edit faction [faction id] [action]");
SendClientMessage(playerid, -1, " Available Actions: 'name'");
return 1;
}
}
else if(!strcmp(pname, "player"))
{
SendClientMessage(playerid, -1, "editing a player!");
}
else return INV_NAME;
}
#undef INV_NAME
return 1;
}
Re: Multiple Parameter Commands -
Jefff - 26.11.2013
Try
pawn Код:
if(sscanf(params[strlen("faccfg")], "s[25]", action)) //or if(sscanf(params, "{s[10]}s[25]", action))
{
SendClientMessage(playerid, -1, "/edit factionconfig [action]");
SendClientMessage(playerid, -1, " Available Actions: 'chatcol', 'usenametags', 'nametagcol'");
return 1;
}