Mutliple Strings in Commands
#1

Hey,

I was wondering how I would use something like strings in commands with Zcmd and Sscanf.

I am basically looking to create a '/duty' command for factions and jobs to use but I want to place it into one command. For example, if someone was in a cop they would do '/duty cop' to get their equipment or if someone had the taxi driver job and wanted to go on-duty they would do '/duty job'.

I know how to do this with integers in switches, just not sure with strings as this would make some of my commands a lot easier to use.

Thanks in advance.
Reply
#2

Just an example:

pawn Код:
CMD:duty(playerid, params[])
{
    new option[24];
    if(sscanf(params, "s[24]", option)) return SendClientMessage(playerid, -1, "Usage: /duty [job/faction]");
    if(!strcmp(option, "cop", true)) //If they  typed cop for the option
    {
        //Do something
    }
    else if(!strcmp(option, "taxi", true)) //If they  typed taxi for the option
    {
        //Do something
    }
    else return SendClientMessage(playerid, -1, "Incorrect option!");
    return 1;
}
Reply
#3

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Just an example:

pawn Код:
CMD:duty(playerid, params[])
{
    new option[24];
    if(sscanf(params, "s[24]", option)) return SendClientMessage(playerid, -1, "Usage: /duty [job/faction]");
    if(!strcmp(option, "cop", true)) //If they  typed cop for the option
    {
        //Do something
    }
    else if(!strcmp(option, "taxi", true)) //If they  typed taxi for the option
    {
        //Do something
    }
    else return SendClientMessage(playerid, -1, "Incorrect option!");
    return 1;
}
Thanks for that, it was just what I was looking for!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)