sscanf multiple options command -
AndreiWow - 10.02.2017
PHP код:
CMD:druglab(playerid, params[])
{
new option[13], option2[13];
sscanf(params, "s[13]", option);
if(isnull(option))
{
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");
}
else if(!strcmp(option, "info"))
{
sscanf(params, "s[13]", option2);
if(isnull(option2))
{
SCM(playerid, COLOR_GREY, "/druglab info <cmds/inv>");
}
else if(!strcmp(option, "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;
}
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>
Re: sscanf multiple options command -
SyS - 10.02.2017
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.
Re: sscanf multiple options command -
AndreiWow - 10.02.2017
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(playerid, params[])
{
new option[13], option2[13];
//sscanf(params, "s[13]", option);
if(isnull(params))
{
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");
}
else if(!strcmp(params, "info"))
{
sscanf(params, "s[13]", option2);
if(isnull(option2))
{
SCM(playerid, COLOR_GREY, "/druglab info <cmds/inv>");
}
else 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;
}
Re: sscanf multiple options command -
SyS - 10.02.2017
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.
Re: sscanf multiple options command -
AndreiWow - 10.02.2017
Sorry but I really don't understand... can you show me an example?
Re: sscanf multiple options command -
Type-R - 10.02.2017
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
Re: sscanf multiple options command -
AndreiWow - 10.02.2017
PHP код:
CMD:druglab(playerid, params[])
{
new option[13], option2[13];
if(sscanf(params, "s[13]s[13]", option, option2))
{
if(isnull(option))
{
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");
}
else if(!strcmp(option, "info"))
{
if(isnull(option2))
{
SCM(playerid, COLOR_GREY, "/druglab info <cmds/inv>");
}
else 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;
}
It works if I type /druglab info, but it doesnt work if I type /druglab info cmds
Re: sscanf multiple options command -
Type-R - 10.02.2017
Код:
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
Re: sscanf multiple options command -
AndreiWow - 10.02.2017
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 :/
Re: sscanf multiple options command -
Type-R - 10.02.2017
Код:
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