UGX-Mods

Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: Katarina on July 04, 2017, 03:21:12 pm

Title: Setting text to a hud element without using SetText()?
Post by: Katarina on July 04, 2017, 03:21:12 pm
Right now i'm having a problem using SetText(), in a loop anyways it crashes after 25 - 30 minutes of game time.
The error: BG_Cache_GetIndexInternal - Exceeded '2048' items for type 'string'

Does NewHudElem have a text property I can use?
.text doesn't work.
Title: Re: Setting text to a hud element without using SetText()?
Post by: Archaicvirus on July 07, 2017, 04:13:14 am
Right now i'm having a problem using SetText(), in a loop anyways it crashes after 25 - 30 minutes of game time.
The error: BG_Cache_GetIndexInternal - Exceeded '2048' items for type 'string'

Does NewHudElem have a text property I can use?
.text doesn't work.

I would guess your problem is that you aren't deleting the elements, or the defined strings are stacking up, causing an overflow. Try making the variables global, then overwriting them. You could also make a gsh file, define your strings there, then insert them where necessary. That's how 3arc does it generally. Make sure to do #insert scripts/zm/custom_strings.gsh or whatever you name it. That way new strings aren't being generated every time you define text for a hud element. Check your scripts, maybe you forgot to destroy the elements? Check for logic and/or possible loop errors as well, just to be sure unused elements aren't lingering around somehow. Another cheap trick would be to spawn a trigger, link it to the player, and give it a hintstring, but that's a shitty way to do it. I started using gsh files for most of my scripts recently, mostly for the purpose of having all my important variables in one place, easy to tweak settings etc. I only use it for strings and ints/floats, not for the hud elements themselves though. Doing it that way, I have a lot of hud elements including text and shaders, and I haven't experienced that issue. Hope the info helps man, good luck.
Title: Re: Setting text to a hud element without using SetText()?
Post by: Harry Bo21 on July 12, 2017, 10:15:07 am
No your just setting it to quick and when you don't need to

Only update the string - if the string actually changes - and make sure it's not on insanely fast iterations
Title: Re: Setting text to a hud element without using SetText()?
Post by: Katarina on July 13, 2017, 03:27:42 pm
I would guess your problem is that you aren't deleting the elements, or the defined strings are stacking up, causing an overflow. Try making the variables global, then overwriting them. You could also make a gsh file, define your strings there, then insert them where necessary. That's how 3arc does it generally. Make sure to do #insert scripts/zm/custom_strings.gsh or whatever you name it. That way new strings aren't being generated every time you define text for a hud element. Check your scripts, maybe you forgot to destroy the elements? Check for logic and/or possible loop errors as well, just to be sure unused elements aren't lingering around somehow. Another cheap trick would be to spawn a trigger, link it to the player, and give it a hintstring, but that's a shitty way to do it. I started using gsh files for most of my scripts recently, mostly for the purpose of having all my important variables in one place, easy to tweak settings etc. I only use it for strings and ints/floats, not for the hud elements themselves though. Doing it that way, I have a lot of hud elements including text and shaders, and I haven't experienced that issue. Hope the info helps man, good luck.

Ok this is what I've got now:
#define ZOMBIE_COUNT "Zombie Count: %%1"
#define ZOMBIE_REMAINING "Zombies Remaining: %%1"
#define TOTAL_GAME_TIME "Total Game Time: %%1:%%2:%%3"

Unfortunately though when I use SetText(&ZOMBIE_COUNT, zombie_utility::get_current_zombie_count())
the output I get is: "Zombie Count: ..16" and for Total Game Time it gets weirder: "Total Game Time: ..1:..2:..3000000"

How do I format the string so I get: "Zombie Count: x" or "Total Game Time: "xx:xx:xx"

Double Post Merge: July 13, 2017, 03:30:35 pm
No your just setting it to quick and when you don't need to

Only update the string - if the string actually changes - and make sure it's not on insanely fast iterations

I do need to though I'm making a stopwatch and zombie counter.

And I know about creating multiple huds side by side, and using SetValue instead, but for the stopwatch part it's extremely difficult and looks really sloppy.
Title: Re: Setting text to a hud element without using SetText()?
Post by: Archaicvirus on July 13, 2017, 06:43:36 pm
I think what you want to do is update the string first, then set text.

Code Snippet
Plaintext
X = get_current_zombie_count();
String = "Zombie Count: " + X;