sscanf multiple options command
#1

PHP код:
CMD:druglab(playeridparams[])
{
    new 
option[13], option2[13];
    
    
sscanf(params"s[13]"option);
    
    if(
isnull(option))
    {
        
SCM(playeridCOLOR_GREY"INFO: /druglab <optiune>");
        if(
PlayerInfo[playerid][pAdmin] >= 3)
        {
            
SCM(playeridCOLOR_WHITE"DRUGLAB ADMIN: "COL_GREY"create | move");
        }
        
SCM(playeridCOLOR_GREY"OPTIUNI: grantacces | hire | fire | lock | info");
    }
    else if(!
strcmp(option"info"))
    {
        
sscanf(params"s[13]"option2);
        
        if(
isnull(option2))
        {
            
SCM(playeridCOLOR_GREY"/druglab info <cmds/inv>");
        }
        else if(!
strcmp(option"cmds"))
        {
            if(
PlayerInfo[playerid][pAdmin] >= 3)
            {
                
SCM(playeridCOLOR_YELLOW">> /druglab create");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un druglab la pozitia playerului.");
                
SCM(playeridCOLOR_YELLOW" ");
                
SCM(playeridCOLOR_YELLOW">> /druglab move");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda muta locatia unui druglab.");
            }
            
SCM(playeridCOLOR_YELLOW">> /druglab grantacces");
            
SCM(playeridCOLOR_WHITE"Cu aceasta comanda poti da o cheie de la druglab altui jucator.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab hire");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un NPC la pozitia la care te afli.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab fire");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda sterge NPCul din druglab.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab lock");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda incuie druglab-ul.");
        }
    }
    return 
1;

It is working if I use like /druglab option
But I want that every option will also have a option.. above is what I tried, but it didn't work.
Example

/druglab info <cmds/inv>
Reply
#2

you are extracting string from params in both cases and also keep in mind that params is a string there isn't need of sscanf in this case.
Reply
#3

I removed sscanf from /druglab and only used it at option info, but it is not working either?
I mean, if it is null, the message appears but if I use /druglab info, nothing shows up.
PHP код:
CMD:druglab(playeridparams[])
{
    new 
option[13], option2[13];
    
    
//sscanf(params, "s[13]", option);
    
    
if(isnull(params))
    {
        
SCM(playeridCOLOR_GREY"INFO: /druglab <optiune>");
        if(
PlayerInfo[playerid][pAdmin] >= 3)
        {
            
SCM(playeridCOLOR_WHITE"DRUGLAB ADMIN: "COL_GREY"create | move");
        }
        
SCM(playeridCOLOR_GREY"OPTIUNI: grantacces | hire | fire | lock | info");
    }
    else if(!
strcmp(params"info"))
    {
        
sscanf(params"s[13]"option2);
        
        if(
isnull(option2))
        {
            
SCM(playeridCOLOR_GREY"/druglab info <cmds/inv>");
        }
        else if(!
strcmp(option2"cmds"))
        {
            if(
PlayerInfo[playerid][pAdmin] >= 3)
            {
                
SCM(playeridCOLOR_YELLOW">> /druglab create");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un druglab la pozitia playerului.");
                
SCM(playeridCOLOR_YELLOW" ");
                
SCM(playeridCOLOR_YELLOW">> /druglab move");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda muta locatia unui druglab.");
            }
            
SCM(playeridCOLOR_YELLOW">> /druglab grantacces");
            
SCM(playeridCOLOR_WHITE"Cu aceasta comanda poti da o cheie de la druglab altui jucator.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab hire");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un NPC la pozitia la care te afli.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab fire");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda sterge NPCul din druglab.");
            
SCM(playeridCOLOR_YELLOW" ");
            
SCM(playeridCOLOR_YELLOW">> /druglab lock");
            
SCM(playeridCOLOR_WHITE"Aceasta comanda incuie druglab-ul.");
        }
    }
    return 
1;

Reply
#4

because option variables are null it dont have any value check params in strcmp with constant strings
PS: I'm on phone therefore I can't give you an example sorry.
Reply
#5

Sorry but I really don't understand... can you show me an example?
Reply
#6

