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
Dark Theme
Contact us
Close Menu
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 3
Call of Duty: Black Ops 3 Mods and Scripts
Call of Duty: Black Ops 3 Scripts
Lets Make A Menu!
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="JayCoder" data-source="post: 12941" data-attributes="member: 11522"><p>Jay -</p><p></p><p>Hello CabCon Community, I wanted to start a TUT On making a GSC MENU for bo3.</p><p>Forgive my english.</p><p></p><p>so lets find how we will make our hud,text,level.players.if statements,etc</p><p>1: grabbing the _clientids</p><p></p><p>[SPOILER="Here the orginal clientids"][PHP]#using scripts\codescripts\struct;</p><p></p><p>#using scripts\shared\callbacks_shared;</p><p>#using scripts\shared\system_shared;</p><p></p><p>#insert scripts\shared\shared.gsh;</p><p></p><p>#namespace clientids;</p><p></p><p>REGISTER_SYSTEM( "clientids", &__init__, undefined )</p><p> </p><p>function __init__()</p><p>{</p><p> callback::on_start_gametype( &init );</p><p> callback::on_connect( &on_player_connect );</p><p>}</p><p></p><p>function init()</p><p>{</p><p> // this is now handled in code ( not lan )</p><p> // see s_nextScriptClientId</p><p> level.clientid = 0;</p><p>}</p><p></p><p>function on_player_connect()</p><p>{</p><p> self.clientid = matchRecordNewPlayer( self );</p><p> if ( !isdefined( self.clientid ) || self.clientid == -1 )</p><p> {</p><p> self.clientid = level.clientid;</p><p> level.clientid++; // Is this safe? What if a server runs for a long time and many people join/leave</p><p> }</p><p></p><p> /#</p><p> PrintLn( "client: " + self.name + " clientid: " + self.clientid);</p><p> #/</p><p>}</p><p> [/PHP][/SPOILER]</p><p>I Started By Cleaning It Up, by doing the following</p><p>[SPOILER="Clean Up"]</p><p>[PHP]#using scripts\codescripts\struct;</p><p>#using scripts\shared\callbacks_shared;</p><p>#using scripts\shared\system_shared;</p><p>#insert scripts\shared\shared.gsh;</p><p></p><p>#namespace clientids;</p><p>REGISTER_SYSTEM( "clientids", &MainInit, undefined )</p><p></p><p>function MainInit()</p><p>{</p><p> callback::on_start_gametype( &initloader );</p><p> callback::on_connect( &OPC );</p><p> callback::on_spawned( &OPS );</p><p>}</p><p></p><p>function initloader()</p><p>{</p><p> if(!(DvarGetString("CGT") == "Nothing1" || DvarGetString("CGT") == "Nothing2" || DvarGetString("CGT") =="Nothing3" || DvarGetString("CGT") =="Nothing4"))</p><p> {</p><p> setDvar("CGT","Menu Name");</p><p> }</p><p> if(DvarGetString("CGT") == "Menu Name")</p><p> {</p><p> self freezecontrols(false);</p><p> IFS = false;</p><p> }</p><p> if(DvarGetString("CGT") == "Nothing1")</p><p> {</p><p> self thread Test();</p><p> }</p><p> if(DvarGetString("CGT") == "Nothing2")</p><p> {</p><p> self thread Test();</p><p> }</p><p> if(DvarGetString("CGT") == "Nothing3")</p><p> {</p><p> self thread Test();</p><p> }</p><p> if(DvarGetString("CGT") == "Nothing4")</p><p> {</p><p> self thread Test();</p><p> }</p><p>}</p><p>function OPC()</p><p>{</p><p> for(;;)</p><p> {</p><p> level waittill( "connecting", player );</p><p> self.clientid = matchRecordNewPlayer( self );</p><p> if ( !isdefined( self.clientid ) || self.clientid == -1 )</p><p> {</p><p> self.clientid = level.clientid;</p><p> level.clientid++; </p><p> }</p><p> level.clientid = 0;</p><p> }</p><p>}</p><p>function OPS()</p><p>{</p><p> self endon( "disconnect" );</p><p> level endon( "game_ended" );</p><p> if(DvarGetString("CGT") == "Menu Name")</p><p> {</p><p> IFS = true;</p><p> }</p><p> for(;;)</p><p> {</p><p> if(IFS)</p><p> {</p><p> if(self isHost())</p><p> {</p><p> if(!isDefined(self.MenuName["active"]))</p><p> {</p><p> self freezecontrols(false);</p><p> self.MenuName["active"] = true;</p><p> self iprintln("Text Here");</p><p> self iprintln("Text Here");</p><p> }</p><p> }</p><p> }</p><p> }</p><p>}[/PHP]</p><p></p><p>[/SPOILER]</p><p></p><p>How To Get Hud And Text?</p><p>Ok We Need to Find The Files</p><p>_hud_message.gsc</p><p>hud_message_shared.gsc</p><p>hud_shared.gsc</p><p>util_shared.gsc</p><p></p><p>lets get started making our hud function</p><p>[SPOILER="Hud Function"]</p><p>this is hudutil where we will get setpoint,setParent,CreateFrontString,Etc</p><p>[PHP]</p><p>#using scripts\codescripts\struct;</p><p>#using scripts\shared\lui_shared;</p><p>#using scripts\shared\util_shared;</p><p></p><p>#insert scripts\shared\shared.gsh;</p><p></p><p>#namespace hud;</p><p></p><p>function setParent( element )</p><p>{</p><p> if ( isdefined( self.parent ) && self.parent == element )</p><p> return;</p><p> </p><p> if ( isdefined( self.parent ) )</p><p> self.parent removeChild( self );</p><p></p><p> self.parent = element;</p><p> self.parent addChild( self );</p><p></p><p> if ( isdefined( self.point ) )</p><p> self setPoint( self.point, self.relativePoint, self.xOffset, self.yOffset );</p><p> else</p><p> self setPoint( "TOP" );</p><p>}</p><p></p><p>function getParent()</p><p>{</p><p> return self.parent;</p><p>}</p><p></p><p>function addChild( element )</p><p>{</p><p> element.index = self.children.size;</p><p> self.children[self.children.size] = element;</p><p>}</p><p></p><p>function removeChild( element )</p><p>{</p><p> element.parent = undefined;</p><p></p><p> if ( self.children[self.children.size-1] != element )</p><p> {</p><p> self.children[element.index] = self.children[self.children.size-1];</p><p> self.children[element.index].index = element.index;</p><p> }</p><p> self.children[self.children.size-1] = undefined;</p><p> </p><p> element.index = undefined;</p><p>}</p><p></p><p></p><p>function setPoint( point, relativePoint, xOffset, yOffset, moveTime )</p><p>{</p><p> if ( !isdefined( moveTime ) )</p><p> moveTime = 0;</p><p></p><p> element = self getParent();</p><p></p><p> if ( moveTime )</p><p> self moveOverTime( moveTime );</p><p> </p><p> if ( !isdefined( xOffset ) )</p><p> xOffset = 0;</p><p> self.xOffset = xOffset;</p><p></p><p> if ( !isdefined( yOffset ) )</p><p> yOffset = 0;</p><p> self.yOffset = yOffset;</p><p> </p><p> self.point = point;</p><p></p><p> self.alignX = "center";</p><p> self.alignY = "middle";</p><p></p><p> switch( point )</p><p> {</p><p> case "CENTER":</p><p> break;</p><p></p><p> case "TOP":</p><p> self.alignY = "top";</p><p> break;</p><p></p><p> case "BOTTOM":</p><p> self.alignY = "bottom";</p><p> break;</p><p></p><p> case "LEFT":</p><p> self.alignX = "left";</p><p> break;</p><p> </p><p> case "RIGHT":</p><p> self.alignX = "right";</p><p> break;</p><p></p><p> case "TOPRIGHT":</p><p> case "TOP_RIGHT":</p><p> self.alignY = "top";</p><p> self.alignX = "right";</p><p> break;</p><p></p><p> case "TOPLEFT":</p><p> case "TOP_LEFT":</p><p> self.alignY = "top";</p><p> self.alignX = "left";</p><p> break;</p><p></p><p> case "TOPCENTER":</p><p> self.alignY = "top";</p><p> self.alignX = "center";</p><p> break;</p><p></p><p> case "BOTTOM RIGHT":</p><p> case "BOTTOM_RIGHT":</p><p> self.alignY = "bottom";</p><p> self.alignX = "right";</p><p> break;</p><p></p><p> case "BOTTOM LEFT":</p><p> case "BOTTOM_LEFT":</p><p> self.alignY = "bottom";</p><p> self.alignX = "left";</p><p> break;</p><p></p><p> default:</p><p> /# println( "^3Warning: unknown point passed to setPoint(): " + point ); #/</p><p> break;</p><p> }</p><p></p><p> if ( !isdefined( relativePoint ) )</p><p> relativePoint = point;</p><p></p><p> self.relativePoint = relativePoint;</p><p></p><p> relativeX = "center";</p><p> relativeY = "middle";</p><p></p><p> switch( relativePoint )</p><p> {</p><p> case "CENTER":</p><p> break;</p><p></p><p> case "TOP":</p><p> relativeY = "top";</p><p> break;</p><p></p><p> case "BOTTOM":</p><p> relativeY = "bottom";</p><p> break;</p><p></p><p> case "LEFT":</p><p> relativeX = "left";</p><p> break;</p><p></p><p> case "RIGHT":</p><p> relativeX = "right";</p><p> break;</p><p></p><p> case "TOPRIGHT":</p><p> case "TOP_RIGHT":</p><p> relativeY = "top";</p><p> relativeX = "right";</p><p> break;</p><p></p><p> case "TOPLEFT":</p><p> case "TOP_LEFT":</p><p> relativeY = "top";</p><p> relativeX = "left";</p><p> break;</p><p></p><p> case "TOPCENTER":</p><p> relativeY = "top";</p><p> relativeX = "center";</p><p> break;</p><p></p><p> case "BOTTOM RIGHT":</p><p> case "BOTTOM_RIGHT":</p><p> relativeY = "bottom";</p><p> relativeX = "right";</p><p> break;</p><p></p><p> case "BOTTOM LEFT":</p><p> case "BOTTOM_LEFT":</p><p> relativeY = "bottom";</p><p> relativeX = "left";</p><p> break;</p><p></p><p> default:</p><p> /# println( "^3Warning: unknown relativePoint passed to setPoint(): " + relativePoint ); #/</p><p> break;</p><p> }</p><p></p><p> if ( element == level.uiParent )</p><p> {</p><p> self.horzAlign = relativeX;</p><p> self.vertAlign = relativeY;</p><p> }</p><p> else</p><p> {</p><p> self.horzAlign = element.horzAlign;</p><p> self.vertAlign = element.vertAlign;</p><p> }</p><p></p><p></p><p> if ( relativeX == element.alignX )</p><p> {</p><p> offsetX = 0;</p><p> xFactor = 0;</p><p> }</p><p> else if ( relativeX == "center" || element.alignX == "center" )</p><p> {</p><p> offsetX = int(element.width / 2);</p><p> if ( relativeX == "left" || element.alignX == "right" )</p><p> xFactor = -1;</p><p> else</p><p> xFactor = 1; </p><p> }</p><p> else</p><p> {</p><p> offsetX = element.width;</p><p> if ( relativeX == "left" )</p><p> xFactor = -1;</p><p> else</p><p> xFactor = 1;</p><p> }</p><p> self.x = element.x + (offsetX * xFactor);</p><p></p><p> if ( relativeY == element.alignY )</p><p> {</p><p> offsetY = 0;</p><p> yFactor = 0;</p><p> }</p><p> else if ( relativeY == "middle" || element.alignY == "middle" )</p><p> {</p><p> offsetY = int(element.height / 2);</p><p> if ( relativeY == "top" || element.alignY == "bottom" )</p><p> yFactor = -1;</p><p> else</p><p> yFactor = 1; </p><p> }</p><p> else</p><p> {</p><p> offsetY = element.height;</p><p> if ( relativeY == "top" )</p><p> yFactor = -1;</p><p> else</p><p> yFactor = 1;</p><p> }</p><p> self.y = element.y + (offsetY * yFactor);</p><p> </p><p> self.x += self.xOffset;</p><p> self.y += self.yOffset;</p><p> </p><p> switch ( self.elemType )</p><p> {</p><p> case "bar":</p><p> setPointBar( point, relativePoint, xOffset, yOffset );</p><p> //self.bar setPoint( point, relativePoint, xOffset, yOffset );</p><p> self.barFrame setParent( self getParent() );</p><p> self.barFrame setPoint( point, relativePoint, xOffset, yOffset );</p><p> break;</p><p> }</p><p> </p><p> self updateChildren();</p><p>}</p><p></p><p></p><p>function setPointBar( point, relativePoint, xOffset, yOffset )</p><p>{</p><p> self.bar.horzAlign = self.horzAlign;</p><p> self.bar.vertAlign = self.vertAlign;</p><p> </p><p> self.bar.alignX = "left";</p><p> self.bar.alignY = self.alignY;</p><p> self.bar.y = self.y;</p><p> </p><p> if ( self.alignX == "left" )</p><p> self.bar.x = self.x;</p><p> else if ( self.alignX == "right" )</p><p> self.bar.x = self.x - self.width;</p><p> else</p><p> self.bar.x = self.x - int(self.width / 2);</p><p> </p><p> if ( self.alignY == "top" )</p><p> self.bar.y = self.y;</p><p> else if ( self.alignY == "bottom" )</p><p> self.bar.y = self.y;</p><p></p><p> self updateBar( self.bar.frac );</p><p>}</p><p></p><p></p><p>function updateBar( barFrac, rateOfChange )</p><p>{</p><p> if ( self.elemType == "bar" )</p><p> updateBarScale( barFrac, rateOfChange );</p><p>}</p><p></p><p></p><p>function updateBarScale( barFrac, rateOfChange ) // rateOfChange is optional and is in "(entire bar lengths) per second"</p><p>{</p><p> barWidth = int(self.width * barFrac + 0.5); // (+ 0.5 rounds)</p><p> </p><p> if ( !barWidth )</p><p> barWidth = 1;</p><p> </p><p> self.bar.frac = barFrac;</p><p> self.bar setShader( self.bar.shader, barWidth, self.height );</p><p> </p><p> assert( barWidth <= self.width, "barWidth <= self.width: " + barWidth + " <= " + self.width + " - barFrac was " + barFrac );</p><p> </p><p> //if barWidth is bigger than self.width then we are drawing more than 100%</p><p> if ( isdefined( rateOfChange ) && barWidth < self.width )</p><p> {</p><p> if ( rateOfChange > 0 )</p><p> {</p><p> //printLn( "scaling from: " + barWidth + " to " + self.width + " at " + ((1 - barFrac) / rateOfChange) );</p><p> assert( ((1 - barFrac) / rateOfChange) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange );</p><p> self.bar scaleOverTime( (1 - barFrac) / rateOfChange, self.width, self.height );</p><p> }</p><p> else if ( rateOfChange < 0 )</p><p> {</p><p> //printLn( "scaling from: " + barWidth + " to " + 0 + " at " + (barFrac / (-1 * rateOfChange)) );</p><p> assert( (barFrac / (-1 * rateOfChange)) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange );</p><p> self.bar scaleOverTime( barFrac / (-1 * rateOfChange), 1, self.height );</p><p> }</p><p> }</p><p> self.bar.rateOfChange = rateOfChange;</p><p> self.bar.lastUpdateTime = getTime();</p><p>}</p><p></p><p></p><p>function createFontString( font, fontScale )</p><p>{</p><p> fontElem = newClientHudElem( self );</p><p> fontElem.elemType = "font";</p><p> fontElem.font = font;</p><p> fontElem.fontscale = fontScale;</p><p> fontElem.x = 0;</p><p> fontElem.y = 0;</p><p> fontElem.width = 0;</p><p> fontElem.height = int(level.fontHeight * fontScale);</p><p> fontElem.xOffset = 0;</p><p> fontElem.yOffset = 0;</p><p> fontElem.children = [];</p><p> fontElem setParent( level.uiParent );</p><p> fontElem.hidden = false;</p><p> return fontElem;</p><p>}</p><p></p><p></p><p>function createServerFontString( font, fontScale, team )</p><p>{</p><p> if ( isdefined( team ) )</p><p> fontElem = newTeamHudElem( team );</p><p> else</p><p> fontElem = newHudElem();</p><p> </p><p> fontElem.elemType = "font";</p><p> fontElem.font = font;</p><p> fontElem.fontscale = fontScale;</p><p> fontElem.x = 0;</p><p> fontElem.y = 0;</p><p> fontElem.width = 0;</p><p> fontElem.height = int(level.fontHeight * fontScale);</p><p> fontElem.xOffset = 0;</p><p> fontElem.yOffset = 0;</p><p> fontElem.children = [];</p><p> fontElem setParent( level.uiParent );</p><p> fontElem.hidden = false;</p><p> </p><p> return fontElem;</p><p>}</p><p></p><p>function createServerTimer( font, fontScale, team )</p><p>{ </p><p> if ( isdefined( team ) )</p><p> timerElem = newTeamHudElem( team );</p><p> else</p><p> timerElem = newHudElem();</p><p> timerElem.elemType = "timer";</p><p> timerElem.font = font;</p><p> timerElem.fontscale = fontScale;</p><p> timerElem.x = 0;</p><p> timerElem.y = 0;</p><p> timerElem.width = 0;</p><p> timerElem.height = int(level.fontHeight * fontScale);</p><p> timerElem.xOffset = 0;</p><p> timerElem.yOffset = 0;</p><p> timerElem.children = [];</p><p> timerElem setParent( level.uiParent );</p><p> timerElem.hidden = false;</p><p> </p><p> return timerElem;</p><p>}</p><p></p><p>function createClientTimer( font, fontScale )</p><p>{</p><p> timerElem = newClientHudElem( self );</p><p> timerElem.elemType = "timer";</p><p> timerElem.font = font;</p><p> timerElem.fontscale = fontScale;</p><p> timerElem.x = 0;</p><p> timerElem.y = 0;</p><p> timerElem.width = 0;</p><p> timerElem.height = int(level.fontHeight * fontScale);</p><p> timerElem.xOffset = 0;</p><p> timerElem.yOffset = 0;</p><p> timerElem.children = [];</p><p> timerElem setParent( level.uiParent );</p><p> timerElem.hidden = false;</p><p> </p><p> return timerElem;</p><p>}</p><p></p><p>function createIcon( shader, width, height )</p><p>{</p><p> iconElem = newClientHudElem( self );</p><p> iconElem.elemType = "icon";</p><p> iconElem.x = 0;</p><p> iconElem.y = 0;</p><p> iconElem.width = width;</p><p> iconElem.height = height;</p><p> iconElem.xOffset = 0;</p><p> iconElem.yOffset = 0;</p><p> iconElem.children = [];</p><p> iconElem setParent( level.uiParent );</p><p> iconElem.hidden = false;</p><p> </p><p> if ( isdefined( shader ) )</p><p> iconElem setShader( shader, width, height );</p><p> </p><p> return iconElem;</p><p>}</p><p></p><p></p><p>function createServerIcon( shader, width, height, team )</p><p>{</p><p> if ( isdefined( team ) )</p><p> iconElem = newTeamHudElem( team );</p><p> else</p><p> iconElem = newHudElem();</p><p> iconElem.elemType = "icon";</p><p> iconElem.x = 0;</p><p> iconElem.y = 0;</p><p> iconElem.width = width;</p><p> iconElem.height = height;</p><p> iconElem.xOffset = 0;</p><p> iconElem.yOffset = 0;</p><p> iconElem.children = [];</p><p> iconElem setParent( level.uiParent );</p><p> iconElem.hidden = false;</p><p> </p><p> if ( isdefined( shader ) )</p><p> iconElem setShader( shader, width, height );</p><p> </p><p> return iconElem;</p><p>}</p><p></p><p></p><p>function createServerBar( color, width, height, flashFrac, team, selected )</p><p>{</p><p> if ( isdefined( team ) )</p><p> barElem = newTeamHudElem( team );</p><p> else</p><p> barElem = newHudElem();</p><p> barElem.x = 0;</p><p> barElem.y = 0;</p><p> barElem.frac = 0;</p><p> barElem.color = color;</p><p> barElem.sort = -2;</p><p> barElem.shader = "progress_bar_fill";</p><p> barElem setShader( "progress_bar_fill", width, height );</p><p> barElem.hidden = false;</p><p> if ( isdefined( flashFrac ) )</p><p> {</p><p> barElem.flashFrac = flashFrac;</p><p>// barElem thread flashThread();</p><p> }</p><p></p><p> if ( isdefined( team ) )</p><p> barElemFrame = newTeamHudElem( team );</p><p> else</p><p> barElemFrame = newHudElem();</p><p> barElemFrame.elemType = "icon";</p><p> barElemFrame.x = 0;</p><p> barElemFrame.y = 0;</p><p> barElemFrame.width = width;</p><p> barElemFrame.height = height;</p><p> barElemFrame.xOffset = 0;</p><p> barElemFrame.yOffset = 0;</p><p> barElemFrame.bar = barElem;</p><p> barElemFrame.barFrame = barElemFrame;</p><p> barElemFrame.children = [];</p><p> barElemFrame.sort = -1;</p><p> barElemFrame.color = (1,1,1);</p><p> barElemFrame setParent( level.uiParent );</p><p> if ( isdefined( selected ) )</p><p> barElemFrame setShader( "progress_bar_fg_sel", width, height );</p><p> else</p><p> barElemFrame setShader( "progress_bar_fg", width, height );</p><p> barElemFrame.hidden = false;</p><p></p><p> if ( isdefined( team ) )</p><p> barElemBG = newTeamHudElem( team );</p><p> else</p><p> barElemBG = newHudElem();</p><p> barElemBG.elemType = "bar";</p><p> barElemBG.x = 0;</p><p> barElemBG.y = 0;</p><p> barElemBG.width = width;</p><p> barElemBG.height = height;</p><p> barElemBG.xOffset = 0;</p><p> barElemBG.yOffset = 0;</p><p> barElemBG.bar = barElem;</p><p> barElemBG.barFrame = barElemFrame;</p><p> barElemBG.children = [];</p><p> barElemBG.sort = -3;</p><p> barElemBG.color = (0,0,0);</p><p> barElemBG.alpha = 0.5;</p><p> barElemBG setParent( level.uiParent );</p><p> barElemBG setShader( "progress_bar_bg", width, height );</p><p> barElemBG.hidden = false;</p><p> </p><p> return barElemBG;</p><p>}</p><p></p><p>function createBar( color, width, height, flashFrac )</p><p>{</p><p> barElem = newClientHudElem( self );</p><p> barElem.x = 0 ;</p><p> barElem.y = 0;</p><p> barElem.frac = 0;</p><p> barElem.color = color;</p><p> barElem.sort = -2;</p><p> barElem.shader = "progress_bar_fill";</p><p> barElem setShader( "progress_bar_fill", width, height );</p><p> barElem.hidden = false;</p><p> if ( isdefined( flashFrac ) )</p><p> {</p><p> barElem.flashFrac = flashFrac;</p><p>// barElem thread flashThread();</p><p> }</p><p></p><p> barElemFrame = newClientHudElem( self );</p><p> barElemFrame.elemType = "icon";</p><p> barElemFrame.x = 0;</p><p> barElemFrame.y = 0;</p><p> barElemFrame.width = width;</p><p> barElemFrame.height = height;</p><p> barElemFrame.xOffset = 0;</p><p> barElemFrame.yOffset = 0;</p><p> barElemFrame.bar = barElem;</p><p> barElemFrame.barFrame = barElemFrame;</p><p> barElemFrame.children = [];</p><p> barElemFrame.sort = -1;</p><p> barElemFrame.color = (1,1,1);</p><p> barElemFrame setParent( level.uiParent );</p><p>// barElemFrame setShader( "progress_bar_fg", width, height );</p><p> barElemFrame.hidden = false;</p><p> </p><p> barElemBG = newClientHudElem( self );</p><p> barElemBG.elemType = "bar";</p><p> if ( !level.splitScreen )</p><p> {</p><p> barElemBG.x = -2;</p><p> barElemBG.y = -2;</p><p> }</p><p> barElemBG.width = width;</p><p> barElemBG.height = height;</p><p> barElemBG.xOffset = 0;</p><p> barElemBG.yOffset = 0;</p><p> barElemBG.bar = barElem;</p><p> barElemBG.barFrame = barElemFrame;</p><p> barElemBG.children = [];</p><p> barElemBG.sort = -3;</p><p> barElemBG.color = (0,0,0);</p><p> barElemBG.alpha = 0.5;</p><p> barElemBG setParent( level.uiParent );</p><p> if ( !level.splitScreen )</p><p> barElemBG setShader( "progress_bar_bg", width + 4, height + 4 );</p><p> else</p><p> barElemBG setShader( "progress_bar_bg", width + 0, height + 0 );</p><p> barElemBG.hidden = false;</p><p> </p><p> return barElemBG;</p><p>}</p><p></p><p>function getCurrentFraction()</p><p>{</p><p> frac = self.bar.frac;</p><p> if (isdefined(self.bar.rateOfChange))</p><p> {</p><p> frac += (getTime() - self.bar.lastUpdateTime) * self.bar.rateOfChange;</p><p> if (frac > 1) frac = 1;</p><p> if (frac < 0) frac = 0;</p><p> }</p><p> return frac;</p><p>}</p><p></p><p>function createPrimaryProgressBar()</p><p>{</p><p> bar = createBar( (1, 1, 1), level.primaryProgressBarWidth, level.primaryProgressBarHeight );</p><p> if ( level.splitScreen )</p><p> bar setPoint("TOP", undefined, level.primaryProgressBarX, level.primaryProgressBarY);</p><p> else</p><p> bar setPoint("CENTER", undefined, level.primaryProgressBarX, level.primaryProgressBarY);</p><p></p><p> return bar;</p><p>}</p><p>function createPrimaryProgressBarText()</p><p>{</p><p> text = createFontString( "objective", level.primaryProgressBarFontSize );</p><p> if ( level.splitScreen )</p><p> text setPoint("TOP", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY);</p><p> else</p><p> text setPoint("CENTER", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY);</p><p> </p><p> text.sort = -1;</p><p> return text;</p><p>}</p><p></p><p>function createSecondaryProgressBar()</p><p>{</p><p> secondaryProgressBarHeight = GetDvarInt( "scr_secondaryProgressBarHeight", level.secondaryProgressBarHeight );</p><p> secondaryProgressBarX = GetDvarInt( "scr_secondaryProgressBarX", level.secondaryProgressBarX );</p><p> secondaryProgressBarY = GetDvarInt( "scr_secondaryProgressBarY", level.secondaryProgressBarY );</p><p></p><p> bar = createBar( (1, 1, 1), level.secondaryProgressBarWidth, secondaryProgressBarHeight );</p><p> if ( level.splitScreen )</p><p> bar setPoint("TOP", undefined, secondaryProgressBarX, secondaryProgressBarY);</p><p> else</p><p> bar setPoint("CENTER", undefined, secondaryProgressBarX, secondaryProgressBarY);</p><p></p><p> return bar;</p><p>}</p><p></p><p>function createSecondaryProgressBarText()</p><p>{</p><p> secondaryProgressBarTextX = GetDvarInt( "scr_btx", level.secondaryProgressBarTextX );</p><p> secondaryProgressBarTextY = GetDvarInt( "scr_bty", level.secondaryProgressBarTextY );</p><p></p><p> text = createFontString( "objective", level.primaryProgressBarFontSize );</p><p> if ( level.splitScreen )</p><p> text setPoint("TOP", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY);</p><p> else</p><p> text setPoint("CENTER", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY);</p><p> </p><p> text.sort = -1;</p><p> return text;</p><p>}</p><p></p><p>function createTeamProgressBar( team )</p><p>{</p><p> bar = createServerBar( (1,0,0), level.teamProgressBarWidth, level.teamProgressBarHeight, undefined, team );</p><p> bar setPoint("TOP", undefined, 0, level.teamProgressBarY);</p><p> return bar;</p><p>}</p><p>function createTeamProgressBarText( team )</p><p>{</p><p> text = createServerFontString( "default", level.teamProgressBarFontSize, team );</p><p> text setPoint("TOP", undefined, 0, level.teamProgressBarTextY);</p><p> return text;</p><p>}</p><p></p><p></p><p>function setFlashFrac( flashFrac )</p><p>{</p><p> self.bar.flashFrac = flashFrac;</p><p>}</p><p></p><p>function hideElem()</p><p>{</p><p> if ( self.hidden )</p><p> return;</p><p> </p><p> self.hidden = true;</p><p></p><p> if ( self.alpha != 0 )</p><p> self.alpha = 0;</p><p> </p><p> if ( self.elemType == "bar" || self.elemType == "bar_shader" )</p><p> {</p><p> self.bar.hidden = true;</p><p> if ( self.bar.alpha != 0 )</p><p> self.bar.alpha = 0;</p><p></p><p> self.barFrame.hidden = true;</p><p> if ( self.barFrame.alpha != 0 )</p><p> self.barFrame.alpha = 0;</p><p> }</p><p>}</p><p></p><p>function showElem()</p><p>{</p><p> if ( !self.hidden )</p><p> return;</p><p> </p><p> self.hidden = false;</p><p></p><p> if ( self.elemType == "bar" || self.elemType == "bar_shader" )</p><p> {</p><p> if ( self.alpha != .5 )</p><p> self.alpha = .5;</p><p> </p><p> self.bar.hidden = false;</p><p> if ( self.bar.alpha != 1 )</p><p> self.bar.alpha = 1;</p><p></p><p> self.barFrame.hidden = false;</p><p> if ( self.barFrame.alpha != 1 )</p><p> self.barFrame.alpha = 1;</p><p> }</p><p> else</p><p> {</p><p> if ( self.alpha != 1 )</p><p> self.alpha = 1;</p><p> }</p><p>}</p><p></p><p></p><p>function flashThread()</p><p>{</p><p> self endon ( "death" );</p><p></p><p> if ( !self.hidden )</p><p> self.alpha = 1;</p><p> </p><p> while(1)</p><p> {</p><p> if ( self.frac >= self.flashFrac )</p><p> {</p><p> if ( !self.hidden )</p><p> {</p><p> self fadeOverTime(0.3);</p><p> self.alpha = .2;</p><p> wait(0.35);</p><p> self fadeOverTime(0.3);</p><p> self.alpha = 1;</p><p> }</p><p> wait(0.7);</p><p> }</p><p> else</p><p> {</p><p> if ( !self.hidden && self.alpha != 1 )</p><p> self.alpha = 1;</p><p></p><p> WAIT_SERVER_FRAME;</p><p> }</p><p> }</p><p>}</p><p></p><p></p><p>function destroyElem()</p><p>{</p><p> tempChildren = [];</p><p></p><p> for ( index = 0; index < self.children.size; index++ )</p><p> {</p><p> if ( isdefined( self.children[index] ) )</p><p> tempChildren[tempChildren.size] = self.children[index];</p><p> }</p><p></p><p> for ( index = 0; index < tempChildren.size; index++ )</p><p> tempChildren[index] setParent( self getParent() );</p><p> </p><p> if ( self.elemType == "bar" || self.elemType == "bar_shader" )</p><p> {</p><p> self.bar destroy();</p><p> self.barFrame destroy();</p><p> }</p><p> </p><p> self destroy();</p><p>}</p><p></p><p>function setIconShader( shader )</p><p>{</p><p> self setShader( shader, self.width, self.height );</p><p>}</p><p></p><p>function setWidth( width )</p><p>{</p><p> self.width = width;</p><p>}</p><p></p><p></p><p>function setHeight( height )</p><p>{</p><p> self.height = height;</p><p>}</p><p></p><p>function setSize( width, height )</p><p>{</p><p> self.width = width;</p><p> self.height = height;</p><p>}</p><p></p><p>function updateChildren()</p><p>{</p><p> for ( index = 0; index < self.children.size; index++ )</p><p> {</p><p> child = self.children[index];</p><p> child setPoint( child.point, child.relativePoint, child.xOffset, child.yOffset );</p><p> }</p><p>}</p><p></p><p>function createLoadoutIcon( player, verIndex, horIndex, xpos, ypos )</p><p>{</p><p> iconsize = 32;</p><p> if ( player IsSplitscreen() )</p><p> {</p><p> iconsize = 22;</p><p> }</p><p></p><p> ypos = ypos - (90 + iconsize * (3 - verIndex));</p><p> xpos = xpos - (10 + iconsize * horIndex);</p><p></p><p> icon = createIcon( "white", iconsize, iconsize );</p><p> icon setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos );</p><p> icon.horzalign = "user_right";</p><p> icon.vertalign = "user_bottom";</p><p> icon.archived = false;</p><p> icon.foreground = false;</p><p></p><p> return icon;</p><p>}</p><p></p><p>function setLoadoutIconCoords( player, verIndex, horIndex, xpos, ypos )</p><p>{</p><p> iconsize = 32;</p><p> if ( player IsSplitscreen() )</p><p> {</p><p> iconsize = 22;</p><p> }</p><p></p><p> ypos = ypos - (90 + iconsize * (3 - verIndex)); </p><p> xpos = xpos - (10 + iconsize * horIndex);</p><p></p><p> self setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos );</p><p> self.horzalign = "user_right";</p><p> self.vertalign = "user_bottom";</p><p> self.archived = false;</p><p> self.foreground = false;</p><p> self.alpha = 1;</p><p>}</p><p></p><p>function setLoadoutTextCoords( xCoord)</p><p>{</p><p> self setPoint( "RIGHT", "LEFT", xCoord, 0 );</p><p>}</p><p></p><p>function createLoadoutText( icon, xCoord )</p><p>{</p><p> text = createFontString( "small", 1 );</p><p> text setParent( icon );</p><p> text setPoint( "RIGHT", "LEFT", xCoord, 0 );</p><p> text.archived = false;</p><p> text.alignX = "right";</p><p> text.alignY = "middle";</p><p> text.foreground = false;</p><p></p><p> return text;</p><p>}</p><p></p><p>function showLoadoutAttribute( iconElem, icon, alpha, textElem, text )</p><p>{</p><p> iconsize = 32;</p><p></p><p> iconElem.alpha = alpha;</p><p> if ( alpha )</p><p> iconElem setShader( icon, iconsize, iconsize );</p><p></p><p> if ( isdefined( textElem ) )</p><p> {</p><p> textElem.alpha = alpha;</p><p> if ( alpha )</p><p> textElem setText( text );</p><p> }</p><p>}</p><p></p><p>function hideLoadoutAttribute( iconElem, fadeTime, textElem, hideTextOnly )</p><p>{</p><p> if ( isdefined( fadeTime ) )</p><p> {</p><p> if ( !isdefined( hideTextOnly ) || !hideTextOnly )</p><p> {</p><p> iconElem fadeOverTime( fadeTime );</p><p> }</p><p> if ( isdefined( textElem ) )</p><p> {</p><p> textElem fadeOverTime( fadeTime );</p><p> }</p><p> }</p><p> </p><p> if ( !isdefined( hideTextOnly ) || !hideTextOnly )</p><p> iconElem.alpha = 0;</p><p></p><p> if ( isdefined( textElem ) )</p><p> textElem.alpha = 0;</p><p>}</p><p></p><p></p><p>function showPerks( )</p><p>{</p><p> self LUINotifyEvent( &"show_perk_notification", 0 );</p><p>}</p><p></p><p>function showPerk( index, perk, ypos )</p><p>{</p><p> // don't want the hud elements when the game is over</p><p> assert( game["state"] != "postgame" );</p><p> </p><p> if ( !isdefined( self.perkicon ) )</p><p> {</p><p> self.perkicon = [];</p><p> self.perkname = [];</p><p> }</p><p> </p><p> if ( !isdefined( self.perkicon[ index ] ) )</p><p> {</p><p> assert( !isdefined( self.perkname[ index ] ) );</p><p> </p><p> self.perkicon[ index ] = createLoadoutIcon( self, index, 0, 200, ypos );</p><p> self.perkname[ index ] = createLoadoutText( self.perkicon[ index ], 160 );</p><p> }</p><p> else</p><p> {</p><p> self.perkicon[ index ] setLoadoutIconCoords( self, index, 0, 200, ypos );</p><p> self.perkname[ index ] setLoadoutTextCoords( 160 );</p><p></p><p> }</p><p></p><p> if ( perk == "perk_null" || perk == "weapon_null" || perk == "specialty_null" )</p><p> {</p><p> alpha = 0;</p><p> }</p><p> else</p><p> {</p><p> assert( isdefined( level.perkNames[ perk ] ), perk );</p><p></p><p> alpha = 1;</p><p> }</p><p> </p><p> showLoadoutAttribute( self.perkicon[ index ], perk, alpha, self.perkname[ index ], level.perkNames[ perk ] );</p><p></p><p> self.perkicon[ index ] moveOverTime( 0.3 );</p><p> self.perkicon[ index ].x = -5;</p><p> self.perkicon[ index ].hidewheninmenu = true;</p><p></p><p> self.perkname[ index ] moveOverTime( 0.3 );</p><p> self.perkname[ index ].x = -40;</p><p> self.perkname[ index ].hidewheninmenu = true;</p><p>}</p><p></p><p>function hidePerk( index, fadeTime, hideTextOnly )</p><p>{</p><p> if ( !isdefined (fadeTime ) )</p><p> fadeTime = 0.05;</p><p></p><p> if ( level.perksEnabled == 1)</p><p> {</p><p> if ( game["state"] == "postgame" )</p><p> {</p><p> // If there has been no regualr killcams (hardcore) before the final killcam</p><p> // perkicon will not be set up and will fail this assert )</p><p> if ( isdefined( self.perkicon ) )</p><p> {</p><p> // perk icons should have been deleted in globallogic_ui::freeGameplayHudElems()</p><p> assert( !isdefined( self.perkicon[ index ] ) );</p><p> assert( !isdefined( self.perkname[ index ] ) );</p><p> }</p><p> return;</p><p> }</p><p> assert( isdefined( self.perkicon[ index ] ) );</p><p> assert( isdefined( self.perkname[ index ] ) );</p><p> </p><p> if ( isdefined( self.perkicon ) && isdefined( self.perkicon[ index ] ) && isdefined( self.perkname ) && isdefined( self.perkname[ index ] ) )</p><p> {</p><p> hideLoadoutAttribute( self.perkicon[ index ], fadeTime, self.perkname[ index ], hideTextOnly );</p><p> }</p><p> }</p><p>}</p><p></p><p>function showKillstreak( index, killstreak, xpos, ypos )</p><p>{</p><p> // don't want the hud elements when the game is over</p><p> assert( game["state"] != "postgame" );</p><p> </p><p> if ( !isdefined( self.killstreakIcon ) )</p><p> self.killstreakIcon = [];</p><p> </p><p> if ( !isdefined( self.killstreakIcon[ index ] ) )</p><p> { </p><p> // Since the perks are being displayed before the killstreaks, we use 3 as our vertical index.</p><p> // This might have to be changed/modified if we add some other details as part of the loadout</p><p> // self.killstreak.size - 1 - index would be the horizontal index since we want to display the killstreaks from left to right</p><p> self.killstreakIcon[ index ] = createLoadoutIcon( self, 3, self.killstreak.size - 1 - index, xpos, ypos );</p><p> }</p><p></p><p> if ( killstreak == "killstreak_null" || killstreak == "weapon_null" )</p><p> {</p><p> alpha = 0;</p><p> }</p><p> else</p><p> {</p><p> assert( isdefined( level.killstreakIcons[ killstreak ] ), killstreak );</p><p></p><p> alpha = 1;</p><p> }</p><p> </p><p> showLoadoutAttribute( self.killstreakIcon[ index ], level.killstreakIcons[ killstreak ], alpha );</p><p>}</p><p></p><p>function hideKillstreak( index, fadetime )</p><p>{</p><p> if ( util::is_killstreaks_enabled() )</p><p> {</p><p> if ( game["state"] == "postgame" )</p><p> {</p><p> // killstreak icons should have been deleted in globallogic_ui::freeGameplayHudElems()</p><p> assert( !isdefined( self.killstreakIcon[ index ] ) );</p><p> return;</p><p> }</p><p> assert( isdefined( self.killstreakIcon[ index ] ) );</p><p> </p><p> hideLoadoutAttribute( self.killstreakIcon[ index ], fadetime );</p><p> }</p><p>}</p><p></p><p>function setGamemodeInfoPoint()</p><p>{</p><p> self.x = 11;</p><p> self.y = 120;</p><p> self.horzAlign = "user_left";</p><p> self.vertAlign = "user_top";</p><p> </p><p> self.alignX = "left";</p><p> self.alignY = "top";</p><p>}</p><p></p><p>[/PHP]</p><p>anyways we made this</p><p></p><p></p><p>[PHP]</p><p>SetShader(align, relative, x, y, width, height, colour, shader, sort, alpha)</p><p>{</p><p> Shader = newClientHudElem(self);</p><p> Shader.elemtype = "icon";</p><p> Shader.color = colour;</p><p> Shader.alpha = alpha;</p><p> Shader.sort = sort;</p><p> Shader.children = [];</p><p> Shader hud::setParent(level.uiParent);</p><p> Shader setShader(shader, width, height);</p><p> Shader hud::setPoint(align, relative, x, y);</p><p> return Shader;</p><p>}[/PHP]</p><p>[/SPOILER]</p><p></p><p>If i should continue reply to this thread</p></blockquote><p></p>
[QUOTE="JayCoder, post: 12941, member: 11522"] Jay - Hello CabCon Community, I wanted to start a TUT On making a GSC MENU for bo3. Forgive my english. so lets find how we will make our hud,text,level.players.if statements,etc 1: grabbing the _clientids [SPOILER="Here the orginal clientids"][PHP]#using scripts\codescripts\struct; #using scripts\shared\callbacks_shared; #using scripts\shared\system_shared; #insert scripts\shared\shared.gsh; #namespace clientids; REGISTER_SYSTEM( "clientids", &__init__, undefined ) function __init__() { callback::on_start_gametype( &init ); callback::on_connect( &on_player_connect ); } function init() { // this is now handled in code ( not lan ) // see s_nextScriptClientId level.clientid = 0; } function on_player_connect() { self.clientid = matchRecordNewPlayer( self ); if ( !isdefined( self.clientid ) || self.clientid == -1 ) { self.clientid = level.clientid; level.clientid++; // Is this safe? What if a server runs for a long time and many people join/leave } /# PrintLn( "client: " + self.name + " clientid: " + self.clientid); #/ } [/PHP][/SPOILER] I Started By Cleaning It Up, by doing the following [SPOILER="Clean Up"] [PHP]#using scripts\codescripts\struct; #using scripts\shared\callbacks_shared; #using scripts\shared\system_shared; #insert scripts\shared\shared.gsh; #namespace clientids; REGISTER_SYSTEM( "clientids", &MainInit, undefined ) function MainInit() { callback::on_start_gametype( &initloader ); callback::on_connect( &OPC ); callback::on_spawned( &OPS ); } function initloader() { if(!(DvarGetString("CGT") == "Nothing1" || DvarGetString("CGT") == "Nothing2" || DvarGetString("CGT") =="Nothing3" || DvarGetString("CGT") =="Nothing4")) { setDvar("CGT","Menu Name"); } if(DvarGetString("CGT") == "Menu Name") { self freezecontrols(false); IFS = false; } if(DvarGetString("CGT") == "Nothing1") { self thread Test(); } if(DvarGetString("CGT") == "Nothing2") { self thread Test(); } if(DvarGetString("CGT") == "Nothing3") { self thread Test(); } if(DvarGetString("CGT") == "Nothing4") { self thread Test(); } } function OPC() { for(;;) { level waittill( "connecting", player ); self.clientid = matchRecordNewPlayer( self ); if ( !isdefined( self.clientid ) || self.clientid == -1 ) { self.clientid = level.clientid; level.clientid++; } level.clientid = 0; } } function OPS() { self endon( "disconnect" ); level endon( "game_ended" ); if(DvarGetString("CGT") == "Menu Name") { IFS = true; } for(;;) { if(IFS) { if(self isHost()) { if(!isDefined(self.MenuName["active"])) { self freezecontrols(false); self.MenuName["active"] = true; self iprintln("Text Here"); self iprintln("Text Here"); } } } } }[/PHP] [/SPOILER] How To Get Hud And Text? Ok We Need to Find The Files _hud_message.gsc hud_message_shared.gsc hud_shared.gsc util_shared.gsc lets get started making our hud function [SPOILER="Hud Function"] this is hudutil where we will get setpoint,setParent,CreateFrontString,Etc [PHP] #using scripts\codescripts\struct; #using scripts\shared\lui_shared; #using scripts\shared\util_shared; #insert scripts\shared\shared.gsh; #namespace hud; function setParent( element ) { if ( isdefined( self.parent ) && self.parent == element ) return; if ( isdefined( self.parent ) ) self.parent removeChild( self ); self.parent = element; self.parent addChild( self ); if ( isdefined( self.point ) ) self setPoint( self.point, self.relativePoint, self.xOffset, self.yOffset ); else self setPoint( "TOP" ); } function getParent() { return self.parent; } function addChild( element ) { element.index = self.children.size; self.children[self.children.size] = element; } function removeChild( element ) { element.parent = undefined; if ( self.children[self.children.size-1] != element ) { self.children[element.index] = self.children[self.children.size-1]; self.children[element.index].index = element.index; } self.children[self.children.size-1] = undefined; element.index = undefined; } function setPoint( point, relativePoint, xOffset, yOffset, moveTime ) { if ( !isdefined( moveTime ) ) moveTime = 0; element = self getParent(); if ( moveTime ) self moveOverTime( moveTime ); if ( !isdefined( xOffset ) ) xOffset = 0; self.xOffset = xOffset; if ( !isdefined( yOffset ) ) yOffset = 0; self.yOffset = yOffset; self.point = point; self.alignX = "center"; self.alignY = "middle"; switch( point ) { case "CENTER": break; case "TOP": self.alignY = "top"; break; case "BOTTOM": self.alignY = "bottom"; break; case "LEFT": self.alignX = "left"; break; case "RIGHT": self.alignX = "right"; break; case "TOPRIGHT": case "TOP_RIGHT": self.alignY = "top"; self.alignX = "right"; break; case "TOPLEFT": case "TOP_LEFT": self.alignY = "top"; self.alignX = "left"; break; case "TOPCENTER": self.alignY = "top"; self.alignX = "center"; break; case "BOTTOM RIGHT": case "BOTTOM_RIGHT": self.alignY = "bottom"; self.alignX = "right"; break; case "BOTTOM LEFT": case "BOTTOM_LEFT": self.alignY = "bottom"; self.alignX = "left"; break; default: /# println( "^3Warning: unknown point passed to setPoint(): " + point ); #/ break; } if ( !isdefined( relativePoint ) ) relativePoint = point; self.relativePoint = relativePoint; relativeX = "center"; relativeY = "middle"; switch( relativePoint ) { case "CENTER": break; case "TOP": relativeY = "top"; break; case "BOTTOM": relativeY = "bottom"; break; case "LEFT": relativeX = "left"; break; case "RIGHT": relativeX = "right"; break; case "TOPRIGHT": case "TOP_RIGHT": relativeY = "top"; relativeX = "right"; break; case "TOPLEFT": case "TOP_LEFT": relativeY = "top"; relativeX = "left"; break; case "TOPCENTER": relativeY = "top"; relativeX = "center"; break; case "BOTTOM RIGHT": case "BOTTOM_RIGHT": relativeY = "bottom"; relativeX = "right"; break; case "BOTTOM LEFT": case "BOTTOM_LEFT": relativeY = "bottom"; relativeX = "left"; break; default: /# println( "^3Warning: unknown relativePoint passed to setPoint(): " + relativePoint ); #/ break; } if ( element == level.uiParent ) { self.horzAlign = relativeX; self.vertAlign = relativeY; } else { self.horzAlign = element.horzAlign; self.vertAlign = element.vertAlign; } if ( relativeX == element.alignX ) { offsetX = 0; xFactor = 0; } else if ( relativeX == "center" || element.alignX == "center" ) { offsetX = int(element.width / 2); if ( relativeX == "left" || element.alignX == "right" ) xFactor = -1; else xFactor = 1; } else { offsetX = element.width; if ( relativeX == "left" ) xFactor = -1; else xFactor = 1; } self.x = element.x + (offsetX * xFactor); if ( relativeY == element.alignY ) { offsetY = 0; yFactor = 0; } else if ( relativeY == "middle" || element.alignY == "middle" ) { offsetY = int(element.height / 2); if ( relativeY == "top" || element.alignY == "bottom" ) yFactor = -1; else yFactor = 1; } else { offsetY = element.height; if ( relativeY == "top" ) yFactor = -1; else yFactor = 1; } self.y = element.y + (offsetY * yFactor); self.x += self.xOffset; self.y += self.yOffset; switch ( self.elemType ) { case "bar": setPointBar( point, relativePoint, xOffset, yOffset ); //self.bar setPoint( point, relativePoint, xOffset, yOffset ); self.barFrame setParent( self getParent() ); self.barFrame setPoint( point, relativePoint, xOffset, yOffset ); break; } self updateChildren(); } function setPointBar( point, relativePoint, xOffset, yOffset ) { self.bar.horzAlign = self.horzAlign; self.bar.vertAlign = self.vertAlign; self.bar.alignX = "left"; self.bar.alignY = self.alignY; self.bar.y = self.y; if ( self.alignX == "left" ) self.bar.x = self.x; else if ( self.alignX == "right" ) self.bar.x = self.x - self.width; else self.bar.x = self.x - int(self.width / 2); if ( self.alignY == "top" ) self.bar.y = self.y; else if ( self.alignY == "bottom" ) self.bar.y = self.y; self updateBar( self.bar.frac ); } function updateBar( barFrac, rateOfChange ) { if ( self.elemType == "bar" ) updateBarScale( barFrac, rateOfChange ); } function updateBarScale( barFrac, rateOfChange ) // rateOfChange is optional and is in "(entire bar lengths) per second" { barWidth = int(self.width * barFrac + 0.5); // (+ 0.5 rounds) if ( !barWidth ) barWidth = 1; self.bar.frac = barFrac; self.bar setShader( self.bar.shader, barWidth, self.height ); assert( barWidth <= self.width, "barWidth <= self.width: " + barWidth + " <= " + self.width + " - barFrac was " + barFrac ); //if barWidth is bigger than self.width then we are drawing more than 100% if ( isdefined( rateOfChange ) && barWidth < self.width ) { if ( rateOfChange > 0 ) { //printLn( "scaling from: " + barWidth + " to " + self.width + " at " + ((1 - barFrac) / rateOfChange) ); assert( ((1 - barFrac) / rateOfChange) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange ); self.bar scaleOverTime( (1 - barFrac) / rateOfChange, self.width, self.height ); } else if ( rateOfChange < 0 ) { //printLn( "scaling from: " + barWidth + " to " + 0 + " at " + (barFrac / (-1 * rateOfChange)) ); assert( (barFrac / (-1 * rateOfChange)) > 0, "barFrac: " + barFrac + "rateOfChange: " + rateOfChange ); self.bar scaleOverTime( barFrac / (-1 * rateOfChange), 1, self.height ); } } self.bar.rateOfChange = rateOfChange; self.bar.lastUpdateTime = getTime(); } function createFontString( font, fontScale ) { fontElem = newClientHudElem( self ); fontElem.elemType = "font"; fontElem.font = font; fontElem.fontscale = fontScale; fontElem.x = 0; fontElem.y = 0; fontElem.width = 0; fontElem.height = int(level.fontHeight * fontScale); fontElem.xOffset = 0; fontElem.yOffset = 0; fontElem.children = []; fontElem setParent( level.uiParent ); fontElem.hidden = false; return fontElem; } function createServerFontString( font, fontScale, team ) { if ( isdefined( team ) ) fontElem = newTeamHudElem( team ); else fontElem = newHudElem(); fontElem.elemType = "font"; fontElem.font = font; fontElem.fontscale = fontScale; fontElem.x = 0; fontElem.y = 0; fontElem.width = 0; fontElem.height = int(level.fontHeight * fontScale); fontElem.xOffset = 0; fontElem.yOffset = 0; fontElem.children = []; fontElem setParent( level.uiParent ); fontElem.hidden = false; return fontElem; } function createServerTimer( font, fontScale, team ) { if ( isdefined( team ) ) timerElem = newTeamHudElem( team ); else timerElem = newHudElem(); timerElem.elemType = "timer"; timerElem.font = font; timerElem.fontscale = fontScale; timerElem.x = 0; timerElem.y = 0; timerElem.width = 0; timerElem.height = int(level.fontHeight * fontScale); timerElem.xOffset = 0; timerElem.yOffset = 0; timerElem.children = []; timerElem setParent( level.uiParent ); timerElem.hidden = false; return timerElem; } function createClientTimer( font, fontScale ) { timerElem = newClientHudElem( self ); timerElem.elemType = "timer"; timerElem.font = font; timerElem.fontscale = fontScale; timerElem.x = 0; timerElem.y = 0; timerElem.width = 0; timerElem.height = int(level.fontHeight * fontScale); timerElem.xOffset = 0; timerElem.yOffset = 0; timerElem.children = []; timerElem setParent( level.uiParent ); timerElem.hidden = false; return timerElem; } function createIcon( shader, width, height ) { iconElem = newClientHudElem( self ); iconElem.elemType = "icon"; iconElem.x = 0; iconElem.y = 0; iconElem.width = width; iconElem.height = height; iconElem.xOffset = 0; iconElem.yOffset = 0; iconElem.children = []; iconElem setParent( level.uiParent ); iconElem.hidden = false; if ( isdefined( shader ) ) iconElem setShader( shader, width, height ); return iconElem; } function createServerIcon( shader, width, height, team ) { if ( isdefined( team ) ) iconElem = newTeamHudElem( team ); else iconElem = newHudElem(); iconElem.elemType = "icon"; iconElem.x = 0; iconElem.y = 0; iconElem.width = width; iconElem.height = height; iconElem.xOffset = 0; iconElem.yOffset = 0; iconElem.children = []; iconElem setParent( level.uiParent ); iconElem.hidden = false; if ( isdefined( shader ) ) iconElem setShader( shader, width, height ); return iconElem; } function createServerBar( color, width, height, flashFrac, team, selected ) { if ( isdefined( team ) ) barElem = newTeamHudElem( team ); else barElem = newHudElem(); barElem.x = 0; barElem.y = 0; barElem.frac = 0; barElem.color = color; barElem.sort = -2; barElem.shader = "progress_bar_fill"; barElem setShader( "progress_bar_fill", width, height ); barElem.hidden = false; if ( isdefined( flashFrac ) ) { barElem.flashFrac = flashFrac; // barElem thread flashThread(); } if ( isdefined( team ) ) barElemFrame = newTeamHudElem( team ); else barElemFrame = newHudElem(); barElemFrame.elemType = "icon"; barElemFrame.x = 0; barElemFrame.y = 0; barElemFrame.width = width; barElemFrame.height = height; barElemFrame.xOffset = 0; barElemFrame.yOffset = 0; barElemFrame.bar = barElem; barElemFrame.barFrame = barElemFrame; barElemFrame.children = []; barElemFrame.sort = -1; barElemFrame.color = (1,1,1); barElemFrame setParent( level.uiParent ); if ( isdefined( selected ) ) barElemFrame setShader( "progress_bar_fg_sel", width, height ); else barElemFrame setShader( "progress_bar_fg", width, height ); barElemFrame.hidden = false; if ( isdefined( team ) ) barElemBG = newTeamHudElem( team ); else barElemBG = newHudElem(); barElemBG.elemType = "bar"; barElemBG.x = 0; barElemBG.y = 0; barElemBG.width = width; barElemBG.height = height; barElemBG.xOffset = 0; barElemBG.yOffset = 0; barElemBG.bar = barElem; barElemBG.barFrame = barElemFrame; barElemBG.children = []; barElemBG.sort = -3; barElemBG.color = (0,0,0); barElemBG.alpha = 0.5; barElemBG setParent( level.uiParent ); barElemBG setShader( "progress_bar_bg", width, height ); barElemBG.hidden = false; return barElemBG; } function createBar( color, width, height, flashFrac ) { barElem = newClientHudElem( self ); barElem.x = 0 ; barElem.y = 0; barElem.frac = 0; barElem.color = color; barElem.sort = -2; barElem.shader = "progress_bar_fill"; barElem setShader( "progress_bar_fill", width, height ); barElem.hidden = false; if ( isdefined( flashFrac ) ) { barElem.flashFrac = flashFrac; // barElem thread flashThread(); } barElemFrame = newClientHudElem( self ); barElemFrame.elemType = "icon"; barElemFrame.x = 0; barElemFrame.y = 0; barElemFrame.width = width; barElemFrame.height = height; barElemFrame.xOffset = 0; barElemFrame.yOffset = 0; barElemFrame.bar = barElem; barElemFrame.barFrame = barElemFrame; barElemFrame.children = []; barElemFrame.sort = -1; barElemFrame.color = (1,1,1); barElemFrame setParent( level.uiParent ); // barElemFrame setShader( "progress_bar_fg", width, height ); barElemFrame.hidden = false; barElemBG = newClientHudElem( self ); barElemBG.elemType = "bar"; if ( !level.splitScreen ) { barElemBG.x = -2; barElemBG.y = -2; } barElemBG.width = width; barElemBG.height = height; barElemBG.xOffset = 0; barElemBG.yOffset = 0; barElemBG.bar = barElem; barElemBG.barFrame = barElemFrame; barElemBG.children = []; barElemBG.sort = -3; barElemBG.color = (0,0,0); barElemBG.alpha = 0.5; barElemBG setParent( level.uiParent ); if ( !level.splitScreen ) barElemBG setShader( "progress_bar_bg", width + 4, height + 4 ); else barElemBG setShader( "progress_bar_bg", width + 0, height + 0 ); barElemBG.hidden = false; return barElemBG; } function getCurrentFraction() { frac = self.bar.frac; if (isdefined(self.bar.rateOfChange)) { frac += (getTime() - self.bar.lastUpdateTime) * self.bar.rateOfChange; if (frac > 1) frac = 1; if (frac < 0) frac = 0; } return frac; } function createPrimaryProgressBar() { bar = createBar( (1, 1, 1), level.primaryProgressBarWidth, level.primaryProgressBarHeight ); if ( level.splitScreen ) bar setPoint("TOP", undefined, level.primaryProgressBarX, level.primaryProgressBarY); else bar setPoint("CENTER", undefined, level.primaryProgressBarX, level.primaryProgressBarY); return bar; } function createPrimaryProgressBarText() { text = createFontString( "objective", level.primaryProgressBarFontSize ); if ( level.splitScreen ) text setPoint("TOP", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY); else text setPoint("CENTER", undefined, level.primaryProgressBarTextX, level.primaryProgressBarTextY); text.sort = -1; return text; } function createSecondaryProgressBar() { secondaryProgressBarHeight = GetDvarInt( "scr_secondaryProgressBarHeight", level.secondaryProgressBarHeight ); secondaryProgressBarX = GetDvarInt( "scr_secondaryProgressBarX", level.secondaryProgressBarX ); secondaryProgressBarY = GetDvarInt( "scr_secondaryProgressBarY", level.secondaryProgressBarY ); bar = createBar( (1, 1, 1), level.secondaryProgressBarWidth, secondaryProgressBarHeight ); if ( level.splitScreen ) bar setPoint("TOP", undefined, secondaryProgressBarX, secondaryProgressBarY); else bar setPoint("CENTER", undefined, secondaryProgressBarX, secondaryProgressBarY); return bar; } function createSecondaryProgressBarText() { secondaryProgressBarTextX = GetDvarInt( "scr_btx", level.secondaryProgressBarTextX ); secondaryProgressBarTextY = GetDvarInt( "scr_bty", level.secondaryProgressBarTextY ); text = createFontString( "objective", level.primaryProgressBarFontSize ); if ( level.splitScreen ) text setPoint("TOP", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY); else text setPoint("CENTER", undefined, secondaryProgressBarTextX, secondaryProgressBarTextY); text.sort = -1; return text; } function createTeamProgressBar( team ) { bar = createServerBar( (1,0,0), level.teamProgressBarWidth, level.teamProgressBarHeight, undefined, team ); bar setPoint("TOP", undefined, 0, level.teamProgressBarY); return bar; } function createTeamProgressBarText( team ) { text = createServerFontString( "default", level.teamProgressBarFontSize, team ); text setPoint("TOP", undefined, 0, level.teamProgressBarTextY); return text; } function setFlashFrac( flashFrac ) { self.bar.flashFrac = flashFrac; } function hideElem() { if ( self.hidden ) return; self.hidden = true; if ( self.alpha != 0 ) self.alpha = 0; if ( self.elemType == "bar" || self.elemType == "bar_shader" ) { self.bar.hidden = true; if ( self.bar.alpha != 0 ) self.bar.alpha = 0; self.barFrame.hidden = true; if ( self.barFrame.alpha != 0 ) self.barFrame.alpha = 0; } } function showElem() { if ( !self.hidden ) return; self.hidden = false; if ( self.elemType == "bar" || self.elemType == "bar_shader" ) { if ( self.alpha != .5 ) self.alpha = .5; self.bar.hidden = false; if ( self.bar.alpha != 1 ) self.bar.alpha = 1; self.barFrame.hidden = false; if ( self.barFrame.alpha != 1 ) self.barFrame.alpha = 1; } else { if ( self.alpha != 1 ) self.alpha = 1; } } function flashThread() { self endon ( "death" ); if ( !self.hidden ) self.alpha = 1; while(1) { if ( self.frac >= self.flashFrac ) { if ( !self.hidden ) { self fadeOverTime(0.3); self.alpha = .2; wait(0.35); self fadeOverTime(0.3); self.alpha = 1; } wait(0.7); } else { if ( !self.hidden && self.alpha != 1 ) self.alpha = 1; WAIT_SERVER_FRAME; } } } function destroyElem() { tempChildren = []; for ( index = 0; index < self.children.size; index++ ) { if ( isdefined( self.children[index] ) ) tempChildren[tempChildren.size] = self.children[index]; } for ( index = 0; index < tempChildren.size; index++ ) tempChildren[index] setParent( self getParent() ); if ( self.elemType == "bar" || self.elemType == "bar_shader" ) { self.bar destroy(); self.barFrame destroy(); } self destroy(); } function setIconShader( shader ) { self setShader( shader, self.width, self.height ); } function setWidth( width ) { self.width = width; } function setHeight( height ) { self.height = height; } function setSize( width, height ) { self.width = width; self.height = height; } function updateChildren() { for ( index = 0; index < self.children.size; index++ ) { child = self.children[index]; child setPoint( child.point, child.relativePoint, child.xOffset, child.yOffset ); } } function createLoadoutIcon( player, verIndex, horIndex, xpos, ypos ) { iconsize = 32; if ( player IsSplitscreen() ) { iconsize = 22; } ypos = ypos - (90 + iconsize * (3 - verIndex)); xpos = xpos - (10 + iconsize * horIndex); icon = createIcon( "white", iconsize, iconsize ); icon setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos ); icon.horzalign = "user_right"; icon.vertalign = "user_bottom"; icon.archived = false; icon.foreground = false; return icon; } function setLoadoutIconCoords( player, verIndex, horIndex, xpos, ypos ) { iconsize = 32; if ( player IsSplitscreen() ) { iconsize = 22; } ypos = ypos - (90 + iconsize * (3 - verIndex)); xpos = xpos - (10 + iconsize * horIndex); self setPoint( "BOTTOM RIGHT", "BOTTOM RIGHT", xpos, ypos ); self.horzalign = "user_right"; self.vertalign = "user_bottom"; self.archived = false; self.foreground = false; self.alpha = 1; } function setLoadoutTextCoords( xCoord) { self setPoint( "RIGHT", "LEFT", xCoord, 0 ); } function createLoadoutText( icon, xCoord ) { text = createFontString( "small", 1 ); text setParent( icon ); text setPoint( "RIGHT", "LEFT", xCoord, 0 ); text.archived = false; text.alignX = "right"; text.alignY = "middle"; text.foreground = false; return text; } function showLoadoutAttribute( iconElem, icon, alpha, textElem, text ) { iconsize = 32; iconElem.alpha = alpha; if ( alpha ) iconElem setShader( icon, iconsize, iconsize ); if ( isdefined( textElem ) ) { textElem.alpha = alpha; if ( alpha ) textElem setText( text ); } } function hideLoadoutAttribute( iconElem, fadeTime, textElem, hideTextOnly ) { if ( isdefined( fadeTime ) ) { if ( !isdefined( hideTextOnly ) || !hideTextOnly ) { iconElem fadeOverTime( fadeTime ); } if ( isdefined( textElem ) ) { textElem fadeOverTime( fadeTime ); } } if ( !isdefined( hideTextOnly ) || !hideTextOnly ) iconElem.alpha = 0; if ( isdefined( textElem ) ) textElem.alpha = 0; } function showPerks( ) { self LUINotifyEvent( &"show_perk_notification", 0 ); } function showPerk( index, perk, ypos ) { // don't want the hud elements when the game is over assert( game["state"] != "postgame" ); if ( !isdefined( self.perkicon ) ) { self.perkicon = []; self.perkname = []; } if ( !isdefined( self.perkicon[ index ] ) ) { assert( !isdefined( self.perkname[ index ] ) ); self.perkicon[ index ] = createLoadoutIcon( self, index, 0, 200, ypos ); self.perkname[ index ] = createLoadoutText( self.perkicon[ index ], 160 ); } else { self.perkicon[ index ] setLoadoutIconCoords( self, index, 0, 200, ypos ); self.perkname[ index ] setLoadoutTextCoords( 160 ); } if ( perk == "perk_null" || perk == "weapon_null" || perk == "specialty_null" ) { alpha = 0; } else { assert( isdefined( level.perkNames[ perk ] ), perk ); alpha = 1; } showLoadoutAttribute( self.perkicon[ index ], perk, alpha, self.perkname[ index ], level.perkNames[ perk ] ); self.perkicon[ index ] moveOverTime( 0.3 ); self.perkicon[ index ].x = -5; self.perkicon[ index ].hidewheninmenu = true; self.perkname[ index ] moveOverTime( 0.3 ); self.perkname[ index ].x = -40; self.perkname[ index ].hidewheninmenu = true; } function hidePerk( index, fadeTime, hideTextOnly ) { if ( !isdefined (fadeTime ) ) fadeTime = 0.05; if ( level.perksEnabled == 1) { if ( game["state"] == "postgame" ) { // If there has been no regualr killcams (hardcore) before the final killcam // perkicon will not be set up and will fail this assert ) if ( isdefined( self.perkicon ) ) { // perk icons should have been deleted in globallogic_ui::freeGameplayHudElems() assert( !isdefined( self.perkicon[ index ] ) ); assert( !isdefined( self.perkname[ index ] ) ); } return; } assert( isdefined( self.perkicon[ index ] ) ); assert( isdefined( self.perkname[ index ] ) ); if ( isdefined( self.perkicon ) && isdefined( self.perkicon[ index ] ) && isdefined( self.perkname ) && isdefined( self.perkname[ index ] ) ) { hideLoadoutAttribute( self.perkicon[ index ], fadeTime, self.perkname[ index ], hideTextOnly ); } } } function showKillstreak( index, killstreak, xpos, ypos ) { // don't want the hud elements when the game is over assert( game["state"] != "postgame" ); if ( !isdefined( self.killstreakIcon ) ) self.killstreakIcon = []; if ( !isdefined( self.killstreakIcon[ index ] ) ) { // Since the perks are being displayed before the killstreaks, we use 3 as our vertical index. // This might have to be changed/modified if we add some other details as part of the loadout // self.killstreak.size - 1 - index would be the horizontal index since we want to display the killstreaks from left to right self.killstreakIcon[ index ] = createLoadoutIcon( self, 3, self.killstreak.size - 1 - index, xpos, ypos ); } if ( killstreak == "killstreak_null" || killstreak == "weapon_null" ) { alpha = 0; } else { assert( isdefined( level.killstreakIcons[ killstreak ] ), killstreak ); alpha = 1; } showLoadoutAttribute( self.killstreakIcon[ index ], level.killstreakIcons[ killstreak ], alpha ); } function hideKillstreak( index, fadetime ) { if ( util::is_killstreaks_enabled() ) { if ( game["state"] == "postgame" ) { // killstreak icons should have been deleted in globallogic_ui::freeGameplayHudElems() assert( !isdefined( self.killstreakIcon[ index ] ) ); return; } assert( isdefined( self.killstreakIcon[ index ] ) ); hideLoadoutAttribute( self.killstreakIcon[ index ], fadetime ); } } function setGamemodeInfoPoint() { self.x = 11; self.y = 120; self.horzAlign = "user_left"; self.vertAlign = "user_top"; self.alignX = "left"; self.alignY = "top"; } [/PHP] anyways we made this [PHP] SetShader(align, relative, x, y, width, height, colour, shader, sort, alpha) { Shader = newClientHudElem(self); Shader.elemtype = "icon"; Shader.color = colour; Shader.alpha = alpha; Shader.sort = sort; Shader.children = []; Shader hud::setParent(level.uiParent); Shader setShader(shader, width, height); Shader hud::setPoint(align, relative, x, y); return Shader; }[/PHP] [/SPOILER] If i should continue reply to this thread [/QUOTE]
Verification
Post reply
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 3
Call of Duty: Black Ops 3 Mods and Scripts
Call of Duty: Black Ops 3 Scripts
Lets Make A Menu!
CabConModding is now on facebook! Check the latest Updates, the Site Status and much more now!
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