Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!
Moderator: Core Staff
-
Moustache
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Post
by Moustache » November 5th, 2011, 4:18 pm
Sorry for filling the forum with my questions
This one will be the last for now
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;
}
}
-
Drofder2004
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » November 5th, 2011, 7:25 pm
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.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
Moustache
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Post
by Moustache » November 6th, 2011, 10:15 am
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
-
Drofder2004
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » November 6th, 2011, 2:33 pm
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
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
Moustache
- CJ Worshipper
- Posts: 476
- Joined: August 18th, 2008, 9:30 am
Post
by Moustache » November 6th, 2011, 3:30 pm
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
Users browsing this forum: No registered users and 39 guests