Question about dialog
#1

Hey guys,

I'm currently working on a dynamic faction system and I want to know if is there any way I can check if a color is already used by an existing faction or not. If it's not used I want it to appear on my dialog where you can select the color for the faction.

To be more specific this is the code for my dialog

Код:
ShowPlayerDialog(playerid, dfcolor, DIALOG_STYLE_LIST, "Choose faction color", "Black\nWhite\nOrange\nRed\nBlue\nViolet\nGreen\nYellow\nPink\nSeablue\nBrown", "Choose", "Back");
Is there any way I can check if another faction uses for example the Orange color and remove it from the list?
Reply
#2

Well load your database / filesystem and check if the color was already used by a faction ?

pawn Код:
new string[128];

if(/* Black wasn't used*/) {
    strcat(string, "Black\n");
}
if(/* White wasn't used*/) {
    strcat(string, "White\n");
}
// ...
// At the end remove the last '\n'
string[strlen(string) - 1] = EOS;

ShowPlayerDialog(playerid, dfcolor, DIALOG_STYLE_LIST, "Choose faction color", string, "Choose", "Back");
Reply
#3

Haven't tested it though...

pawn Код:
new ColorNames[11][] =
{
    "Black", "White", "Orange", "Red", "Blue", "Violet", "Green", "Yellow", "Pink", "Seablue", "Brown"
};
new bool:IsColorTaken[11];
//Dialog:
pawn Код:
new string[128] = " ";
for(new fac; fac<11; fac++)
{
    if(IsColorTaken[fac] == false)
    {
        format(string, sizeof(string), "%s\n%s", string, ColorNames[fac]);
    }
}
ShowPlayerDialog(playerid, dfcolor, DIALOG_STYLE_LIST, "Choose faction color", string, "Choose", "Back");
And when player selects the color, make sure you set the value if IsColorTaken to true. So black = 0, white = 1, orange = 2 ... seablue = 9 and brown = 10
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)