Question about dialog - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about dialog (
/showthread.php?tid=554742)
Question about dialog -
Nightkill - 04.01.2015
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?
AW: Question about dialog -
Nero_3D - 04.01.2015
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");
Re: Question about dialog -
Schneider - 04.01.2015
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