• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Destroying Elements without a lag spike?
#1
I get a huge lag spike for a few seconds every time I remove a progress bar with destroyelem(). Can't use hide since there would end up being too many elements.

I saw some topics about this problem, but none had the fix in em.

Any tips?
[Image: enjin-103434-13169654251028747231-blue.png]
  Reply
#2
(03-06-2012, 18:06)frozenliquid Wrote: I get a huge lag spike for a few seconds every time I remove a progress bar with destroyelem(). Can't use hide since there would end up being too many elements.

I saw some topics about this problem, but none had the fix in em.

Any tips?
The lag spike is probably caused because by an "infinite loop". Look in the console. It'll say something like "infinite loop detected, killing thread". Atleast that always what it says to me when I have a lag spike.
Destroyelem() shouldn't cause lag spikes by default. I think it can happen when you try to destroy a hudelem that doesn't exist. Check your code again. Wink

Edit: I never use Destroyelem(), I always use destroy(), maybe that'll help.
Would like to make a donation? Click here
  Reply
#3
destroy() seemed to have fixed it Big Grin Still have some slight problems with color overriding each other when a new bar comes into play, but I think that shouldn't be too hard to fix.

And yes, it was in a loop, but I always created the element before the while(1) within the function.
[Image: enjin-103434-13169654251028747231-blue.png]
  Reply
#4
Oh man I can't get this to work properly. Got rid of the lag spikes, thanks to you, but now the bars stack on top of each other and now I did something that causes BO to crash every time it reaches lvl 3... If anyone wants to check what's wrong with my code, here it is:

