Page 1 of 1

Hud .label

Posted: November 5th, 2011, 4:18 pm
by Moustache
Sorry for filling the forum with my questions :oops:
This one will be the last for now :P

What is wrong with my hud? How is it possible that I only see the iPrintLnBolds and the hud Message 1 and Message end?

Code: Select all

HUD_TEST()
{
        if( isDefined( self.HUD_text ))
                self.HUD_text destroy();
 
        wait 0.05;
 
        self.HUD_text = newClientHudElem( self );
        self.HUD_text.x = -300;
        self.HUD_text.y = 300;
        self.HUD_text.horzAlign = "center_safearea";
        self.HUD_text.vertAlign = "top";
        self.HUD_text.alignX = "left";
        self.HUD_text.alignY = "middle";
        self.HUD_text.sort = 102;
        self.HUD_text.foreground = 1;
        self.HUD_text.archived = false;
        self.HUD_text.alpha = 1;
        self.HUD_text.fontScale = 1.9;
        self.HUD_text.hidewheninmenu = false;
        self.HUD_text.color = (.99, .99, .99);
 
        i = 3;
        
        special = "Special message";
        while(1)
        {
                        self.HUD_text.label = &"Message 1"; // I see this one
self iPrintLnBold( "1" );
wait i;
                        self.HUD_text.label = special; // This one fails
self iPrintLnBold( "2" );
wait i;
                        self.HUD_text.label = &"" + special; // This one fails
self iPrintLnBold( "3" );
wait i;
                        self.HUD_text.label = &" " + special; // This one fails
self iPrintLnBold( "4" );
wait i;
                        self.HUD_text.label = &"" + special + ""; // This one fails
self iPrintLnBold( "5" );
wait i;
                        self.HUD_text.label = &" " + special + " "; // This one fails
self iPrintLnBold( "6" );
wait i;
                        self.HUD_text.label = &"Message end"; // And I see this one
self iPrintLnBold( "7" );
wait i;
        }
}

Re: Hud .label

Posted: November 5th, 2011, 7:25 pm
by Drofder2004
I believe the "&" makes the game treat the text as localised.

Try adding it to the variable definition
var = &"Hello";

Also, if you're not going to use the 'value' portion of this, then you might aswell use setText()

And finally, in CoD4 onwards, for text, you should use "createFontString" for client huds or "createServerFontString" for global huds.

Re: Hud .label

Posted: November 6th, 2011, 10:15 am
by Moustache
Drofder2004 wrote:I believe the "&" makes the game treat the text as localised.

Try adding it to the variable definition
var = &"Hello";
Thank that worked perfect. But when I try to combine tow localized strings like this:

Code: Select all

var1 = &"Hello";
var2 = &"Sir";
level.special1 = var1 + var2;
 
/*
I get this error:
******* script runtime error *******
pair 'Hello' and 'Sir' has unmatching types 'localized string' and 'localized string': (file 'maps/mp/gametypes/_test.gsc', line 32)
level.special1 = var1 + var2;
*/
Drofder2004 wrote:Also, if you're not going to use the 'value' portion of this, then you might aswell use setText()
I have used that before but it rewarded me with this error after a while:
Player_Name G_FindConfigstringIndex: overflow [309]: 'HUD_Element'
Drofder2004 wrote:And finally, in CoD4 onwards, for text, you should use "createFontString" for client huds or "createServerFontString" for global huds.
Thank you I will keep that in mind :)

Re: Hud .label

Posted: November 6th, 2011, 2:33 pm
by Drofder2004
You cannot combine two localised strings.

You may be able to localise two normal strings.
Try:
level.special = &"" + var1 + var2

Or
level.special = var1 + var2
level.special = &level.special

Re: Hud .label

Posted: November 6th, 2011, 3:30 pm
by Moustache
Drofder2004 wrote:You cannot combine two localised strings.

You may be able to localise two normal strings.
Try:
level.special = &"" + var1 + var2

Or
level.special = var1 + var2
level.special = &level.special
That doesn't work either.
I have fixed it the noob and just make one var out of it. Now there are a few lines more code but that isn't a problem of course.

Thanks for the info and all the help :)