UGX-Mods

Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: MegaMech43 on January 19, 2017, 01:07:55 am

Title: How to do Dynamic Variables in GSC?
Post by: MegaMech43 on January 19, 2017, 01:07:55 am
I want to control when a hud activates/deactives per player. (another function changes i.alpha when triggered)
The problem is if I run i.alpha = 1; it will change everybodies huds.

I know two possible solutions. Dynamic variables or
Code Snippet
Plaintext
players = getplayers();
for players.size {
players[i].hud.alpha = 0; //Any idea if there is an index of 'player' that makes this line of code possible?
}

Dynamic Variable:
This method throws an error. This way should work because each time it creates a new hud object with a new variable.
Anyone know a different method that may work?

Code Snippet
Plaintext
function hud() {
players = getplayers();
level.hud = [];
for (i=0; i<players.size; i++) {
abc = asdf+i;
level.hud[i] = NewClientHudElem(players[i]);//I also tried level.i = NewCli... (This compiled but didn't work.)
level.hud[i].foreground = true;
level.hud[i].fontScale = 1.5;
level.hud[i].fontType = "default"; //etc.
level.i.sort = 1;
level.i.hidewheninmenu = true;
level.i.alignX = "left";
level.i.alignY = "bottom";
level.i.horzAlign = "left";
level.i.vertAlign = "bottom";
level.i.x = 35;
level.i.y -= 125;
level.i.alpha = 1; //eventually be 0
level.i SetText("Stocks: "+level.cash); //Yes, you will be able to collect interest at a 'bank' in my map.
}
}
Title: Re: How to do Dynamic Variables in GSC?
Post by: BluntStuffy on January 19, 2017, 01:15:30 am
Code Snippet
Plaintext
function hud() 
{
players = getplayers();
for (i=0; i<players.size; i++)
{
hud[i] = NewClientHudElem(players[i]);
hud[i].foreground = true;
hud[i].fontScale = 1.5;
hud[i].fontType = "default";
hud[i].sort = 1;
hud[i].hidewheninmenu = true;
hud[i].alignX = "left";
hud[i].alignY = "bottom";
hud[i].horzAlign = "left";
hud[i].vertAlign = "bottom";
hud[i].x = 35;
hud[i].y -= 125;
hud[i].alpha = 1; //eventually be 0
hud[i] SetText("Stocks: "+level.cash);
players[i].my_hud = hud[i];
}
}


function change_myhud_alpha()
{
players = getplayers();
for (i=0; i<players.size; i++)
{
players[i].my_hud.alpha = 0;
}
}

Title: Re: How to do Dynamic Variables in GSC?
Post by: MegaMech43 on January 19, 2017, 01:36:23 am
Code Snippet
Plaintext

hud[i] = NewClientHudElem(players[i]);
players[i].my_hud = hud[i];
function change_myhud_alpha() {
players[i].my_hud.alpha = 0;
}

That solution worked! Thank you. I was so close to the answer haha.
That one had me stumped.
"When in doubt, create your own index"?

Is it possible to create a new line with SetText.
Like SetText("Stock: "+level.cash+"\n Interest:"+level.interest);