UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Setting text to a hud element without using SetText()?

broken avatar :(
Created 7 years ago
by Katarina
0 Members and 1 Guest are viewing this topic.
2,532 views
broken avatar :(
×
broken avatar :(
Location: ushell
Date Registered: 4 October 2016
Last active: 4 years ago
Posts
6
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Katarina's Groups
Katarina's Contact & Social Links
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.
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
Signature
Let he who has not sinned cast the first stone.
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
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.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
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
broken avatar :(
×
broken avatar :(
Location: ushell
Date Registered: 4 October 2016
Last active: 4 years ago
Posts
6
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Katarina's Groups
Katarina's Contact & Social Links
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.
Last Edit: July 13, 2017, 03:30:55 pm by Katarina
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
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;


 
Loading ...