Help with textdraws.
#1

Hi, I have a problem with textdraws... With my function specifically.
Here we go, I made this function:
PHP код:
#define red 1
#define green 2
#define yellow 3
#define purple 4
#define blue 5
#define orange 6
new ColorTag[][] =
{
    {
red0xFF0000},
    {
green0x00FF00},
    {
yellow0xFFFF00},
    {
purple0xBB00FF},
    {
blue0x0000FF},
    {
orange0xFFAA00}
};
PTextDrawColor(playerididcolor)
{
    new 
idtag;
    for(new 
isizeof(ColorTag); i++)
    {
        if(
color == ColorTag[i][0])
        {
            
infoT[playerid][id][Color] = ColorTag[i][0];
            
//PlayerTextDrawColor(playerid, Textdraw[playerid][id], ColorTag[i][1]);
            
idtag ColorTag[i][1];
            
printf("______________%i, %x"ColorTag[i][0], ColorTag[i][1]); //It shows perfectly the hex color, but it doesn't change color
        
}
    }
    return 
PlayerTextDrawColor(playeridTextdraw[playerid][id], idtag);

But, for some reason, the textdraw color doesn't change... I "refresh" the textdraw(Showing it again) but it still doesn't work.
Shall I use an enum for the array? Just like this
Thanks for reading, I hope someone help me
Reply
#2

PHP код:
PTextDrawColor(playerididcolor

    new 
idtag
    for(new 
isizeof(ColorTag); i++) 
    { 
        if(
color == ColorTag[i][0]) 
        { 
            
infoT[playerid][id][Color] = ColorTag[i][0]; 
            
//PlayerTextDrawColor(playerid, Textdraw[playerid][id], ColorTag[i][1]); 
            
idtag ColorTag[i][1]; 
            
printf("______________%i, %x"ColorTag[i][0], ColorTag[i][1]); //It shows perfectly the hex color, but it doesn't change color 
            
PlayerTextDrawColor(playeridTextdraw[playerid][id], idtag); 
        } 
    } 
    return 
1;

Reply
#3

You might want to also add break; into the loop, it doesn't have to continue after the color was found.

Furthermore, your colors miss an Alpha value.

Hex format for colors is RRGGBBAA.

You can also just remove the idtag variable (and every line it is used) and uncomment PlayerTextDrawColor(...), then it'll work as expected.
Or keep the original code, the issue were the colors.
Reply
#4

Quote:
Originally Posted by Yaa
Посмотреть сообщение
PHP код:
PTextDrawColor(playerididcolor

    new 
idtag
    for(new 
isizeof(ColorTag); i++) 
    { 
        if(
color == ColorTag[i][0]) 
        { 
            
infoT[playerid][id][Color] = ColorTag[i][0]; 
            
//PlayerTextDrawColor(playerid, Textdraw[playerid][id], ColorTag[i][1]); 
            
idtag ColorTag[i][1]; 
            
printf("______________%i, %x"ColorTag[i][0], ColorTag[i][1]); //It shows perfectly the hex color, but it doesn't change color 
            
PlayerTextDrawColor(playeridTextdraw[playerid][id], idtag); 
        } 
    } 
    return 
1;

I already tried and didn't work.
Quote:
Originally Posted by NaS
Посмотреть сообщение
You might want to also add break; into the loop, it doesn't have to continue after the color was found.

Furthermore, your colors miss an Alpha value.

Hex format for colors is RRGGBBAA.

You can also just remove the idtag variable (and every line it is used) and uncomment PlayerTextDrawColor(...), then it'll work as expected.
It works, I didn't know it was necessary to use transparency.
Thanks for the suggestion about the break... I didn't thought about that.
If I remove idtag it won't work, as I need to return something
Reply
#5

Quote:
Originally Posted by Whillyrez
Посмотреть сообщение
I already tried and didn't work.

It works, I didn't know it was necessary to use transparency.
Thanks for the suggestion about the break... I didn't thought about that.
If I remove idtag it won't work, as I need to return something
You don't need to return anything.

You could add return 1; inside the loop, and 0 at the very end of the function - that way you can know if the function executed successfully.

Except you want the return value of the Color function or the array slot of the color of course
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)