PDA

View Full Version : Showing option 1, for all options of a single command


Deal-or-die
17/09/2012, 12:57 PM
Okay... As mind f***ing as you might have found the title, I'll try explain a little better.

This is my command
/create

with the option of choosing
House, Business or faction.

When I type
/create house - it displays the house menu
/create business - it displays the house menu
/create faction - it displays the house menu

Eh... Not what I want... haha
I want
/create house - house menu
/create business - Business menu(Eventually, not at the moment)
/create faction - Faction menu(Eventually, not at the moment)


Code

command(create, playerid, params[])
{
if(Player[playerid][pAdmin] <= 4) SendClientMessage(playerid, COLOR_RED, "You're not authorised to use this command");
if(Player[playerid][pAdmin] >= 3 && Player[playerid][pAdminDuty] == 0) SendClientMessage(playerid,COLOR_GREY,"You cannot use this while not on admin duty.");
else
{
new option[20];
if(isnull(params)) // if they didn't type anything after /create
{
// tell em how to use it.
return SendClientMessage(playerid, -1, "USAGE: /create [house/business/faction]");
}
if(!strcmp(option, "house", true))
{
ShowPlayerDialog(playerid, 160, DIALOG_STYLE_LIST, "House Creation Menu", "Set Exterior Position\r\nSet Interior Position\r\nSet Lock\r\nSet Alarm\r\nSet Address\r\nSet Number of Rooms\r\nSet number of Vehicle slots\r\nSet House Price\r\nFinalise","Continue","Close");
Create[playerid][cType] = 1;
return 1;
}
if(!strcmp(option, "business", true))
{
// ShowPlayerDialog(playerid, 170, DIALOG_STYLE_LIST, "Business Creation Menu", "Business Name\r\nSet Business Type\r\nSet Exterior Position\r\nSet Interior Position\r\nSet Lock\r\nSet Alarm\r\nSet Address\r\nSet Business Price\r\nFinalise","Select","Cancel");
// Create[playerid][cType] = 2;
SendClientMessage(playerid,COLOR_WHITE,"Please {FF0000}Note{FFFFFF}: This Option is comming soon.");
return 1;
}
if(!strcmp(option, "faction", true))
{
// ShowPlayerDialog(playerid, 180, DIALOG_STYLE_LIST, "Faction Creation Menu", "Faction Name\r\nFaction Type\r\nGovernment Faction\r\nSub Ranks\r\nPrimary Faction\r\nFaction Leader","Select","Cancel")
Create[playerid][cType] = 3;
SendClientMessage(playerid,COLOR_WHITE,"Please {FF0000}Note{FFFFFF}: This entire faction system is due for a complete re-build, and should only be use primarily as an example.");
return 1;
}
}
return 1;
}

Vince
17/09/2012, 01:46 PM
Your option variable is empty!

Deal-or-die
17/09/2012, 02:16 PM
Ahhh... So a suggestion on how to fix that haha, sorry, once I get on example I'll be right :P

Cheers for the response though :P

Deal-or-die
18/09/2012, 11:09 AM
Hey ahh,
Sorry for asking again just still haven't got this sorted yet :P

How can I store/set my 'option' in my 'option variable'?

Cheers.

clarencecuzz
18/09/2012, 11:14 AM
if(sscanf(params("s",option)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX: /CREATE [House/Business/Faction]");

The first few lines should look like this:
command(create, playerid, params[])
{
new option[20];
if(sscanf(params,"s",option)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX: /CREATE [House/Business/Faction]");
//Code continues...

NOTE: You will need the SSCANF2 include and plugin. It's not neccessary but it's recommended.

Deal-or-die
18/09/2012, 11:29 AM
Ahh of course!


Cheers mate.
Yea, of course :P(Referring to the SSCANF2 inc)