Posts: 45
Threads: 10
Joined: Oct 2011
Reputation:
0
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?
Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
03-06-2012, 18:19
(This post was last modified: 03-06-2012, 18:20 by Cyborgking.)
(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.
Edit: I never use Destroyelem(), I always use destroy(), maybe that'll help.
Posts: 45
Threads: 10
Joined: Oct 2011
Reputation:
0
destroy() seemed to have fixed it 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.
Posts: 45
Threads: 10
Joined: Oct 2011
Reputation:
0
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?
Posts: 993
Threads: 86
Joined: Feb 2011
Reputation:
49
03-06-2012, 22:49
(This post was last modified: 03-06-2012, 22:50 by rotceh_dnih.)
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
Posts: 180
Threads: 15
Joined: Feb 2011
Reputation:
10
03-07-2012, 11:47
(This post was last modified: 03-07-2012, 12:37 by Cyborgking.)
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;
}
}
Posts: 45
Threads: 10
Joined: Oct 2011
Reputation:
0
Amazing job man, works perfectly
|