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
Call of Duty: Black Ops 3 Scripts Question
Having problems with hud elements
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="eatdatpussy445" data-source="post: 23024" data-attributes="member: 75352"><p>So I'm really confused as to why no text shows. I don't even know if I used spawnstruct like it's suppose to be used. So I would be really happy if someone could help me out here and maybe explain what i did wrong. I haven't been working with gsc for a long time so yeah... </p><p>[code]</p><p>#using scripts\codescripts\struct;</p><p>#using scripts\shared\system_shared;</p><p>#using scripts\shared\callbacks_shared;</p><p>#using scripts\shared\hud_util_shared;</p><p>#using scripts\shared\util_shared;</p><p></p><p>#insert scripts\shared\shared.gsh;</p><p>#namespace clientids;</p><p></p><p>REGISTER_SYSTEM( "clientids", &__init__, undefined )</p><p>function __init__()</p><p>{</p><p> callback::on_start_gametype( &init );</p><p> callback::on_connect( &connect );</p><p> callback::on_disconnect( &disconnect );</p><p>}</p><p></p><p>//this is based on cwxh's menu base</p><p></p><p>function init()</p><p>{</p><p> level.name = "level";</p><p> level.astra = spawnstruct();</p><p> addcolor("black", (0, 0, 0));</p><p> addcolor("white", (1, 1, 1));</p><p> addcolor("red", (1, 0, 0));</p><p> addcolor("yellow", (1, 1, 0));</p><p> addcolor("green", (0, 1, 0));</p><p> addcolor("blue", (0,0, 1));</p><p> addcolor("purple", (1, 0, 1));</p><p> addcolor("cyan", (0, 1, 1));</p><p> addcolor("gray", (0.5, 0.5, 0.5));</p><p> addcolor("orange", (0.95, 0.52, 0.0285));</p><p> addtheme("Surge", "orange", "black");</p><p> addtheme("Cherry", "red", "white");</p><p> addtheme("Poison", "green", "black");</p><p> addtheme("Death Star", "cyan", "black");</p><p> addtheme("Obsidian", "purple", "black");</p><p> addtheme("NextGenUpdate", "cyan", "gray");</p><p> addtheme("Se7enSins", "green", "gray");</p><p>}</p><p>function disconnect(){}</p><p>function connect()</p><p>{</p><p> self setaccess(Iif(self ishost(), 3, 0));</p><p> self waittill("spawned_player");</p><p> self initastra();</p><p>}</p><p>function initastra()</p><p>{</p><p> self.astra = spawnstruct();</p><p> self.astra.locked = false;</p><p> self.astra.active = false;</p><p> self FreezeControls(false);</p><p> </p><p> setcolor("panel", "black");</p><p> setcolor("glow", "orange");</p><p> setcolor("title", "orange");</p><p> setcolor("options", "white");</p><p> setcolor("scrollbar", "orange");</p><p> setcolor("background", "black");</p><p> self.astra.menu.current = "Astra";</p><p> self initvars();</p><p> self initmenu();</p><p> self thread monitor();</p><p> self thread inithud();</p><p>}</p><p>function initvars()</p><p>{</p><p> addvar("god", 0);</p><p> addvar("ammo", 0);</p><p>}</p><p></p><p></p><p>//ressource/function.gsc</p><p>//functions</p><p>function test()</p><p>{</p><p> self iprintln("hello bois");</p><p>}</p><p></p><p>//ressource/hud.gsc</p><p>//hud</p><p>function inithud()</p><p>{</p><p> self drawtext();</p><p> self drawshaders();</p><p> self.astra.hud.drawn = true;</p><p>}</p><p>function drawtext()</p><p>{</p><p> self notify("redraw");</p><p> colors = self.astra.colors;</p><p> self.astra.hud.text = spawnstruct();</p><p> </p><p> self.astra.hud.text.title = self createText("RIGHT", "TOP", 0, 50, "bigfixed", 1, 7, colors["title"], 0, "");</p><p> self.astra.hud.text.title thread destroyOnAny("disconnect", "menu_exit", "redraw", "dunno");</p><p> self.astra.hud.text.options = [];</p><p> </p><p> for(i = 0; i < 15; i++)</p><p> {</p><p> self.astra.hud.text.options[i] = self createText("RIGHT", "TOP", -540, 50 + (2 * 25) + (25 * i), "objective", 1.4, 7, colors["options"], 0, "");</p><p> self.astra.hud.text.options[i] thread destroyOnAny("disconnect", "menu_exit", "redraw", "dunno");</p><p> }</p><p>}</p><p>function drawshaders()</p><p>{</p><p> colors = self.astra.colors;</p><p> self.astra.hud.shaders = spawnstruct();</p><p> </p><p> self.astra.hud.shaders.background = self createRectangle("LEFT", "CENTER", 0, 0, 0, 500, 2, colors["background"], 0, "white");</p><p> self.astra.hud.shaders.scrollbar = self createRectangle("RIGHT", "TOP", 0, 50 + (2 * 25), 6, 25, 9, colors["scrollbar"], 0, "white");</p><p> self.astra.hud.shaders.shadow = self createRectangle("RIGHT", "CENTER", 0, 0, 5, 500, 3, colors["panel"], 0, "white");</p><p> self.astra.hud.shaders.header = self createRectangle("RIGHT", "TOP", -5, 50, 500, 40, 5, colors["panel"], 0, "white");</p><p> self.astra.hud.shaders.panel = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 2, colors["panel"], 0, "white");</p><p> self.astra.hud.shaders.glow = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 1, colors["glow"], 0, "white");</p><p>}</p><p>function updatetext(offset)</p><p>{</p><p> menu = self getmenu();</p><p> if(!isDefined(offset))</p><p> offset = menu.position - menu.textindex;</p><p> </p><p> for(i = 0; i < 15; i++)</p><p> {</p><p> self.astra.hud.text.options[i] setText(menu.options[offset].label);</p><p> offset++;</p><p> }</p><p>}</p><p>function updatehud()</p><p>{</p><p> self.astra.hud.text.title setText(self getMenu()["label"]);</p><p> self updatetext();</p><p>}</p><p>function showhud()</p><p>{</p><p> self.astra.hud.shaders.header elemFade(0.1, 0.65);</p><p> self.astra.hud.shaders.panel elemFade(0.1, 0.5);</p><p> self.astra.hud.shaders.panel scaleOverTime(0.25, 540, 500);</p><p> self.astra.hud.shaders.background elemFade(0.1, 0.5);</p><p> self.astra.hud.shaders.background scaleOverTime(0.25, 540, 500);</p><p> self.astra.hud.shaders.shadow elemFade(0.25, 0.5);</p><p> self.astra.hud.shaders.glow elemFade(0.1, 0.5);</p><p> self.astra.hud.shaders.glow scaleOverTime(0.25, 1000, 500);</p><p> self.astra.hud.shaders.glow thread pulseEffect(0.4, 0.5, 2);</p><p> self updatehud();</p><p> self menutransin();</p><p> </p><p> self updatescrollbar();</p><p> self.astra.hud.shaders.scrollbar elemFade(0.25, 1);</p><p>}</p><p>function hidehud()</p><p>{</p><p> self.astra.hud.shaders.header elemFade(0.1, 0);</p><p> self.astra.hud.text.title elemFade(0.1, 0);</p><p> for(i = 0; i < self.astra.hud.text.options.size; i++)</p><p> {</p><p> self.astra.hud.text.options[i] thread elemMoveX(0.25, 0);</p><p> self.astra.hud.text.options[i] elemFade(0.25, 0);</p><p> }</p><p> </p><p> self.astra.hud.shaders.glow notify("pulse_end");</p><p> self.astra.hud.shaders.glow elemFade(0.4, 0);</p><p> self.astra.hud.shaders.glow scaleOverTime(0.25, 1, 500);</p><p> self.astra.hud.shaders.shadow elemFade(0.4, 0);</p><p> self.astra.hud.shaders.background elemFade(0.4, 0);</p><p> self.astra.hud.shaders.background scaleOverTime(0.25, 1, 500);</p><p> self.astra.hud.shaders.panel elemFade(0.4, 0);</p><p> self.astra.hud.shaders.panel scaleOverTime(0.25, 1, 500);</p><p> self.astra.hud.shaders.scrollbar.alpha = 0;</p><p>}</p><p>function updatescrollbar()</p><p>{</p><p> self.astra.hud.shaders.scrollbar elemMoveY(0.15, self.astra.hud.text.options[self getmenu().textindex].y);</p><p>}</p><p>function menutransin()</p><p>{</p><p> self.astra.hud.text.title.x = 0;</p><p> self.astra.hud.text.title thread elemMoveX(0.25, -10);</p><p> self.astra.hud.text.title elemFade(0.25, 1);</p><p> for(i = 0; i < 15; i++)</p><p> {</p><p> self.astra.hud.text.options[i].x = -540;</p><p> self.astra.hud.text.options[i] thread elemMoveX(0.25, -10);</p><p> self.astra.hud.text.options[i] elemFade(0.25, 0.5);</p><p> }</p><p> self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 5, 25);</p><p> self thread scrollbareffect();</p><p>}</p><p>function menutransout()</p><p>{</p><p> self.astra.hud.text.title thread elemMoveX(0.25, 0);</p><p> self.astra.hud.text.title elemFade(0.25, 0);</p><p> </p><p> for(i = 0; i < self.astra.hud.text.options.size; i++)</p><p> {</p><p> self.astra.hud.text.options[i] thread elemMoveX(0.25, 0);</p><p> self.astra.hud.text.options[i] elemFade(0.25, 0);</p><p> }</p><p> self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 540, 25);</p><p>}</p><p></p><p>//ressource/hud_util.gsc</p><p>//hud util</p><p>function createrectangle(align, relative, x, y, width, height, sort, color, alpha, shader)</p><p>{</p><p> elem = newClientHudElem(self);</p><p> elem.elemType = "bar";</p><p> elem.sort = sort;</p><p> elem.color = color;</p><p> elem.alpha = alpha;</p><p> elem hud::setParent(level.uiParent);</p><p> elem setShader(shader, width, height);</p><p> elem.hideWhenInMenu = true;</p><p> elem hud::setPoint(align, relative, x, y);</p><p> elem.type = "shader";</p><p> elem.owner = self;</p><p> return elem;</p><p>}</p><p>function createtext(align, relative, x, y, font, fontscale, sort, color, alpha, text)</p><p>{</p><p> elem = self hud::CreateFontString(font, fontscale);</p><p> elem hud::setPoint(align, relative, x, y);</p><p> elem.sort = sort;</p><p> elem.alpha = alpha;</p><p> elem.hideWhenInMenu = true;</p><p> elem setText(text);</p><p> elem.type = "text";</p><p> elem.color = color;</p><p> elem.owner = self;</p><p> return elem;</p><p>}</p><p>function elemMoveX(time, x)</p><p>{</p><p> self moveovertime(time);</p><p> self.x = x;</p><p>}</p><p>function elemMoveY(time, y)</p><p>{</p><p> self moveovertime(time);</p><p> self.y = y;</p><p>}</p><p>function elemFade(time, alpha)</p><p>{</p><p> self fadeovertime(time);</p><p> self.alpha = alpha;</p><p>}</p><p>function pulse(state)</p><p>{</p><p> if(state == true)</p><p> self thread pulseeffect(0.5, 1, 0.5);</p><p> else</p><p> self notify("pulse_end");</p><p> self.pulsing = state;</p><p>}</p><p>function pulseeffect(min, max, time)</p><p>{</p><p> self endon("pulse_end");</p><p> for(;;)</p><p> {</p><p> self elemFade(time, max);</p><p> wait time;</p><p> self elemFade(time, min);</p><p> wait time;</p><p> }</p><p>}</p><p>function scrollbareffect()</p><p>{</p><p> for(i = 0; i < self.astra.hud.text.options.size; i++)</p><p> {</p><p> if(i == self getmenu().textindex)</p><p> self.astra.hud.text.options[i] elemFade(0.25, 1);</p><p> else</p><p> self.astra.hud.text.options[i] elemFade(0.25, 0.5);</p><p> }</p><p>}</p><p>function destroyOnAny(event1, event2, event3, event4, event5, event6)</p><p>{</p><p> self.owner util::waittill_any(event1, event2, event3, event4, event5, event6);</p><p> self destroy();</p><p>}</p><p></p><p>//ressource/menu.gsc</p><p>//menu</p><p>function initmenu()</p><p>{</p><p> main = "Astra";</p><p> self.astra.menu = [];</p><p> </p><p> self.astra.menu.current = main;</p><p> self addmenu(undefined, main);</p><p> </p><p> for(i = 0; i < 17; i++)</p><p> {</p><p> self addmenu(main, "Submenu " + (i + 1));</p><p> for(n = 0; n < 19; n++)</p><p> self addoption("Submenu " + (i + 1), "Option " + (n + 1), &test);</p><p> }</p><p>}</p><p></p><p>//ressource/misc.gsc</p><p>//misc</p><p>function Iif(bool, val1, val2)</p><p>{</p><p> if(bool)</p><p> return val1;</p><p> return val2;</p><p>}</p><p>function isallowed(n = 1)</p><p>{</p><p> return self getAccess() >= n;</p><p>}</p><p>function empty(x)</p><p>{</p><p> if(!isDefined(x) || x == "")</p><p> return true;</p><p> return false;</p><p>}</p><p>//add</p><p>function addcolor(name, color)</p><p>{</p><p> level.astra.colors[name] = color;</p><p>}</p><p>function addsetting(name, value)</p><p>{</p><p> level.astra.settings[name] = value;</p><p>}</p><p>function addvar(name, value)</p><p>{</p><p> self.astra.vars[name] = value;</p><p>}</p><p>function addtheme(name, primary, secondary)</p><p>{</p><p> level.astra.themes[name] = spawnstruct();</p><p> level.astra.themes[name].primary = level.astra.colors[primary];</p><p> level.astra.themes[name].secondary = level.astra.colors[secondary];</p><p>}</p><p>//set</p><p>function setcolor(elem, name)</p><p>{</p><p> self.astra.colors[elem] = level.astra.colors[name];</p><p>}</p><p>function setaccess(n)</p><p>{</p><p> self.astra.access = n;</p><p>}</p><p>function setsetting(name, value)</p><p>{</p><p> level.astra.settings[name] = value;</p><p>}</p><p>function setvar(name, value)</p><p>{</p><p> self.astra.vars[name] = value;</p><p>}</p><p>//get</p><p>function getsetting(name)</p><p>{</p><p> return level.astra.settings[name];</p><p>}</p><p>function getvar(name)</p><p>{</p><p> return self.astra.vars[name];</p><p>}</p><p>function getaccess()</p><p>{</p><p> return Iif(empty(self.astra.access), 0, self.astra.access);</p><p>}</p><p>function getmenu()</p><p>{</p><p> return self.astra.menu[self getcurrentmenu()];</p><p>}</p><p>function getcurrentmenu()</p><p>{</p><p> return self.astra.menu.current;</p><p>}</p><p></p><p>//ressource/monitoring.gsc</p><p>//controls</p><p>function monitor()</p><p>{</p><p> self endon("dunno");</p><p> for(;;)</p><p> {</p><p> while(isAlive(self))</p><p> {</p><p> if(!self.astra.locked)</p><p> {</p><p> if(!self.astra.active)</p><p> {</p><p> //open</p><p> if(self ActionSlotOneButtonPressed())</p><p> self openmenu();</p><p> //exit level (for testing)</p><p> if(self ActionSlotFourButtonPressed())</p><p> ExitLevel();</p><p> }</p><p> else</p><p> {</p><p> //go back/exit menu</p><p> if(self ActionSlotTwoButtonPressed() || self UseButtonPressed())</p><p> {</p><p> if(self ActionSlotTwoButtonPressed() || empty(self getmenu().parent))</p><p> self closemenu();</p><p> else</p><p> self submenu(self getmenu().parent);</p><p> wait 0.2;</p><p> </p><p> }</p><p> //scroll</p><p> if(self AttackButtonPressed() || self AdsButtonPressed())</p><p> {</p><p> scroll(Iif(self AttackButtonPressed(), -1, 1));</p><p> wait 0.2;</p><p> }</p><p> </p><p> //select</p><p> if(self JumpButtonPressed())</p><p> {</p><p> self select();</p><p> wait 0.2;</p><p> }</p><p> }</p><p> }</p><p> wait 0.05;</p><p> }</p><p> self waittill("spawned_player");</p><p> }</p><p>}</p><p>//select</p><p>function select()</p><p>{</p><p> selected = self getmenu().options[self getmenu().position];</p><p> //so you dont have to re-enter name of the submenu -> addOption("SubMenu 1", "SubMenu 1.1", &submenu);</p><p> if(selected.func == &submenu && empty(selected.input))</p><p> selected.input = selected.label;</p><p> //prevent text from moving if the option is "submenu" / move text if option is submenu but menu doesnt exist</p><p> if(selected.func != &submenu || (selected.func == &submenu && empty(self.astra.menu[selected.input])))</p><p> {</p><p> elem = self.astra.hud.text.options[self getmenu().textindex];</p><p> elem elemMoveX(0.07, elem.x - 5);</p><p> wait 0.25;</p><p> elem thread elemMoveX(0.07, -10);</p><p> }</p><p> //if submenu doesnt exist</p><p> if(selected.func == &submenu && empty(self.astra.menu[selected.input]))</p><p> {</p><p> self iprintln("^1ERROR: ^3Cannot enter submenu: submenu does not exist");</p><p> return;</p><p> }</p><p> //thread function</p><p> if(selected.type == "thread")</p><p> {</p><p> if(empty(selected.input))</p><p> selected.entity thread [[selected.func]]();</p><p> else if(isArray(selected.input))</p><p> {</p><p> if(selected.input.size == 0)</p><p> self iprintln("^1ERROR: ^3Cannot call function: no arguments passed");</p><p> else if(selected.input.size == 1)</p><p> selected.entity thread [[selected.func]](selected.input[0]);</p><p> else if(selected.input.size == 2)</p><p> selected.entity thread [[selected.func]](selected.input[0], selected.input[1]);</p><p> else if(selected.input.size == 3)</p><p> selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2]);</p><p> else if(selected.input.size == 4)</p><p> selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3]);</p><p> else if(selected.input.size == 5)</p><p> selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3], selected.input[4]);</p><p> else</p><p> self iprintln("^1ERROR: ^3Cannot call function: too many arguments passed");</p><p> }</p><p> else</p><p> selected.entity thread [[selected.func]](selected.input);</p><p> }</p><p> </p><p> //call function immediately</p><p> else if(selected.type == "immediate")</p><p> {</p><p> if(empty(selected.input))</p><p> selected.entity [[selected.func]]();</p><p> else if(isArray(selected.input))</p><p> selected.entity [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3], selected.input[4]);</p><p> else</p><p> selected.entity [[selected.func]](selected.input);</p><p> }</p><p> //tell player that func was called on ent</p><p> if(selected.entity != self)</p><p> self iPrintln(selected.label + " was called on " + selected.entity.name);</p><p>}</p><p>//scroll</p><p>function scroll(amount)</p><p>{</p><p> menu = self getmenu();</p><p> options = menu.options;</p><p> position = menu.position + amount;</p><p> lastindex = menu.lastindex;</p><p> textindex = menu.textindex;</p><p> if(position < 0)</p><p> {</p><p> position = options.size - 1;</p><p> textindex = lastindex;</p><p> self updateText(position - textindex);</p><p> }</p><p> else if(position >= options.size)</p><p> {</p><p> position = 0;</p><p> textindex = 0;</p><p> self updateText(position - textindex);</p><p> }</p><p> else if(textindex != 0 && textindex != lastindex)</p><p> textindex += amount;</p><p> else</p><p> self updateText(position - textindex);</p><p> </p><p> self.astra.menu[menu.label].textindex = textindex;</p><p> self.astra.menu[menu.label].position = position;</p><p>}</p><p></p><p>//ressource/util.gsc</p><p>//menu util</p><p>function addmenu(parent, name)</p><p>{</p><p> self.astra.menu[name] = spawnstruct();</p><p> self.astra.menu[name].options = [];</p><p> self.astra.menu[name].parent = parent;</p><p> self.astra.menu[name].label = name;</p><p> self.astra.menu[name].position = 0;</p><p> self.astra.menu[name].textindex = 0;</p><p> self.astra.menu[name].lastindex = 0;</p><p> if(!empty(parent))</p><p> self addoption(parent, name, &submenu);</p><p>}</p><p>function addoption(menu, label, func, input, type = "thread", entity = self)</p><p>{</p><p> index = self.astra.menu[menu].options.size;</p><p> self.astra.menu[menu].options[index] = spawnstruct();</p><p> self.astra.menu[menu].options[index].label = label;</p><p> self.astra.menu[menu].options[index].func = func;</p><p> self.astra.menu[menu].options[index].input = input;</p><p> self.astra.menu[menu].options[index].type = type;</p><p> self.astra.menu[menu].options[index].entity = entity;</p><p> if(index < 15)</p><p> self.astra.menu[menu].lastindex = index;</p><p>}</p><p>function openmenu()</p><p>{</p><p> self FreezeControls(false);</p><p> self EnableInvulnerability();</p><p> self SetClientUIVisibilityFlag("hud_visible", 0);</p><p> self showHud();</p><p> self.astra.active = true;</p><p>}</p><p>function closemenu()</p><p>{</p><p> self hideHud();</p><p> wait 0.15;</p><p> </p><p> self notify("menu_exit");</p><p> self SetClientUIVisibilityFlag("hud_visible", 1);</p><p> self.astra.active = false;</p><p> if(!getvar("god"))</p><p> self DisableInvulnerability();</p><p>}</p><p>function submenu(input)</p><p>{</p><p> if(!empty(self.astra.menu[input]))</p><p> {</p><p> if(!self.astra.active)</p><p> {</p><p> if(self getaccess() > 0)</p><p> {</p><p> self menutransout();</p><p> wait 0.25;</p><p> self.astra.menu.current = input;</p><p> self updatehud();</p><p> self.astra.hud.shaders.glow notify("pulse_end");</p><p> self.astra.hud.shaders.glow thread pulseEffect(0.4, 0.5, 2);</p><p> self updatescrollbar();</p><p> self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 5, 25);</p><p> }</p><p> else</p><p> self iPrintln("^1You do not have permission to enter this menu");</p><p> }</p><p> else</p><p> self iPrintln("^1ERROR: ^3Cannot enter submenu: menu is closing");</p><p> }</p><p> else</p><p> self iPrintln("^1ERROR: ^3Cannot enter submenu: menu does not exist");</p><p>}</p><p>[/code]</p></blockquote><p></p>
[QUOTE="eatdatpussy445, post: 23024, member: 75352"] So I'm really confused as to why no text shows. I don't even know if I used spawnstruct like it's suppose to be used. So I would be really happy if someone could help me out here and maybe explain what i did wrong. I haven't been working with gsc for a long time so yeah... [code] #using scripts\codescripts\struct; #using scripts\shared\system_shared; #using scripts\shared\callbacks_shared; #using scripts\shared\hud_util_shared; #using scripts\shared\util_shared; #insert scripts\shared\shared.gsh; #namespace clientids; REGISTER_SYSTEM( "clientids", &__init__, undefined ) function __init__() { callback::on_start_gametype( &init ); callback::on_connect( &connect ); callback::on_disconnect( &disconnect ); } //this is based on cwxh's menu base function init() { level.name = "level"; level.astra = spawnstruct(); addcolor("black", (0, 0, 0)); addcolor("white", (1, 1, 1)); addcolor("red", (1, 0, 0)); addcolor("yellow", (1, 1, 0)); addcolor("green", (0, 1, 0)); addcolor("blue", (0,0, 1)); addcolor("purple", (1, 0, 1)); addcolor("cyan", (0, 1, 1)); addcolor("gray", (0.5, 0.5, 0.5)); addcolor("orange", (0.95, 0.52, 0.0285)); addtheme("Surge", "orange", "black"); addtheme("Cherry", "red", "white"); addtheme("Poison", "green", "black"); addtheme("Death Star", "cyan", "black"); addtheme("Obsidian", "purple", "black"); addtheme("NextGenUpdate", "cyan", "gray"); addtheme("Se7enSins", "green", "gray"); } function disconnect(){} function connect() { self setaccess(Iif(self ishost(), 3, 0)); self waittill("spawned_player"); self initastra(); } function initastra() { self.astra = spawnstruct(); self.astra.locked = false; self.astra.active = false; self FreezeControls(false); setcolor("panel", "black"); setcolor("glow", "orange"); setcolor("title", "orange"); setcolor("options", "white"); setcolor("scrollbar", "orange"); setcolor("background", "black"); self.astra.menu.current = "Astra"; self initvars(); self initmenu(); self thread monitor(); self thread inithud(); } function initvars() { addvar("god", 0); addvar("ammo", 0); } //ressource/function.gsc //functions function test() { self iprintln("hello bois"); } //ressource/hud.gsc //hud function inithud() { self drawtext(); self drawshaders(); self.astra.hud.drawn = true; } function drawtext() { self notify("redraw"); colors = self.astra.colors; self.astra.hud.text = spawnstruct(); self.astra.hud.text.title = self createText("RIGHT", "TOP", 0, 50, "bigfixed", 1, 7, colors["title"], 0, ""); self.astra.hud.text.title thread destroyOnAny("disconnect", "menu_exit", "redraw", "dunno"); self.astra.hud.text.options = []; for(i = 0; i < 15; i++) { self.astra.hud.text.options[i] = self createText("RIGHT", "TOP", -540, 50 + (2 * 25) + (25 * i), "objective", 1.4, 7, colors["options"], 0, ""); self.astra.hud.text.options[i] thread destroyOnAny("disconnect", "menu_exit", "redraw", "dunno"); } } function drawshaders() { colors = self.astra.colors; self.astra.hud.shaders = spawnstruct(); self.astra.hud.shaders.background = self createRectangle("LEFT", "CENTER", 0, 0, 0, 500, 2, colors["background"], 0, "white"); self.astra.hud.shaders.scrollbar = self createRectangle("RIGHT", "TOP", 0, 50 + (2 * 25), 6, 25, 9, colors["scrollbar"], 0, "white"); self.astra.hud.shaders.shadow = self createRectangle("RIGHT", "CENTER", 0, 0, 5, 500, 3, colors["panel"], 0, "white"); self.astra.hud.shaders.header = self createRectangle("RIGHT", "TOP", -5, 50, 500, 40, 5, colors["panel"], 0, "white"); self.astra.hud.shaders.panel = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 2, colors["panel"], 0, "white"); self.astra.hud.shaders.glow = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 1, colors["glow"], 0, "white"); } function updatetext(offset) { menu = self getmenu(); if(!isDefined(offset)) offset = menu.position - menu.textindex; for(i = 0; i < 15; i++) { self.astra.hud.text.options[i] setText(menu.options[offset].label); offset++; } } function updatehud() { self.astra.hud.text.title setText(self getMenu()["label"]); self updatetext(); } function showhud() { self.astra.hud.shaders.header elemFade(0.1, 0.65); self.astra.hud.shaders.panel elemFade(0.1, 0.5); self.astra.hud.shaders.panel scaleOverTime(0.25, 540, 500); self.astra.hud.shaders.background elemFade(0.1, 0.5); self.astra.hud.shaders.background scaleOverTime(0.25, 540, 500); self.astra.hud.shaders.shadow elemFade(0.25, 0.5); self.astra.hud.shaders.glow elemFade(0.1, 0.5); self.astra.hud.shaders.glow scaleOverTime(0.25, 1000, 500); self.astra.hud.shaders.glow thread pulseEffect(0.4, 0.5, 2); self updatehud(); self menutransin(); self updatescrollbar(); self.astra.hud.shaders.scrollbar elemFade(0.25, 1); } function hidehud() { self.astra.hud.shaders.header elemFade(0.1, 0); self.astra.hud.text.title elemFade(0.1, 0); for(i = 0; i < self.astra.hud.text.options.size; i++) { self.astra.hud.text.options[i] thread elemMoveX(0.25, 0); self.astra.hud.text.options[i] elemFade(0.25, 0); } self.astra.hud.shaders.glow notify("pulse_end"); self.astra.hud.shaders.glow elemFade(0.4, 0); self.astra.hud.shaders.glow scaleOverTime(0.25, 1, 500); self.astra.hud.shaders.shadow elemFade(0.4, 0); self.astra.hud.shaders.background elemFade(0.4, 0); self.astra.hud.shaders.background scaleOverTime(0.25, 1, 500); self.astra.hud.shaders.panel elemFade(0.4, 0); self.astra.hud.shaders.panel scaleOverTime(0.25, 1, 500); self.astra.hud.shaders.scrollbar.alpha = 0; } function updatescrollbar() { self.astra.hud.shaders.scrollbar elemMoveY(0.15, self.astra.hud.text.options[self getmenu().textindex].y); } function menutransin() { self.astra.hud.text.title.x = 0; self.astra.hud.text.title thread elemMoveX(0.25, -10); self.astra.hud.text.title elemFade(0.25, 1); for(i = 0; i < 15; i++) { self.astra.hud.text.options[i].x = -540; self.astra.hud.text.options[i] thread elemMoveX(0.25, -10); self.astra.hud.text.options[i] elemFade(0.25, 0.5); } self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 5, 25); self thread scrollbareffect(); } function menutransout() { self.astra.hud.text.title thread elemMoveX(0.25, 0); self.astra.hud.text.title elemFade(0.25, 0); for(i = 0; i < self.astra.hud.text.options.size; i++) { self.astra.hud.text.options[i] thread elemMoveX(0.25, 0); self.astra.hud.text.options[i] elemFade(0.25, 0); } self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 540, 25); } //ressource/hud_util.gsc //hud util function createrectangle(align, relative, x, y, width, height, sort, color, alpha, shader) { elem = newClientHudElem(self); elem.elemType = "bar"; elem.sort = sort; elem.color = color; elem.alpha = alpha; elem hud::setParent(level.uiParent); elem setShader(shader, width, height); elem.hideWhenInMenu = true; elem hud::setPoint(align, relative, x, y); elem.type = "shader"; elem.owner = self; return elem; } function createtext(align, relative, x, y, font, fontscale, sort, color, alpha, text) { elem = self hud::CreateFontString(font, fontscale); elem hud::setPoint(align, relative, x, y); elem.sort = sort; elem.alpha = alpha; elem.hideWhenInMenu = true; elem setText(text); elem.type = "text"; elem.color = color; elem.owner = self; return elem; } function elemMoveX(time, x) { self moveovertime(time); self.x = x; } function elemMoveY(time, y) { self moveovertime(time); self.y = y; } function elemFade(time, alpha) { self fadeovertime(time); self.alpha = alpha; } function pulse(state) { if(state == true) self thread pulseeffect(0.5, 1, 0.5); else self notify("pulse_end"); self.pulsing = state; } function pulseeffect(min, max, time) { self endon("pulse_end"); for(;;) { self elemFade(time, max); wait time; self elemFade(time, min); wait time; } } function scrollbareffect() { for(i = 0; i < self.astra.hud.text.options.size; i++) { if(i == self getmenu().textindex) self.astra.hud.text.options[i] elemFade(0.25, 1); else self.astra.hud.text.options[i] elemFade(0.25, 0.5); } } function destroyOnAny(event1, event2, event3, event4, event5, event6) { self.owner util::waittill_any(event1, event2, event3, event4, event5, event6); self destroy(); } //ressource/menu.gsc //menu function initmenu() { main = "Astra"; self.astra.menu = []; self.astra.menu.current = main; self addmenu(undefined, main); for(i = 0; i < 17; i++) { self addmenu(main, "Submenu " + (i + 1)); for(n = 0; n < 19; n++) self addoption("Submenu " + (i + 1), "Option " + (n + 1), &test); } } //ressource/misc.gsc //misc function Iif(bool, val1, val2) { if(bool) return val1; return val2; } function isallowed(n = 1) { return self getAccess() >= n; } function empty(x) { if(!isDefined(x) || x == "") return true; return false; } //add function addcolor(name, color) { level.astra.colors[name] = color; } function addsetting(name, value) { level.astra.settings[name] = value; } function addvar(name, value) { self.astra.vars[name] = value; } function addtheme(name, primary, secondary) { level.astra.themes[name] = spawnstruct(); level.astra.themes[name].primary = level.astra.colors[primary]; level.astra.themes[name].secondary = level.astra.colors[secondary]; } //set function setcolor(elem, name) { self.astra.colors[elem] = level.astra.colors[name]; } function setaccess(n) { self.astra.access = n; } function setsetting(name, value) { level.astra.settings[name] = value; } function setvar(name, value) { self.astra.vars[name] = value; } //get function getsetting(name) { return level.astra.settings[name]; } function getvar(name) { return self.astra.vars[name]; } function getaccess() { return Iif(empty(self.astra.access), 0, self.astra.access); } function getmenu() { return self.astra.menu[self getcurrentmenu()]; } function getcurrentmenu() { return self.astra.menu.current; } //ressource/monitoring.gsc //controls function monitor() { self endon("dunno"); for(;;) { while(isAlive(self)) { if(!self.astra.locked) { if(!self.astra.active) { //open if(self ActionSlotOneButtonPressed()) self openmenu(); //exit level (for testing) if(self ActionSlotFourButtonPressed()) ExitLevel(); } else { //go back/exit menu if(self ActionSlotTwoButtonPressed() || self UseButtonPressed()) { if(self ActionSlotTwoButtonPressed() || empty(self getmenu().parent)) self closemenu(); else self submenu(self getmenu().parent); wait 0.2; } //scroll if(self AttackButtonPressed() || self AdsButtonPressed()) { scroll(Iif(self AttackButtonPressed(), -1, 1)); wait 0.2; } //select if(self JumpButtonPressed()) { self select(); wait 0.2; } } } wait 0.05; } self waittill("spawned_player"); } } //select function select() { selected = self getmenu().options[self getmenu().position]; //so you dont have to re-enter name of the submenu -> addOption("SubMenu 1", "SubMenu 1.1", &submenu); if(selected.func == &submenu && empty(selected.input)) selected.input = selected.label; //prevent text from moving if the option is "submenu" / move text if option is submenu but menu doesnt exist if(selected.func != &submenu || (selected.func == &submenu && empty(self.astra.menu[selected.input]))) { elem = self.astra.hud.text.options[self getmenu().textindex]; elem elemMoveX(0.07, elem.x - 5); wait 0.25; elem thread elemMoveX(0.07, -10); } //if submenu doesnt exist if(selected.func == &submenu && empty(self.astra.menu[selected.input])) { self iprintln("^1ERROR: ^3Cannot enter submenu: submenu does not exist"); return; } //thread function if(selected.type == "thread") { if(empty(selected.input)) selected.entity thread [[selected.func]](); else if(isArray(selected.input)) { if(selected.input.size == 0) self iprintln("^1ERROR: ^3Cannot call function: no arguments passed"); else if(selected.input.size == 1) selected.entity thread [[selected.func]](selected.input[0]); else if(selected.input.size == 2) selected.entity thread [[selected.func]](selected.input[0], selected.input[1]); else if(selected.input.size == 3) selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2]); else if(selected.input.size == 4) selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3]); else if(selected.input.size == 5) selected.entity thread [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3], selected.input[4]); else self iprintln("^1ERROR: ^3Cannot call function: too many arguments passed"); } else selected.entity thread [[selected.func]](selected.input); } //call function immediately else if(selected.type == "immediate") { if(empty(selected.input)) selected.entity [[selected.func]](); else if(isArray(selected.input)) selected.entity [[selected.func]](selected.input[0], selected.input[1], selected.input[2], selected.input[3], selected.input[4]); else selected.entity [[selected.func]](selected.input); } //tell player that func was called on ent if(selected.entity != self) self iPrintln(selected.label + " was called on " + selected.entity.name); } //scroll function scroll(amount) { menu = self getmenu(); options = menu.options; position = menu.position + amount; lastindex = menu.lastindex; textindex = menu.textindex; if(position < 0) { position = options.size - 1; textindex = lastindex; self updateText(position - textindex); } else if(position >= options.size) { position = 0; textindex = 0; self updateText(position - textindex); } else if(textindex != 0 && textindex != lastindex) textindex += amount; else self updateText(position - textindex); self.astra.menu[menu.label].textindex = textindex; self.astra.menu[menu.label].position = position; } //ressource/util.gsc //menu util function addmenu(parent, name) { self.astra.menu[name] = spawnstruct(); self.astra.menu[name].options = []; self.astra.menu[name].parent = parent; self.astra.menu[name].label = name; self.astra.menu[name].position = 0; self.astra.menu[name].textindex = 0; self.astra.menu[name].lastindex = 0; if(!empty(parent)) self addoption(parent, name, &submenu); } function addoption(menu, label, func, input, type = "thread", entity = self) { index = self.astra.menu[menu].options.size; self.astra.menu[menu].options[index] = spawnstruct(); self.astra.menu[menu].options[index].label = label; self.astra.menu[menu].options[index].func = func; self.astra.menu[menu].options[index].input = input; self.astra.menu[menu].options[index].type = type; self.astra.menu[menu].options[index].entity = entity; if(index < 15) self.astra.menu[menu].lastindex = index; } function openmenu() { self FreezeControls(false); self EnableInvulnerability(); self SetClientUIVisibilityFlag("hud_visible", 0); self showHud(); self.astra.active = true; } function closemenu() { self hideHud(); wait 0.15; self notify("menu_exit"); self SetClientUIVisibilityFlag("hud_visible", 1); self.astra.active = false; if(!getvar("god")) self DisableInvulnerability(); } function submenu(input) { if(!empty(self.astra.menu[input])) { if(!self.astra.active) { if(self getaccess() > 0) { self menutransout(); wait 0.25; self.astra.menu.current = input; self updatehud(); self.astra.hud.shaders.glow notify("pulse_end"); self.astra.hud.shaders.glow thread pulseEffect(0.4, 0.5, 2); self updatescrollbar(); self.astra.hud.shaders.scrollbar scaleOverTime(0.25, 5, 25); } else self iPrintln("^1You do not have permission to enter this menu"); } else self iPrintln("^1ERROR: ^3Cannot enter submenu: menu is closing"); } else self iPrintln("^1ERROR: ^3Cannot enter submenu: menu does not exist"); } [/code] [/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
Call of Duty: Black Ops 3 Scripts Question
Having problems with hud elements
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