Code:
PrawgrezzBar()
{
self endon("disconnect");
self endon("death");
self endon("endchosen");

survivorBar = createPrimaryProgressBar( -100 );
survivorBarText = createPrimaryProgressBarText( -100 );
survivorBarText setText("^5Level 1");
SurvivorBar updateBar( 0.0 );

for(;;)
       {
       switch(self.kills)
       {    
            case 0:
            {
                        survivorBar.bar.color = (0,0,0);
            SurvivorBar updateBar( 0.0 );
            break;
            }
            case 1:
               {
                      SurvivorBar updateBar( 0.2 );
                      survivorBar.bar.color = (0,1,1);
                      break;
              }
              
            case 2:
              {
                      SurvivorBar updateBar( 0.4 );
                     survivorBar.bar.color = (0,1,1);
                      break;
              }  
            case 3:
              {
                      SurvivorBar updateBar( 0.6 );
                      survivorBar.bar.color = (0,1,1);
                      break;
              }      
            case 4:
              {
                     SurvivorBar updateBar( 0.8 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }          
              case 5:
              {
                      SurvivorBar updateBar( 1.00 );
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                        survivorBar.bar.color = (0,1,0);
                            wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                        wait 1;
                        survivorBar.bar.color = (0,1,0);
                        SurvivorBar updateBar( 0.0 );
                        survivorBar Destroy();
                        survivorBarText Destroy();                    
                        self thread Level2();
                        break;
              }
                
            }    
                wait 0.05;
}
}

Level2()
{
self endon("disconnect");
self endon("death");
self endon("endchosen");

survivorBar = createPrimaryProgressBar( -100 );
survivorBarText = createPrimaryProgressBarText( -100 );
survivorBarText setText("^5Level 2");
SurvivorBar updateBar( 0.0 );

for(;;)
       {
       switch(self.kills)
       {
            case 6:
               {
                      SurvivorBar updateBar( 0.2 );
                      survivorBar.bar.color = (0,1,1);
                      break;
              }          
            case 7:
              {
                      SurvivorBar updateBar( 0.4 );
                      survivorBar.bar.color = (0,1,1);
                      break;
              }          
            case 8:
              {
                    SurvivorBar updateBar( 0.6 );
                    survivorBar.bar.color = (0,1,1);
                    break;
              }          
            case 9:
              {
                     SurvivorBar updateBar( 0.8 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }        
              case 10:
              {
                      SurvivorBar updateBar( 1.00 );
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                        survivorBar.bar.color = (0,1,0);
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                        wait 1;
                        survivorBar.bar.color = (0,1,0);
                        SurvivorBar updateBar( 0.0 );
                        survivorBar Destroy();
                        survivorBarText Destroy();
                        self thread Level3();
                        break;
              }
                
            }    
                wait 0.05;
}
}

Level3()
{
self endon("disconnect");
self endon("death");
self endon("endchosen");

survivorBar = createPrimaryProgressBar( -100 );
survivorBarText = createPrimaryProgressBarText( -100 );
survivorBarText setText("^5Level 3");
SurvivorBar updateBar( 0.0 );

for(;;)
       {
       switch(self.kills)
       {            
            case 11:
               {
                      SurvivorBar updateBar( 0.1 );
                      survivorBar.bar.color = (0,1,1);
                      break;
              }  
            case 12:
              {
                      SurvivorBar updateBar( 0.2 );
                     survivorBar.bar.color = (0,1,1);
                      break;
              }      
            case 13:
              {
                      SurvivorBar updateBar( 0.3 );
                     survivorBar.bar.color = (0,1,1);                      
                      break;
              }      
            case 14:
              {
                     SurvivorBar updateBar( 0.4);
                     survivorBar.bar.color = (0,1,1);
                     break;
              }
              case 15:
              {
                     SurvivorBar updateBar( 0.5 );
                    survivorBar.bar.color = (0,1,1);
                     break;
              }
              case 16:
              {
                     SurvivorBar updateBar( 0.6 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }
              case 17:
              {
                     SurvivorBar updateBar( 0.7 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }
              case 18:
              {
                     SurvivorBar updateBar( 0.8 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }
              case 19:
              {
                     SurvivorBar updateBar( 0.9 );
                     survivorBar.bar.color = (0,1,1);
                     break;
              }
              
              case 20:
              {
                      SurvivorBar updateBar( 1.00 );
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                        survivorBar.bar.color = (0,1,0);
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                        wait 1;
                        survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                        wait 1;
                        survivorBar.bar.color = (0,1,0);
                        SurvivorBar updateBar( 0.0 );
                        survivorBar Destroy();
                        survivorBarText Destroy();
                        self thread SurvivorLevel4();
                        survivorBar.bar.color = (0,0,0);
                        break;
              }
                
            }    
                wait 0.05;
}
}

First level goes fine with normal transparent black background behind cyan progress bar. Goes fine to the end and jumps to Level2().

Level 2 has a non-transparent black bar behind it the whole time but still goes on to level 3.

Level 3 has a non transparent black bar on top of the new progress bar. (Can see a tiny portion of the cyan color behind the black bar, so I know it's there.)

How can I remove the old bars from underneath and from on top of the current one?
[Image: enjin-103434-13169654251028747231-blue.png]
  Reply
#5
Blush soz didnt read code but this should do the job for you
Code:
makehud1()
{

        self endon ("disconnect");
            this = self createFontString( "objective", 1.2 );
            this setPoint("BOTTOMLEFT", "BOTTOMLEFT", 10, -95);
            this setText("some text hud stuff");
            this.sort = 10;
           self thread killhud(this);

}

with

Code:
killhud(entity)
{
    self endon("disconnect");
    self waittill_any("death", "round_end_done", "disconnect" , "something");  // notify on Next hud item
    entity delete();
    entity destroy();
}

hope that makes sence , notify to delete & destroy when you start your next hud item this will work great and all you have to do is put a notify in somewhere Smile
  Reply
#6
I think that won't solve all the problems.
I'll look into it.

Edit: got it fixed!
Destroyhudelem was actually the only way to remove the progressbars. Atleast that's the only way how I could remove those bars.
The problem was the for(;; ) loop. Once a level got completed, the loop would still go on. So if you had killed 5 players, then 0.05 seconds later it would do all the functions in that switch again(like removing the hud elem that doesn't exist, which caused the lagspike). I fixed it by adding another notify and endon. I would suggest to stop using a loop though and instead just put it somewhere in onplayerkilled.

Here is the fixed code, I have also done some other tiny improvements.:
Code:
PrawgrezzBar()
{
    self endon("disconnect");
    self endon("death");
    self endon("endchosen");
    self endon("level1_done");

    survivorBar = createPrimaryProgressBar( );
    survivorBarText = createPrimaryProgressBarText( );
    survivorBarText setText("^5Level 1");
    SurvivorBar updateBar( 0.0 );

    for(;;)
    {
        switch(self.kills)
        {
            case 1:
            {
                SurvivorBar updateBar( 0.2 );
                break;
            }
            case 2:
            {
                SurvivorBar updateBar( 0.4 );
                break;
            }
            case 3:
            {
                SurvivorBar updateBar( 0.6 );
                break;
            }
            case 4:
            {
                SurvivorBar updateBar( 0.8 );
                break;
            }
            case 5:
            {
                SurvivorBar updateBar( 1.00 );
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                survivorBar.bar.color = (0,1,0);
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                wait 1;
                survivorBar Destroyelem();
                survivorBarText Destroyelem();
                self thread Level2();
                self notify("level1_done");
                
                break;
            }
        }
        wait 0.05;
    }
}

Level2()
{
    self endon("disconnect");
    self endon("death");
    self endon("endchosen");
    self endon("level2_done");

    SurvivorBar = createPrimaryProgressBar( );
    SurvivorBarText = createPrimaryProgressBarText( );
    SurvivorBarText setText("^5Level 2");
    SurvivorBar updateBar( 0.0 );

    for(;;)
    {
        switch(self.kills)
        {
            case 6:
            {
                SurvivorBar updateBar( 0.2 );
                break;
            }
            case 7:
            {
                SurvivorBar updateBar( 0.4 );
                break;
            }
            case 8:
            {
                SurvivorBar updateBar( 0.6 );
                break;
            }
            case 9:
            {
                SurvivorBar updateBar( 0.8 );
                break;
            }
            case 10:
            {
                SurvivorBar updateBar( 1.00 );
                SurvivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                SurvivorBar.bar.color = (0,1,0);
                wait 1;
                SurvivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                wait 1;
                SurvivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                wait 1;
                SurvivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                wait 1;
                SurvivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                wait 1;
                SurvivorBar Destroyelem();
                SurvivorBarText Destroyelem();
                self thread Level3();
                self notify("level2_done");
                break;
            }
        }
        wait 0.05;
    }
}

Level3()
{
    self endon("disconnect");
    self endon("death");
    self endon("endchosen");
    self endon("level3_done");

    survivorBar = createPrimaryProgressBar( );
    survivorBarText = createPrimaryProgressBarText( );
    survivorBarText setText("^5Level 3");
    SurvivorBar updateBar( 0.0 );

    for(;;)
    {
        switch(self.kills)
        {
            case 11:
            {
                SurvivorBar updateBar( 0.1 );
                break;
            }
            case 12:
            {
                SurvivorBar updateBar( 0.2 );
                break;
            }
            case 13:
            {
                SurvivorBar updateBar( 0.3 );
                break;
            }
            case 14:
            {
                SurvivorBar updateBar( 0.4);
                break;
            }
            case 15:
            {
                SurvivorBar updateBar( 0.5 );
                break;
            }
            case 16:
            {
                SurvivorBar updateBar( 0.6 );
                break;
            }
            case 17:
            {
                SurvivorBar updateBar( 0.7 );
                break;
            }
            case 18:
            {
                SurvivorBar updateBar( 0.8 );
                break;
            }
            case 19:
            {
                SurvivorBar updateBar( 0.9 );
                break;
            }

            case 20:
            {
                SurvivorBar updateBar( 1.00 );
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^55 ^7seconds!");
                survivorBar.bar.color = (0,1,0);
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^54 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^53 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^52 ^7seconds!");
                wait 1;
                survivorBarText settext("^2COMPLETED! ^7Advancing to the next level in ^51 ^7seconds!");
                wait 1;
                survivorBar Destroyelem();
                survivorBarText Destroyelem();
                self thread SurvivorLevel4();
                
                self notify("level3_done");
                break;
            }
        }
        wait 0.05;
    }
}
Would like to make a donation? Click here
  Reply
#7
Amazing job man, works perfectly Big Grin
[Image: enjin-103434-13169654251028747231-blue.png]
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to delete HUD elements on death? camxxcore 6 4,418 08-21-2013, 08:54
Last Post: Yamato
  Help How ToCreate Dynamic Hud Elements OzonE 3 2,534 09-18-2012, 15:20
Last Post: archit
  Hud Elements Tutorial OzonE 1 2,846 08-26-2012, 17:21
Last Post: JariZ
  I hate HUD elements AZUMIKKEL 9 4,553 09-17-2011, 14:10
Last Post: master131
Question Help Removing hud elements FRAN710 3 2,904 08-09-2011, 22:09
Last Post: thre3pi
  Help make a working Camera spike on players head rotceh_dnih 2 2,419 07-25-2011, 14:52
Last Post: Scripts18
  [Request] Tutorial on hud elements Pozzuh 1 1,773 12-17-2010, 00:15
Last Post: sliver

Forum Jump:


Users browsing this thread: 1 Guest(s)