Embedded colours - 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: Embedded colours (
/showthread.php?tid=367045)
Embedded colours -
Luis- - 08.08.2012
Hi. I want to use embedded colours in my dialog but in a different way. I know how to use them etc, I want to use them like this.
Example:
I have a dialog which is looped in an array for example, teleports and I want to do this,
Teleport 1
Teleport 2
Teleport 3
Teleport 4
And that keeps going until the loop ends.
Thanks.
Re: Embedded colours -
Killer#Mummy - 08.08.2012
Simply create a variable before the loop:
Then you switch between 1 and 0 each loop:
pawn Код:
for(......)
{
if(ColorOption == 0)
{
ColorOption = 1;
//code for red color
}
else
{
ColorOption = 0
//code for green color
}
}
I hope you understand what I mean.
Re: Embedded colours -
Roko_foko - 08.08.2012
for(i=0;i<Max;i++)
if(i%2==0)RED
else GREEN
Hope this helps you
Re: Embedded colours -
Luis- - 08.08.2012
I know there is a simpler yet efficient way of doing it. Thanks though.
This is what my code looks like.
pawn Код:
stock GetTeles(playerid) {
new string[1000];
for(new i = 0; i < sizeof(TeleportsPos); i++) {
format(string, sizeof string, "%s%s\n", string, TeleportsPos[i][Name]);
}
ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleports", string, "Teleport", "Cancel");
return 1;
}
Re: Embedded colours -
Roko_foko - 08.08.2012
This is the most optimased I can think of:
pawn Код:
stock GetTeles(playerid) {
new string[1000];
for(new i = 0; i < sizeof(TeleportsPos); i++) {
format(string, sizeof string, "%s%s%s\n", string,(i%2)?("{FF0000}"):("{00FF00}"), TeleportsPos[i][Name]);
}
ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleports", string, "Teleport", "Cancel");
return 1;
}
Re: Embedded colours -
Vince - 08.08.2012
Mod is slow though. Bitwise and is much faster.
pawn Код:
format(string, sizeof string, "%s%s%s\n", string, (i & 1) ? ("{FF0000}") : ("{00FF00}"), TeleportsPos[i][Name]);