command 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: command help (
/showthread.php?tid=395238)
command help -
Amine_Mejrhirrou - 25.11.2012
hi
can any one show me an example of a command like this /craft [option1/option2]
Re: command help -
Channeru - 25.11.2012
you mean /rules? or what?
Re: command help -
Nordic - 25.11.2012
hopefully this has what you need:
https://sampwiki.blast.hk/wiki/Creating_Commands
Re: command help -
RenSoprano - 25.11.2012
pawn Код:
CMD:yourcmd(playerid, params[])
{
new choice[32];
if(sscanf(params, "s[32]", choice))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /yourcmd [name]");
SendClientMessageEx(playerid, COLOR_GREY, "Available names: optinon1, option2");
return 1;
}
if(strcmp(choice, "option1", true) == 0)
{
// Your code
return 1;
}
else if(strcmp(choice, "option2", true) == 0)
{
// Your code
return 1;
}
return 1;
}
maybe you want something like this
Re : command help -
Amine_Mejrhirrou - 25.11.2012
RenSoprano ! this is the code i was looking for (i will ++rep of cours)
but can u put this in a normal cmd !
Quote:
if(strcmp(cmd, "/craft", true) == 0)
|
Re: command help -
RenSoprano - 25.11.2012
Yes,
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/yourcommand", true) == 0)
{
new choice[32];
if(sscanf(params, "s[32]", choice))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /yourcmd [name]");
SendClientMessageEx(playerid, COLOR_GREY, "Available names: optinon1, option2");
return 1;
}
if(strcmp(choice, "option1", true) == 0)
{
// Your code
return 1;
}
else if(strcmp(choice, "option2", true) == 0)
{
// Your code
return 1;
}
return 1;
}
return 0;
}
Re: command help -
Nordic - 25.11.2012
Quote:
Originally Posted by RenSoprano
Yes,
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmd, "/yourcommand", true) == 0) { new choice[32]; if(sscanf(params, "s[32]", choice)) { SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /yourcmd [name]"); SendClientMessageEx(playerid, COLOR_GREY, "Available names: optinon1, option2"); return 1; }
if(strcmp(choice, "option1", true) == 0) { // Your code return 1; } else if(strcmp(choice, "option2", true) == 0) { // Your code return 1; } return 1; } return 0; }
|
my lord, there is no params lol.
use strtok instead.