Results 1 to 9 of 9

Thread: problem hud.size

  1. #1
    Private
    Join Date
    Oct 2012
    Posts
    15
    Thanks
    11
    Thanked 1 Time in 1 Post

    problem hud.size

    deleteClientHudTextElementbyName( hud_text_name )
    {
    if( isDefined( self.txt_hud ) && self.txt_hud.size > 0 )
    {
    for(i=0; i<self.txt_hud.size; i++ )
    {
    if( isDefined( self.txt_hud[i].name ) && self.txt_hud[i].name == hud_text_name )
    {
    self.txt_hud[i] destroy();
    self.txt_hud[i].name = undefined;
    }
    }
    }
    }

    the hud[i] is destroyed successfully but, the problem is that the self.txt_hud.size does not decrease and remains allocated in the memory of the server! :/
    is there any way to reduce the self.txt_hud.size?

  2. #2
    Private
    Join Date
    Oct 2012
    Posts
    15
    Thanks
    11
    Thanked 1 Time in 1 Post
    createClientHudTextElement( hud_text_name, x, y, xAlign, yAlign, horzAlign, vertAlign, foreground, sort, alpha, color_r, color_g, color_b, size, text )
    {
    if( !isDefined( self.txt_hud ) ) self.txt_hud = [];

    self deleteHudTextElementbyName( hud_text_name );

    count = self.txt_hud.size;

    self.txt_hud[count] = newClientHudElem( self );
    self.txt_hud[count].name = hud_text_name;
    self.txt_hud[count].x = x;
    self.txt_hud[count].y = y;
    self.txt_hud[count].alignX = xAlign;
    self.txt_hud[count].alignY = yAlign;
    self.txt_hud[count].horzAlign = horzAlign;
    self.txt_hud[count].vertAlign = vertAlign;
    self.txt_hud[count].foreground = foreground;
    self.txt_hud[count].sort = sort;
    self.txt_hud[count].color = ( color_r, color_g, color_b );
    self.txt_hud[count].hideWhenInMenu = true;
    self.txt_hud[count].alpha = alpha;
    self.txt_hud[count].fontScale = size;
    self.txt_hud[count].font = "default";
    self.txt_hud[count] setText( text );
    }

  3. #3
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    PHP Code:
    self.txt_hud[idestroy();
    self.txt_hud[i].name undefined
    you destroy the hud[i] here, hud[i] is now undefined and size is decreased
    however you set hud[i].name afterwards to undefined, therefore hud[i] is now more or less defined
    (since it holds the undefined membervariable name)

    PHP Code:
    self.txt_hud[idestroy(); 
    should do the trick, there is no need to set it to undefined

  4. The Following User Says Thank You to serthy For This Useful Post:

    sabixão (13th May 2014)

  5. #4
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 589 Times in 389 Posts
    Quote Originally Posted by sabixão View Post
    createClientHudTextElement( hud_text_name, x, y, xAlign, yAlign, horzAlign, vertAlign, foreground, sort, alpha, color_r, color_g, color_b, size, text )
    {
    if( !isDefined( self.txt_hud ) ) self.txt_hud = [];

    self deleteHudTextElementbyName( hud_text_name );

    count = self.txt_hud.size;

    self.txt_hud[count] = newClientHudElem( self );
    self.txt_hud[count].name = hud_text_name;
    self.txt_hud[count].x = x;
    self.txt_hud[count].y = y;
    self.txt_hud[count].alignX = xAlign;
    self.txt_hud[count].alignY = yAlign;
    self.txt_hud[count].horzAlign = horzAlign;
    self.txt_hud[count].vertAlign = vertAlign;
    self.txt_hud[count].foreground = foreground;
    self.txt_hud[count].sort = sort;
    self.txt_hud[count].color = ( color_r, color_g, color_b );
    self.txt_hud[count].hideWhenInMenu = true;
    self.txt_hud[count].alpha = alpha;
    self.txt_hud[count].fontScale = size;
    self.txt_hud[count].font = "default";
    self.txt_hud[count] setText( text );
    }
    That is my code. Please credit me for it.

  6. The Following User Says Thank You to Tally For This Useful Post:

    sabixão (13th May 2014)

  7. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 589 Times in 389 Posts
    Quote Originally Posted by serthy View Post
    PHP Code:
    self.txt_hud[idestroy();
    self.txt_hud[i].name undefined
    you destroy the hud[i] here, hud[i] is now undefined and size is decreased
    however you set hud[i].name afterwards to undefined, therefore hud[i] is now more or less defined
    (since it holds the undefined membervariable name)

    PHP Code:
    self.txt_hud[idestroy(); 
    should do the trick, there is no need to set it to undefined
    That is my code he is using, and I have found through experience that you have to undefine self.txt_hud.name once you have removed the element.

    Other than that, it works perfectly fine. There is no need to further reduce sizes.

  8. The Following User Says Thank You to Tally For This Useful Post:

    sabixão (13th May 2014)

  9. #6
    Private
    Join Date
    Oct 2012
    Posts
    15
    Thanks
    11
    Thanked 1 Time in 1 Post
    yes , is a TallyMod function() this is a beautiful shot to reduce many code line , this hud.size allocated in the memory of a server with many huds
    would not be a problem?

  10. #7
    Private First Class RobsoN's Avatar
    Join Date
    Jan 2013
    Location
    /home/cod2/
    Posts
    230
    Thanks
    119
    Thanked 95 Times in 64 Posts
    BTW Tally is hud.hideWhenInMenu = true; built-in engine function?
    "Don't worry if your code doesn't work correctly - if everything worked, you would not work" ~Mosher's right

  11. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 589 Times in 389 Posts
    Quote Originally Posted by RobsoN View Post
    BTW Tally is hud.hideWhenInMenu = true; built-in engine function?
    The code method he posted was from one of my COD4 mods. It doesn't work in COD2.

  12. #9
    Brigadier General
    Join Date
    Oct 2012
    Posts
    998
    Thanks
    20
    Thanked 589 Times in 389 Posts
    Quote Originally Posted by sabixão View Post
    yes , is a TallyMod function() this is a beautiful shot to reduce many code line , this hud.size allocated in the memory of a server with many huds
    would not be a problem?
    When all elements have been destroyed, and you use the method again, it resets the array:

    Code:
    if( !isDefined( self.txt_hud ) ) self.txt_hud = [];
    So, no: it wont affect server memory.

  13. The Following User Says Thank You to Tally For This Useful Post:

    sabixão (13th May 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
  •