Command + a word
#1

Hello, I want to create a /help command but I want it like this

Код:
/help cmds
Ermmm.... How to create like that type of command with the word "cmds"
Reply
#2

pawn Код:
CMD:help( playerid, params[ ] )
{
    if( !strcmp( params, "cmds", true ) )
    {
        // code for /help cmds
    }
    return 1;
}
Reply
#3

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
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

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.
Reply
#7

I just showed a method, he could use or edit it or to get a view how to script his own codes
Reply
#8

Alright, Thanks for the help Dwane and LarzI
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)