command help
#1

hi
can any one show me an example of a command like this /craft [option1/option2]
Reply
#2

you mean /rules? or what?
Reply
#3

hopefully this has what you need: https://sampwiki.blast.hk/wiki/Creating_Commands
Reply
#4

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

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)

Reply
#6

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)