Use something like this:
Код:
if(sscanf(params, "s[13]s[13]", option, option2))
	{
instead of your:
Код:
sscanf(params, "s[13]", option);
and delete:
Код:
sscanf(params, "s[13]", option2);
I believe this should work
Reply
#7

PHP код:
CMD:druglab(playeridparams[])
{
    new 
option[13], option2[13];
    
    if(
sscanf(params"s[13]s[13]"optionoption2))
    {
        if(
isnull(option))
        {
            
SCM(playeridCOLOR_GREY"INFO: /druglab <optiune>");
            if(
PlayerInfo[playerid][pAdmin] >= 3)
            {
                
SCM(playeridCOLOR_WHITE"DRUGLAB ADMIN: "COL_GREY"create | move");
            }
            
SCM(playeridCOLOR_GREY"OPTIUNI: grantacces | hire | fire | lock | info");
        }
        else if(!
strcmp(option"info"))
        {
            if(
isnull(option2))
            {
                
SCM(playeridCOLOR_GREY"/druglab info <cmds/inv>");
            }
            else if(!
strcmp(option2"cmds"))
            {
                if(
PlayerInfo[playerid][pAdmin] >= 3)
                {
                    
SCM(playeridCOLOR_YELLOW">> /druglab create");
                    
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un druglab la pozitia playerului.");
                    
SCM(playeridCOLOR_YELLOW" ");
                    
SCM(playeridCOLOR_YELLOW">> /druglab move");
                    
SCM(playeridCOLOR_WHITE"Aceasta comanda muta locatia unui druglab.");
                }
                
SCM(playeridCOLOR_YELLOW">> /druglab grantacces");
                
SCM(playeridCOLOR_WHITE"Cu aceasta comanda poti da o cheie de la druglab altui jucator.");
                
SCM(playeridCOLOR_YELLOW" ");
                
SCM(playeridCOLOR_YELLOW">> /druglab hire");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda creaza un NPC la pozitia la care te afli.");
                
SCM(playeridCOLOR_YELLOW" ");
                
SCM(playeridCOLOR_YELLOW">> /druglab fire");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda sterge NPCul din druglab.");
                
SCM(playeridCOLOR_YELLOW" ");
                
SCM(playeridCOLOR_YELLOW">> /druglab lock");
                
SCM(playeridCOLOR_WHITE"Aceasta comanda incuie druglab-ul.");
            }
        }
    }
    return 
1;

It works if I type /druglab info, but it doesnt work if I type /druglab info cmds
Reply
#8

Код:
CMD:druglab(playerid, params[])
{
    new option[13], option2[13];

    if(sscanf(params, "s[13]s[13]", option, option2))
	{
	    SCM(playerid, COLOR_GREY, "INFO: /druglab <optiune>");
        if(PlayerInfo[playerid][pAdmin] >= 3)
        {
            SCM(playerid, COLOR_WHITE, "DRUGLAB ADMIN: "COL_GREY"create | move");
        }
        SCM(playerid, COLOR_GREY, "OPTIUNI: grantacces | hire | fire | lock | info");
	    return 1;
	}
    else if(!strcmp(option, "info"))
    {
            if(!strcmp(option2, "cmds"))
            {
                if(PlayerInfo[playerid][pAdmin] >= 3)
                {
                    SCM(playerid, COLOR_YELLOW, ">> /druglab create");
                    SCM(playerid, COLOR_WHITE, "Aceasta comanda creaza un druglab la pozitia playerului.");
                    SCM(playerid, COLOR_YELLOW, " ");
                    SCM(playerid, COLOR_YELLOW, ">> /druglab move");
                    SCM(playerid, COLOR_WHITE, "Aceasta comanda muta locatia unui druglab.");
                }
                SCM(playerid, COLOR_YELLOW, ">> /druglab grantacces");
                SCM(playerid, COLOR_WHITE, "Cu aceasta comanda poti da o cheie de la druglab altui jucator.");
                SCM(playerid, COLOR_YELLOW, " ");
                SCM(playerid, COLOR_YELLOW, ">> /druglab hire");
                SCM(playerid, COLOR_WHITE, "Aceasta comanda creaza un NPC la pozitia la care te afli.");
                SCM(playerid, COLOR_YELLOW, " ");
                SCM(playerid, COLOR_YELLOW, ">> /druglab fire");
                SCM(playerid, COLOR_WHITE, "Aceasta comanda sterge NPCul din druglab.");
                SCM(playerid, COLOR_YELLOW, " ");
                SCM(playerid, COLOR_YELLOW, ">> /druglab lock");
                SCM(playerid, COLOR_WHITE, "Aceasta comanda incuie druglab-ul.");
            }
    }
    return 1;
}
Try this
Reply
#9

It works but not as I want...
If the player type
/druglab info
it will show him the options
/druglab info <cmds/inv>
then if he type /druglab info cmds
it will trigger the code that I put there..
is this really impossible to do :/
Reply
#10

Код:
if(sscanf(params, "s[13]s[13]", option, option2))
	{
	    if(isnull(option))
        {
           //here put /druglab info
        }
        else if(isnull(option2))
        {
            //here put /druglab info <cmds/inv>
        }
	    return 1;
	}
so just edit this part of the code and it should work the way you want it to
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)