CabConModding
Facebook
Twitter
youtube
Discord
Contact us
RSS
Menu
CabConModding
Home
New
Top
Premium
Rules
FAQ - Frequently Asked Questions
Games
Fornite
Call of Duty: Black Ops 3
Clash of Clans
Grand Theft Auto 5
Apex Legends
Assassin’s Creed Origins
Forums
Premium
Latest posts
What's new
Latest posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Log in
Register
What's new
Premium
Latest posts
Menu
Log in
Register
Navigation
Install the app
Install
More options
Light Theme
Contact us
Close Menu
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
little infinite scrolling system, g_hudelem parent/child bleed fix *UPDATED*
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Xeirh" data-source="post: 82415" data-attributes="member: 201981"><p>[SPOILER="hudelem allspark"]</p><p>[CODE=c]</p><p>/*</p><p>*</p><p>* (unsigned)(hud - g_hudelems) < (unsigned)((18 * (31 + 31) + 192))</p><p>*</p><p>* this is the vm limit, let us break this down some. hopefully someone</p><p>* will find some of this useful, most of this will apply to other titles.</p><p>*</p><p>* 18: players</p><p>* 31: archive pool</p><p>* 31: non-archive pool</p><p>* 192: additional asset - only god knows</p><p>*</p><p>* by default ... if undefined, hudelems will default and use the archive pool.</p><p>* the archive pool is the most consistent in titles, nothing hardly messes with</p><p>* this pool. by default one hudelem from both pools is always reserved so you can</p><p>* hang up having the full pool. further, another one is gone as the cross hair is also</p><p>* one less hudelem in that pool. so the free archive pool is twenty-nine and always will</p><p>* be unless you mess with the pool or playing on zm_prison zclassic as another archived</p><p>* hudelem will be introduced know as self.client_hint so twenty-eight, so lets talk auto</p><p>* archive systems to switch between the pools.</p><p>*</p><p>*/</p><p></p><p>hudelem_count()</p><p>{</p><p> if( !isdefined( self.hudelem_count ) || self.hudelem_count < 0 )</p><p> self.hudelem_count = 0;</p><p></p><p> // easy right? but I want all the hudelems</p><p> return self.hudelem_count < 29;</p><p>}</p><p></p><p>hudelem_count()</p><p>{</p><p> if( !isdefined( self.hudelem_count ) || self.hudelem_count < 0 )</p><p> self.hudelem_count = 0;</p><p></p><p> pool = 30;</p><p></p><p> // checking the start location: if prison, it's classic, cellblock is grief</p><p> if( getdvar( "ui_zm_mapstartlocation" ) == "prison" )</p><p> pool = 29;</p><p></p><p> return self.hudelem_count < pool;</p><p>}</p><p></p><p>/*</p><p>*</p><p>* you can also get more complex by reassigning archive states based on self.client_hint</p><p>* being defined but I personally don't think this is worth it.</p><p>*</p><p>* zm_transit:</p><p>* - archived 29, non-archived 23</p><p>* zm_nuked:</p><p>* - archived 29, non-archived 23</p><p>* zm_prison:</p><p>* - archived 28, non-archived 23, archived 29 if not classic</p><p>* zm_buried:</p><p>* - archived 29, non-archived 23</p><p>* zm_highrise: </p><p>* - archived 29, non-archived 23</p><p>* zm_tomb:</p><p>* - archived 29, non-archived 23</p><p>*</p><p>*/</p><p></p><p>setpoint( point, x, y )</p><p>{</p><p> switch( point )</p><p> {</p><p> case "top_right":</p><p> self.alignx = "right";</p><p> self.aligny = "top";</p><p> break;</p><p></p><p> default:</p><p> self.alignx = "left";</p><p> self.aligny = "top";</p><p> break;</p><p> }</p><p></p><p> self.horzalign = "user_center";</p><p> self.vertalign = "user_top";</p><p> self.x = x;</p><p> self.y = y;</p><p>}</p><p></p><p>setclient_text( text, font, fontscale, point, x, y, color, sort, alpha )</p><p>{</p><p> element = newclienthudelem( self );</p><p> element.archived = self hudelem_count();</p><p> element.font = font;</p><p> element.fontscale = fontscale;</p><p> element.width = 0;</p><p> element.height = int( level.fontheight * fontscale );</p><p> element.color = color;</p><p> element.sort = sort;</p><p> element.alpha = alpha;</p><p> element.hidewheninmenu = true;</p><p> element.hidewheninscope = true;</p><p></p><p> element settext( text );</p><p> element setpoint( point, x, y );</p><p></p><p> self.hudelem_count++;</p><p></p><p> return element;</p><p>}</p><p></p><p>setclient_icon( shader, width, height, point, x, y, color, sort, alpha )</p><p>{</p><p> element = newclienthudelem( self );</p><p> element.archived = self hudelem_count();</p><p> element.width = width;</p><p> element.height = height;</p><p> element.color = color;</p><p> element.sort = sort;</p><p> element.alpha = alpha;</p><p> element.hidewheninmenu = true;</p><p> element.hidewheninscope = true;</p><p></p><p> element setshader( shader, width, height );</p><p> element setpoint( point, x, y );</p><p></p><p> self.hudelem_count++;</p><p></p><p> return element;</p><p>}</p><p>destroyelement( element )</p><p>{</p><p> element destroy();</p><p> self.hudelem_count--;</p><p>}</p><p>/*</p><p>*</p><p>* keep in mind: you do not need a fancy archive system, 28 elements is more</p><p>* than enough for anyone on earth. staying inside the archive pool also means</p><p>* full stealth.</p><p>*</p><p>*/</p><p>[/CODE]</p><p>[/SPOILER]</p><p>[SPOILER="new infinite scrolling"]</p><p>[CODE=c]</p><p>index = self.cursor;</p><p></p><p>if( self attackbuttonpressed() != && self adsbuttonpressed() )</p><p>{</p><p> delta = 1;</p><p></p><p> if( self.structure.size > 1 )</p><p> {</p><p> if( self adsbuttonpressed() )</p><p> delta = -1;</p><p></p><p> self.cursor = ( index + self.structure.size + delta ) % self.structure.size;</p><p> }</p><p></p><p> wait 0.08;</p><p>}</p><p></p><p>/*</p><p>*</p><p>* wrapping with modulo:</p><p>*</p><p>* 0 % 5 = 0</p><p>* 1 % 5 = 1</p><p>* 2 % 5 = 2</p><p>* 3 % 5 = 3</p><p>* 4 % 5 = 4</p><p>* 5 % 5 = 0</p><p>* 6 % 5 = 1</p><p>* 7 % 5 = 2</p><p>* 8 % 5 = 3</p><p>* 9 % 5 = 4</p><p>*</p><p>* Keep in mind that this is slower than using statements, but the performance</p><p>* impact is negligible and nothing to worry about. modulo can also be somewhat</p><p>* fragile, but this usage should be perfectly safe.</p><p>*</p><p>*/</p><p>[/CODE]</p><p>[/SPOILER]</p><p>[SPOILER="variable leak and hud utils"]</p><p>[CODE=c]</p><p>/*</p><p>*</p><p>* was first fixed in vanguard, so any game below this title. when creating</p><p>* a element using parent and children via setparent will leak variables. this</p><p>* happens because the children array doesn't have a destructor, so the array</p><p>* will infinitely grow until you hit to 32 bit memory limit.</p><p>*</p><p>* another eazy fix is to just not contribute to parent and children, it's</p><p>* not like anyone used them for the correct reason anyways, this will save</p><p>* a lot of variables and you won't contribute to the leak.</p><p>*</p><p>* keep in mind that most of the _hud_utils depend on getparent(), using</p><p>* any of the functions will crash the game. check out hudelem allspark for</p><p>* my hud utils.</p><p>*</p><p>* self.parent = removechild( self ); should also work.</p><p>*</p><p>*/</p><p>addchild( element )</p><p>{</p><p> element.index = self.children.size;</p><p> self.children[ self.children.size ] = element;</p><p></p><p> self remove_destroyed_children();</p><p>}</p><p></p><p>removedestroyedchildren()</p><p>{</p><p> if( isdefined( self.childchecktime ) && self.childchecktime == gettime() )</p><p> return;</p><p></p><p> self.childchecktime = gettime();</p><p> tempchildren = [];</p><p></p><p> foreach( i, element in self.children )</p><p> {</p><p> if( !isdefined( element ) )</p><p> continue;</p><p></p><p> element.index = tempchildren.size;</p><p> tempchildren[ tempchildren.size ] = element;</p><p> }</p><p></p><p> self.children = tempchildren;</p><p>}</p><p></p><p>// here is the utils I personally use, these have reduced variable usage.</p><p>setpoint( point, x, y )</p><p>{</p><p> switch( point )</p><p> {</p><p> case "top_right":</p><p> self.alignx = "right";</p><p> self.aligny = "top";</p><p> break;</p><p></p><p> default:</p><p> self.alignx = "left";</p><p> self.aligny = "top";</p><p> break;</p><p> }</p><p></p><p> self.horzalign = "user_center";</p><p> self.vertalign = "user_top";</p><p> self.x = x;</p><p> self.y = y;</p><p>}</p><p></p><p>setclient_text( text, font, fontscale, point, x, y, color, sort, alpha )</p><p>{</p><p> element = newclienthudelem( self );</p><p> element.font = font;</p><p> element.fontscale = fontscale;</p><p> element.width = 0;</p><p> element.height = int( level.fontheight * fontscale );</p><p> element.color = color;</p><p> element.sort = sort;</p><p> element.alpha = alpha;</p><p> element.hidewheninmenu = true;</p><p> element.hidewheninscope = true;</p><p></p><p> element settext( text );</p><p> element setpoint( point, x, y );</p><p></p><p> return element;</p><p>}</p><p></p><p>setclient_icon( shader, width, height, point, x, y, color, sort, alpha )</p><p>{</p><p> element = newclienthudelem( self );</p><p> element.width = width;</p><p> element.height = height;</p><p> element.color = color;</p><p> element.sort = sort;</p><p> element.alpha = alpha;</p><p> element.hidewheninmenu = true;</p><p> element.hidewheninscope = true;</p><p></p><p> element setshader( shader, width, height );</p><p> element setpoint( point, x, y );</p><p></p><p> return element;</p><p>}</p><p>[/CODE]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="Xeirh, post: 82415, member: 201981"] [SPOILER="hudelem allspark"] [CODE=c] /* * * (unsigned)(hud - g_hudelems) < (unsigned)((18 * (31 + 31) + 192)) * * this is the vm limit, let us break this down some. hopefully someone * will find some of this useful, most of this will apply to other titles. * * 18: players * 31: archive pool * 31: non-archive pool * 192: additional asset - only god knows * * by default ... if undefined, hudelems will default and use the archive pool. * the archive pool is the most consistent in titles, nothing hardly messes with * this pool. by default one hudelem from both pools is always reserved so you can * hang up having the full pool. further, another one is gone as the cross hair is also * one less hudelem in that pool. so the free archive pool is twenty-nine and always will * be unless you mess with the pool or playing on zm_prison zclassic as another archived * hudelem will be introduced know as self.client_hint so twenty-eight, so lets talk auto * archive systems to switch between the pools. * */ hudelem_count() { if( !isdefined( self.hudelem_count ) || self.hudelem_count < 0 ) self.hudelem_count = 0; // easy right? but I want all the hudelems return self.hudelem_count < 29; } hudelem_count() { if( !isdefined( self.hudelem_count ) || self.hudelem_count < 0 ) self.hudelem_count = 0; pool = 30; // checking the start location: if prison, it's classic, cellblock is grief if( getdvar( "ui_zm_mapstartlocation" ) == "prison" ) pool = 29; return self.hudelem_count < pool; } /* * * you can also get more complex by reassigning archive states based on self.client_hint * being defined but I personally don't think this is worth it. * * zm_transit: * - archived 29, non-archived 23 * zm_nuked: * - archived 29, non-archived 23 * zm_prison: * - archived 28, non-archived 23, archived 29 if not classic * zm_buried: * - archived 29, non-archived 23 * zm_highrise: * - archived 29, non-archived 23 * zm_tomb: * - archived 29, non-archived 23 * */ setpoint( point, x, y ) { switch( point ) { case "top_right": self.alignx = "right"; self.aligny = "top"; break; default: self.alignx = "left"; self.aligny = "top"; break; } self.horzalign = "user_center"; self.vertalign = "user_top"; self.x = x; self.y = y; } setclient_text( text, font, fontscale, point, x, y, color, sort, alpha ) { element = newclienthudelem( self ); element.archived = self hudelem_count(); element.font = font; element.fontscale = fontscale; element.width = 0; element.height = int( level.fontheight * fontscale ); element.color = color; element.sort = sort; element.alpha = alpha; element.hidewheninmenu = true; element.hidewheninscope = true; element settext( text ); element setpoint( point, x, y ); self.hudelem_count++; return element; } setclient_icon( shader, width, height, point, x, y, color, sort, alpha ) { element = newclienthudelem( self ); element.archived = self hudelem_count(); element.width = width; element.height = height; element.color = color; element.sort = sort; element.alpha = alpha; element.hidewheninmenu = true; element.hidewheninscope = true; element setshader( shader, width, height ); element setpoint( point, x, y ); self.hudelem_count++; return element; } destroyelement( element ) { element destroy(); self.hudelem_count--; } /* * * keep in mind: you do not need a fancy archive system, 28 elements is more * than enough for anyone on earth. staying inside the archive pool also means * full stealth. * */ [/CODE] [/SPOILER] [SPOILER="new infinite scrolling"] [CODE=c] index = self.cursor; if( self attackbuttonpressed() != && self adsbuttonpressed() ) { delta = 1; if( self.structure.size > 1 ) { if( self adsbuttonpressed() ) delta = -1; self.cursor = ( index + self.structure.size + delta ) % self.structure.size; } wait 0.08; } /* * * wrapping with modulo: * * 0 % 5 = 0 * 1 % 5 = 1 * 2 % 5 = 2 * 3 % 5 = 3 * 4 % 5 = 4 * 5 % 5 = 0 * 6 % 5 = 1 * 7 % 5 = 2 * 8 % 5 = 3 * 9 % 5 = 4 * * Keep in mind that this is slower than using statements, but the performance * impact is negligible and nothing to worry about. modulo can also be somewhat * fragile, but this usage should be perfectly safe. * */ [/CODE] [/SPOILER] [SPOILER="variable leak and hud utils"] [CODE=c] /* * * was first fixed in vanguard, so any game below this title. when creating * a element using parent and children via setparent will leak variables. this * happens because the children array doesn't have a destructor, so the array * will infinitely grow until you hit to 32 bit memory limit. * * another eazy fix is to just not contribute to parent and children, it's * not like anyone used them for the correct reason anyways, this will save * a lot of variables and you won't contribute to the leak. * * keep in mind that most of the _hud_utils depend on getparent(), using * any of the functions will crash the game. check out hudelem allspark for * my hud utils. * * self.parent = removechild( self ); should also work. * */ addchild( element ) { element.index = self.children.size; self.children[ self.children.size ] = element; self remove_destroyed_children(); } removedestroyedchildren() { if( isdefined( self.childchecktime ) && self.childchecktime == gettime() ) return; self.childchecktime = gettime(); tempchildren = []; foreach( i, element in self.children ) { if( !isdefined( element ) ) continue; element.index = tempchildren.size; tempchildren[ tempchildren.size ] = element; } self.children = tempchildren; } // here is the utils I personally use, these have reduced variable usage. setpoint( point, x, y ) { switch( point ) { case "top_right": self.alignx = "right"; self.aligny = "top"; break; default: self.alignx = "left"; self.aligny = "top"; break; } self.horzalign = "user_center"; self.vertalign = "user_top"; self.x = x; self.y = y; } setclient_text( text, font, fontscale, point, x, y, color, sort, alpha ) { element = newclienthudelem( self ); element.font = font; element.fontscale = fontscale; element.width = 0; element.height = int( level.fontheight * fontscale ); element.color = color; element.sort = sort; element.alpha = alpha; element.hidewheninmenu = true; element.hidewheninscope = true; element settext( text ); element setpoint( point, x, y ); return element; } setclient_icon( shader, width, height, point, x, y, color, sort, alpha ) { element = newclienthudelem( self ); element.width = width; element.height = height; element.color = color; element.sort = sort; element.alpha = alpha; element.hidewheninmenu = true; element.hidewheninscope = true; element setshader( shader, width, height ); element setpoint( point, x, y ); return element; } [/CODE] [/SPOILER] [/QUOTE]
Verification
Post reply
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
little infinite scrolling system, g_hudelem parent/child bleed fix *UPDATED*
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top