3D Text Labels
#1


(Click the image to see it fullscreen)

I've got this problem. No matter what color I change it to, it stays that exact color and transparency. Here's the code I use;

pawn Код:
case DIALOG_ENTRANCES_EDIT_COLOUR:
        {
            if( response )
            {
                if( isnull( inputtext ) || strlen( inputtext ) > 14 )
                {
                    new
                        cStr [ 32 ],
                        iStr [ 128 ];

                    format( cStr, 32, "Editing: Entrance #%d", plEditingEntrance [ playerid ] );
                    format( iStr, 128, ""#I_RoyalBlue"Current Colour: "#I_White"%s\n\nEntry Point colour is the colour that you see the pickup text as.", EntranceInfo [ plEditingEntrance[ playerid ] ] [ Colour ] );
                    ShowPlayerDialog( playerid, DIALOG_ENTRANCES_EDIT_COLOUR, DIALOG_STYLE_INPUT, cStr, iStr, "Change", "Back" );
                    return false;
                }

                new
                    Str [ 128 ];

                format( EntranceInfo [ plEditingEntrance [ playerid ] ] [ Colour ], 15, inputtext );
                SaveEntrance( plEditingEntrance [ playerid ] );
                LoadEntrance( plEditingEntrance [ playerid ] );

                format( Str, 128, "* Entry Point #"#I_LimeGreen"%d's "#I_White"colour has been set to "#I_RoyalBlue"%s", plEditingEntrance [ playerid ], inputtext );
                SendClientMessage( playerid, -1, Str );
            }
        }
I've already debugged it, and the EntranceInfo for Colour IS being set correctly. So what's the problem?
Reply
#2

I don't see any script that changes the colour of the text, like an Update3DTextLabelText
Reply
#3

Right, forgot to post the LoadEntrance code.

pawn Код:
// ================================== [ DYNAMIC ENTRANCES ] =============================================

public LoadEntrance( entranceid )
{
    new
        nameStr [ 128 ];
       
    INI_ParseFile( FindEntranceFile( entranceid ), "LoadEntrance_%s", .bExtra = true, .extra = entranceid );
   
    if( eSpawned [ entranceid ] == false )
    {
        ePickup [ entranceid ] = CreateDynamicPickup( EntranceInfo [ entranceid ] [ Icon ], 1, EntranceInfo [ entranceid ] [ eX ], EntranceInfo [ entranceid ] [ eY ], EntranceInfo [ entranceid ] [ eZ ], EntranceInfo [ entranceid ] [ VirtualWorld ], EntranceInfo [ entranceid ] [ Interior ], -1, 100.0 );

        format( nameStr, 128, "%s", EntranceInfo [ entranceid ] [ Name ] );
        eLabel [ entranceid ] = Create3DTextLabel( nameStr, EntranceInfo [ entranceid ] [ Colour ], EntranceInfo [ entranceid ] [ eX ], EntranceInfo [ entranceid ] [ eY ], EntranceInfo [ entranceid ] [ eZ ], 10.0, EntranceInfo [ entranceid ] [ VirtualWorld ], 0 );

        eSpawned [ entranceid ] = true;
    }
    else
    {
        DestroyDynamicPickup( ePickup [ entranceid ] );
        Delete3DTextLabel( eLabel [ entranceid ] );
        eSpawned [ entranceid ] = false;
       
        ePickup [ entranceid ] = CreateDynamicPickup( EntranceInfo [ entranceid ] [ Icon ], 1, EntranceInfo [ entranceid ] [ eX ], EntranceInfo [ entranceid ] [ eY ], EntranceInfo [ entranceid ] [ eZ ], EntranceInfo [ entranceid ] [ VirtualWorld ], EntranceInfo [ entranceid ] [ Interior ], -1, 100.0 );

        format( nameStr, 128, "%s", EntranceInfo [ entranceid ] [ Name ] );
        eLabel [ entranceid ] = Create3DTextLabel( nameStr, EntranceInfo [ entranceid ] [ Colour ], EntranceInfo [ entranceid ] [ eX ], EntranceInfo [ entranceid ] [ eY ], EntranceInfo [ entranceid ] [ eZ ], 10.0, EntranceInfo [ entranceid ] [ VirtualWorld ], 0 );

        eSpawned [ entranceid ] = true;
    }
    return true;
}

public SaveEntrance( entranceid )
{
    if( !fexist( FindEntranceFile( entranceid ) ) ) return false;
   
    new
        INI: eFile = INI_Open( FindEntranceFile( entranceid ) );
       
    INI_SetTag( eFile, "data" );
   
    INI_WriteString( eFile,         "E_NAME",               EntranceInfo [ entranceid ] [ Name ] );
    INI_WriteInt( eFile,            "E_ICON",               EntranceInfo [ entranceid ] [ Icon ] );
    INI_WriteInt( eFile,            "E_OPEN",               EntranceInfo [ entranceid ] [ Open ] );
    INI_WriteString( eFile,         "E_COLOUR",             EntranceInfo [ entranceid ] [ Colour ] );
   
    INI_WriteFloat( eFile,          "E_X",                  EntranceInfo [ entranceid ] [ eX ] );
    INI_WriteFloat( eFile,          "E_Y",                  EntranceInfo [ entranceid ] [ eY ] );
    INI_WriteFloat( eFile,          "E_Z",                  EntranceInfo [ entranceid ] [ eZ ] );
    INI_WriteInt( eFile,            "E_INT",                EntranceInfo [ entranceid ] [ Interior ] );
    INI_WriteInt( eFile,            "E_VIRTUALWORLD",       EntranceInfo [ entranceid ] [ VirtualWorld ] );
   
    INI_WriteFloat( eFile,          "I_X",                  EntranceInfo [ entranceid ] [ iX ] );
    INI_WriteFloat( eFile,          "I_Y",                  EntranceInfo [ entranceid ] [ iY ] );
    INI_WriteFloat( eFile,          "I_Z",                  EntranceInfo [ entranceid ] [ iZ ] );
    INI_WriteInt( eFile,            "I_INT",                EntranceInfo [ entranceid ] [ iInt ] );
    INI_WriteInt( eFile,            "I_VIRTUALWORLD",       EntranceInfo [ entranceid ] [ iVirtualWorld ] );
   
    INI_Close( eFile );
    return true;
}
Reply
#4

The problem is the string! If you try to get the hex color as a string. It wont ever work for you anywhere.

You need to get the integer value of the hex color from the string first using the function below.

pawn Код:
stock hexstr(string[]) // By ******
{
    new ret,val,i;
    if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) i = 2;
    while (string[i])
    {
        ret <<= 4;
        val = string[i++] - '0';
        if (val > 0x09) val -= 0x07;
        if (val > 0x0F) val -= 0x20;
        if (val < 0x01) continue;
        if (val < 0x10) ret += val;
    }
    return ret;
}
EDIT:

Quote:
Originally Posted by cessil
Посмотреть сообщение
I don't see any script that changes the colour of the text, like an Update3DTextLabelText
That function can easily be made! Deleting a 3DTextLabel and Creating it again with the given color , with the same name.
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
The problem is the string! If you try to get the hex color as a string. It wont ever work for you anywhere.

You need to get the integer value of the hex color from the string first using the function below.

pawn Код:
stock hexstr(string[]) // By ******
{
    new ret,val,i;
    if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) i = 2;
    while (string[i])
    {
        ret <<= 4;
        val = string[i++] - '0';
        if (val > 0x09) val -= 0x07;
        if (val > 0x0F) val -= 0x20;
        if (val < 0x01) continue;
        if (val < 0x10) ret += val;
    }
    return ret;
}
EDIT:



That function can easily be made! Deleting a 3DTextLabel and Creating it again with the given color , with the same name.
Thank you VERY VERY much! Hexstr was what I needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)