Very simple Question( Rep+ )
#1

1.
How do I make it so I can use for example strcmp on /help so thered be /help and it'd show three options, General, Commands, Admins, then the player would type /help commands or /help admins etc I know i'd have to use strcmp I just dont know how.
Reply
#2

pawn Код:
YCMD:help(playerid, help, params)
{
        if(strcmp(params, "commands", false) == 0)
    {
               SendClientMessage(playerid, -1, "Help commands here.");
           return 1;
    }
    else if(strcmp(params, "admin", false) == 0)
    {
        SendClientMessage(playerid, -1, "Admin help here.");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "Usage: /help [parameter] (commands, admin)");
        return 1;
    }
Reply
#3

pawn Код:
CMD:help(playerid, params[])
{
    if ( isnull ( params ) ) return SendClientMessage( playerid, -1, #Usage /help <commands, admins, general> );
   
    if ( !strcmp ( params, "commands" ) )
    {
        // do your code
    }
    else if ( !strcmp ( params, "admins" ) )
    {
        // do your code
    }
    else
    {
        SendClientMessage( playerid, -1, #Unknown parameter );
    }
   
    return 1;
}
Reply
#4

Quote:
Originally Posted by antonio112
Посмотреть сообщение
pawn Код:
YCMD:help(playerid, help, params)
{
        if(strcmp(params, "commands", false) == 0)
    {
               SendClientMessage(playerid, -1, "Help commands here.");
           return 1;
    }
    else if(strcmp(params, "admin", false) == 0)
    {
        SendClientMessage(playerid, -1, "Admin help here.");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "Usage: /help [parameter] (commands, admin)");
        return 1;
    }
Now can you please explain what the STRCMP does, like what does the false and ==0 mean?
Reply
#5

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
Now can you please explain what the STRCMP does, like what does the false and ==0 mean?
strcmp = string compare
0 = if they match.
https://sampwiki.blast.hk/wiki/Strcmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)