Results 1 to 9 of 9

Thread: Huds appears invisible sometime.. weird :/

  1. #1
    Private
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    13
    Thanked 4 Times in 3 Posts

    Huds appears invisible sometime.. weird :/

    Hello everybody,
    i have a problem with my Huds, "They work" but sometime in the server, some huds appears invisible.
    i thought i had too many of Huds but nop with only 3 Huds in a mod zom: Money, streak and nade
    these 3 Huds bugs often.
    However the script Money and streak are the only that i isn't make. I took from killtube when i started to make scripts.

    i tried to do some test about it:
    1)On all the functions, put:
    -thread maps\mp\gametypes\_scripts::money();
    -thread maps\mp\gametypes\_scripts::streak();
    it dont work.
    2)i'm making a thing in menu ingame when it dont work:
    6.reload Huds
    script:
    PHP Code:
    if(response == reload)
    {
    thread maps\mp\gametypes\_scripts::money();
    thread maps\mp\gametypes\_scripts::streak();
    self iprintlnbold("huds reloaded");

    i have the message but it dont work..
    someone have a idea ?

    money script and streak script:
    PHP Code:
    money()
    {
        
    self.hudmoney newClientHudElem(self);
        
    self.hudmoney.alignx "right";
        
    self.hudmoney.610;
        
    self.hudmoney.285
        
    self.hudmoney.fontscale 1.4;
        
    self.hudmoney.label = &"^7Money^1: &&1^7$";
        
        while(
    1)
        {
            
    wait(0.2);
            if(
    isdefined(self))
            {
                
    self.hudmoney setValue(self.money);
            }
            else if(!
    isdefined(self))
            {
                break;
            }
        }

    PHP Code:
    streak()
    {
        if(
    isdefined(self.streak))
            
    self.streak destroy();
        
        
    self.streak newClientHudElem(self);
        
    self.streak.alignx "right";
        
    self.streak.610;
        
    self.streak.305
        
    self.streak.fontscale 1.3;

        while(
    1)
        {
            
    wait(0.5);
            if(
    isdefined(self))
            {
                if(
    self.pers["team"] == "allies")
                {
                    
    self.streak.label = &"^7KillStreak: ^1&&1";
                    
    self.streak setValue(self.killstreak);
                }
                else
                if(
    self.pers["team"] == "axis")
                {
                    
    self.streak.label = &"^7DeathStreak: ^1&&1";
                    
    self.streak setValue(self.deathstreak);
                
                }
            }
            else if(!
    isdefined(self))
            {
                break;
            }
        }

    And all the Huds are precached.

    in .cfg:

    set logfile "2"
    set sv_fps "20"

    developper 0
    dedicated 2

    i am actually on a local server but on a real server, it dont work also.
    i hope you will help me
    ORDI
    xfire: ordi37zk

  2. #2
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Test with developer 1

  3. #3
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    self.hudmoney.label = &"^7Money^1: &&1^7$";
    self.streak.label = &"^7KillStreak: ^1&&1";
    self.streak.label = &"^7DeathStreak: ^1&&1";
    Pretty sure this needs to be precached. Can't tell if you changed it for the purpose of this post.

    If not;

    Code:
    game["blah_text"] = &"^7Money^1: &&1^7$";
    precacheString(game["blah_text"]);
    
    self.hudmoney.label = game["blah_text"];
    edit:

    Also, you forget to destroy self.hudmoney. Again, not sure if this is intentional.

    Code:
    money() 
    { 
        if(isDefined(self.hudmoney))
            self.hudmoney destroy();
        
        self.hudmoney = newClientHudElem(self); 
        self.hudmoney.alignx = "right"; 
        self.hudmoney.x = 610; 
        self.hudmoney.y = 285;  
        self.hudmoney.fontscale = 1.4; 
        self.hudmoney.label = &"^7Money^1: &&1^7$"; 
         
        while(1) 
        { 
            wait(0.2); 
            if(isdefined(self)) 
            { 
                self.hudmoney setValue(self.money); 
            } 
            else if(!isdefined(self)) 
            { 
                break; 
            } 
        } 
    }
    Or, if you intentionally don't want it deleted;

    Code:
    money() 
    { 
        if(!isDefined(self.hudmoney))    {
            self.hudmoney = newClientHudElem(self); 
            self.hudmoney.alignx = "right"; 
            self.hudmoney.x = 610; 
            self.hudmoney.y = 285;  
            self.hudmoney.fontscale = 1.4; 
            self.hudmoney.label = &"^7Money^1: &&1^7$";
        }
         
        while(1) 
        { 
            wait(0.2); 
            if(isdefined(self)) 
            { 
                self.hudmoney setValue(self.money); 
            } 
            else if(!isdefined(self)) 
            { 
                break; 
            } 
        } 
    }
    Last edited by filthy_freak_; 28th June 2014 at 11:54.

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Your money hud doesnt get destroyed, it gets re-created every time, overflowing hud count.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. #5
    Private
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    13
    Thanked 4 Times in 3 Posts
    before i had placed
    PHP Code:
    if(isDefined(self.hudmoney))
            
    self.hudmoney destroy(); 
    i got a error weird sometime. idk what was this error
    but it appears still invisible

    and when i say precache:
    PHP Code:
    precacheString(&"^7Money^1: &&1^7$");
        
    precacheString(&"^7KillStreak: ^1&&1");
        
    precacheString(&"^7DeathStreak: ^1&&1"); 
    a video in showing the hud money which work and which dont work:
    http://fr.xfire.com/video/62859e/

  6. #6
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    I'v tested the code and it works fine.

    This means the problem must be elsewhere.

    Try and debug your code....

    Code:
    money() 
    { 
        if(isDefined(self.hudmoney))
            self.hudmoney destroy();
        
        self.hudmoney = newClientHudElem(self); 
        self.hudmoney.alignx = "right"; 
        self.hudmoney.x = 610; 
        self.hudmoney.y = 285;  
        self.hudmoney.fontscale = 1.4; 
        self.hudmoney.label = &"^7Money^1: &&1^7$"; 
         
        while(1) 
        { 
            wait(0.2); 
            if(isdefined(self) && isDefined(self.money)) 
            { 
                self.hudmoney setValue(self.money); 
            }
            else if(!isDefined(self.money))
            {
                self iprintlnbold("self.money is undefined!");
                break;
            }
            else if(!isdefined(self)) 
            { 
                self iprintlnbold("self is undefined!");
                break; 
            } 
        } 
    }
    Code:
    streak() 
    { 
        if(isdefined(self.streak)) 
            self.streak destroy(); 
         
        self.streak = newClientHudElem(self); 
        self.streak.alignx = "right"; 
        self.streak.x = 610; 
        self.streak.y = 305;  
        self.streak.fontscale = 1.3; 
    
        while(1) 
        { 
            wait(0.5); 
            if(isdefined(self)) 
            { 
                if(self.pers["team"] == "allies") 
                { 
                    if(isDefined(self.killstreak))
                    {
                        self.streak.label = &"^7KillStreak: ^1&&1"; 
                        self.streak setValue(self.killstreak); 
                    } else {
                        iprintlnbold("self.killstreak is undefined!");  
                        break;
                    }
                } 
                else 
                if(self.pers["team"] == "axis") 
                { 
                    if(isDefined(self.deathstreak))
                    {
                        self.streak.label = &"^7DeathStreak: ^1&&1"; 
                        self.streak setValue(self.deathstreak); 
                    } else {
                        iprintlnbold("self.deathstreak is undefined!");
                        break;
                    }
                } 
            } 
            else if(!isdefined(self)) 
            { 
                iprintln("self is undefined!");
                break; 
            } 
        } 
    }
    i got a error weird sometime.
    Try fixing the error, like izno said, if you don't destroy it you will overflow your hud count.


    EDIT: You will probably find the problem easy if you were to set developer 1.
    Last edited by filthy_freak_; 28th June 2014 at 16:15.

  7. #7
    Private
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    13
    Thanked 4 Times in 3 Posts
    euhm developer 1:
    it do nothing.

    i did what you said:
    PHP Code:
    wait(0.2); 
            if(
    isdefined(self) && isDefined(self.money)) 
            { 
                
    self.hudmoney setValue(self.money); 
            }
            else if(!
    isDefined(self.money))
            {
                
    self iprintlnbold("self.money is undefined!");
                break;
            }
            else if(!
    isdefined(self)) 
            { 
                
    self iprintlnbold("self is undefined!");
                break; 
            } 
    results:
    i cant see:
    self iprintlnbold("self.money is undefined!");
    and
    self iprintlnbold("self is undefined!");
    when it dont work.

  8. #8
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by ORDI View Post
    euhm developer 1:
    it do nothing.

    i did what you said:
    PHP Code:
    wait(0.2); 
            if(
    isdefined(self) && isDefined(self.money)) 
            { 
                
    self.hudmoney setValue(self.money); 
            }
            else if(!
    isDefined(self.money))
            {
                
    self iprintlnbold("self.money is undefined!");
                break;
            }
            else if(!
    isdefined(self)) 
            { 
                
    self iprintlnbold("self is undefined!");
                break; 
            } 
    results:
    i cant see:
    self iprintlnbold("self.money is undefined!");
    and
    self iprintlnbold("self is undefined!");
    when it dont work.
    I'm not going to debug your code, what I said was mostly meant to be an example of what you should be doing.

    I'v tested the code and it works fine.

    This means the problem must be elsewhere.
    ----

    Also, you mentioned you can write your own code. Why did you copy this script, modify it and ask us for help when it doesn't work, instead of writing a script yourself? This could be re-written to suit your needs in under two minutes. I sound harsh but come on... this script is easy!
    Last edited by filthy_freak_; 4th July 2014 at 06:10.

  9. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by ORDI View Post
    euhm developer 1:
    it do nothing.

    i did what you said:
    PHP Code:
    wait(0.2); 
            if(
    isdefined(self) && isDefined(self.money)) 
            { 
                
    self.hudmoney setValue(self.money); 
            }
            else if(!
    isDefined(self.money))
            {
                
    self iprintlnbold("self.money is undefined!");
                break;
            }
            else if(!
    isdefined(self)) 
            { 
                
    self iprintlnbold("self is undefined!");
                break; 
            } 
    results:
    i cant see:
    self iprintlnbold("self.money is undefined!");
    and
    self iprintlnbold("self is undefined!");
    when it dont work.
    If self is undefined then you are calling your scripts wrong.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

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