Results 1 to 10 of 10

Thread: precacheString(variable)

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    precacheString(variable)

    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:

    Code:
    text(&"Test");
    Then I wrote the function:

    Code:
    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:

    Code:
    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)?

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    The "normal" way is like:

    PHP Code:
    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.
    timescale 0.01

  3. #3
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    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

    So just text(&"Mytext");

    Edit: I will report you if I found a result
    Last edited by Loveboy; 15th March 2014 at 14:21.

  4. #4
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Loveboy View Post
    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:

    Code:
    text(&"Test");
    Then I wrote the function:

    Code:
    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:

    Code:
    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:

    Code:
    self.textHud = newClientHudElem( self );
    Last edited by Tally; 15th March 2014 at 14:48.

  5. #5
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Can't I use maybe something else (not .label or setText()) for setting a text without precaching?

  6. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Loveboy View Post
    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.

  7. #7
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    And that's why I asked here, I just wanted something like iprintln()/iprintlnbold(), but I think it's hard scripted

  8. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    hud setplayernamestring(player); is possible.

    I've heard something about setmapnamestring() too, but i cannot confirm/deny anything. (you didnt hear it from me)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. #9
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    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().
    Last edited by Tally; 15th March 2014 at 19:39.

  10. #10
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Tally View Post
    setmapnamestring() is a COD4 function. As is setgametypestring().
    Both function should work in CoD2 too.

  11. The Following User Says Thank You to Mitch For This Useful Post:

    Ni3ls (15th March 2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •