PDA

View Full Version : precacheString(variable)



Loveboy
15th March 2014, 14:25
Hello Guys!

I want to preache a string, what is defined as a variable for a text.
I have got there problems and that won't be precached.

As first I call the thread where the text will be showed:



text(&"Test");


Then I wrote the function:



text(text)
{
self.texthud = newHudElem();
self.texthud.alignx = "center";
self.texthud.aligny = "middle";
self.texthud.x = 320;
self.texthud.y = 240;
self.texthud.fontscale = 2.0;
self.texthud.alpha = 0;
self.texthud setText(text); // HERE THE TEXT WHAT IS AS A VARIABLE DEFINED

//self iprintlnbold("text spawned");
}


But if I want to precache it on my script (called from startGametype()) then it just won't show the text:



precacheStuffs()
{
precacheString(text); //here is the text undefined, so no idea how I can precache it perfect
}


I already looked up if the text bugs, but there is no problem

Can somebody help me please and say how I can precache the variable (text)?

kung foo man
15th March 2014, 14:48
The "normal" way is like:



precacheAll() {
game["someTextA"] = &"some text for your hud A ";
game["someTextB"] = &"some text for your hud B";
game["someTextC"] = &"some text for your hud C";
precacheString(game["someTextA"]);
precacheString(game["someTextB"]);
precacheString(game["someTextC"]);
}

self.someHudA setText(game["someTextA"]);
self.someHudB setText(game["someTextB"]);
self.someHudC setText(game["someTextC"]);


Also it's just misleading to name the paramater as the function ala text(text). Meaningful names are important or your scripts are preventable hard to make sense of.

Loveboy
15th March 2014, 14:54
Yes, but it's a longer way, I just wanna do a short way to do a text (like iprintln[bold]).
If it's possible to do my way, then it would be nice and much easier :D

So just text(&"Mytext");

Edit: I will report you if I found a result

Tally
15th March 2014, 15:45
Hello Guys!

I want to preache a string, what is defined as a variable for a text.
I have got there problems and that won't be precached.

As first I call the thread where the text will be showed:



text(&"Test");


Then I wrote the function:



text(text)
{
self.texthud = newHudElem();
self.texthud.alignx = "center";
self.texthud.aligny = "middle";
self.texthud.x = 320;
self.texthud.y = 240;
self.texthud.fontscale = 2.0;
self.texthud.alpha = 0;
self.texthud setText(text); // HERE THE TEXT WHAT IS AS A VARIABLE DEFINED

//self iprintlnbold("text spawned");
}


But if I want to precache it on my script (called from startGametype()) then it just won't show the text:



precacheStuffs()
{
precacheString(text); //here is the text undefined, so no idea how I can precache it perfect
}


I already looked up if the text bugs, but there is no problem

Can somebody help me please and say how I can precache the variable (text)?

You are calling a level hud element on a client. Maybe that's why it wont work:


self.textHud = newClientHudElem( self );

Loveboy
15th March 2014, 15:48
Can't I use maybe something else (not .label or setText()) for setting a text without precaching?

Tally
15th March 2014, 16:19
Can't I use maybe something else (not .label or setText()) for setting a text without precaching?

You cannot use text in a hud element without precaching it. You can in iprintln()/iprintlnbold(), but not in a hud element.

Loveboy
15th March 2014, 16:49
And that's why I asked here, I just wanted something like iprintln()/iprintlnbold(), but I think it's hard scripted

IzNoGoD
15th March 2014, 20:16
hud setplayernamestring(player); is possible.

I've heard something about setmapnamestring() too, but i cannot confirm/deny anything. (you didnt hear it from me)

Tally
15th March 2014, 20:37
hud setplayernamestring(player); is possible.

I've heard something about setmapnamestring() too, but i cannot confirm/deny anything. (you didnt hear it from me)

setmapnamestring() is a COD4 function. As is setgametypestring().

Mitch
15th March 2014, 20:46
setmapnamestring() is a COD4 function. As is setgametypestring().

Both function should work in CoD2 too.