Command + a word - 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 + a word (
/showthread.php?tid=407531)
Command + a word -
Zex Tan - 14.01.2013
Hello, I want to create a /help command but I want it like this
Ermmm.... How to create like that type of command with the word "cmds"
Re: Command + a word -
Konstantinos - 14.01.2013
pawn Код:
CMD:help( playerid, params[ ] )
{
if( !strcmp( params, "cmds", true ) )
{
// code for /help cmds
}
return 1;
}
Re: Command + a word -
Zex Tan - 14.01.2013
Quote:
Originally Posted by Dwane
pawn Код:
CMD:help( playerid, params[ ] ) { if( !strcmp( params, "cmds", true ) ) { // code for /help cmds } return 1; }
|
Is there anything other then strcmp
If no, then Thanks for Helping me Out
Re: Command + a word -
LarzI - 14.01.2013
Quote:
Originally Posted by Zex Tan
Is there anything other then strcmp If no, then Thanks for Helping me Out
|
No there isn't. Why would you want anything else? This is the fastest and probably most efficient way of doing this certain thing.
Re: Command + a word -
mineralo - 14.01.2013
pawn Код:
OnPlayerCommandText(playerid,cmdtext);
{
new cmd[256],idx,tmp[256];
cmd = strtok(cmdtext,idx);
if(!strcmp(cmd,"/help",true))
{
tmp = strtok(cmdtext,idx);
if(!strcmp(tmp,"cmds",true))
{
//your codes
}
return 1;
}
return 1;
}
Re: Command + a word -
Konstantinos - 14.01.2013
Quote:
Originally Posted by mineralo
pawn Код:
OnPlayerCommandText(playerid,cmdtext); { new cmd[256],idx,tmp[256]; cmd = strtok(cmdtext,idx); if(!strcmp(cmd,"/help",true)) { tmp = strtok(cmdtext,idx); if(!strcmp(tmp,"cmds",true)) { //your codes } return 1; } return 1; }
|
A lot of waste of memory here! 2 strings with size of 256, when the limit is 128.
Strcmp as a command processor (Basically, it is not even a command processor) and strtok are slow.
You should return 0 at the end of the callback.
Re: Command + a word -
mineralo - 14.01.2013
I just showed a method, he could use or edit it or to get a view how to script his own codes
Re: Command + a word -
Zex Tan - 14.01.2013
Alright, Thanks for the help Dwane and LarzI