UGX-Mods

Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: treminaor on June 26, 2014, 07:18:07 am

Title: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 07:18:07 am
Wiki Link: http://ugx-mods.com/wiki/index.php?title=Hintstrings_not_updating (http://ugx-mods.com/wiki/index.php?title=Hintstrings_not_updating)

I believe this is currently the best fix because it actually resolves the engine limit without using any extra HUD elements or other engine resources.
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 09:54:51 am
Hmm unless it doesn't apply to this, I tested this by having a trigger with a hintstring with a number that goes up everytime i press the USE key, and it disappears when it gets near 48.
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: RamboBadass on June 26, 2014, 03:45:22 pm
sweet ... tobad it wasn't fig out before undead town lol
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 06:37:48 pm
Hmm unless it doesn't apply to this, I tested this by having a trigger with a hintstring with a number that goes up everytime i press the USE key, and it disappears when it gets near 48.
I just did the same test and ran into the limit. However I do not think this is a valid test as you are not giving the script a chance to reset the hintstring to " " after every change, which bypasses the script entirely. I doubt any script is going to need to change the hintstring 48 times while the player is standing there staring at it. I'm going to apply this fix to a community map that I remember had a hintstring issue and see if it's fixed.

I was running into the hintstring limit on my testmap and after adding this fix I no longer had the issue or saw the error - so if that was just some coincidence then I do have another idea that doesn't involve HUD elems that I will try.
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: RamboBadass on June 26, 2014, 07:00:43 pm
^ mine? Lol
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 07:30:43 pm
I just tested it on Undead Town and it seemed to work. First I did a test where I did not implement the script and played the map to see when the hintstrings would break. Once I turned the power on, using the UGX Jukebox worked but the hintstring never changed from "Press &&1 to use the Jukebox [Cost: 10]". It should change to "Currently playing a song.".

Once I added the fix to his ugx_jukebox.gsc, power_switches.gsc, buy_powerup.gsc, and _zombiemode_perks.gsc and played the map again the exact same way, the Jukebox trigger worked. Then I noticed the PaP machine trigger wasn't updating when the power turned on so I added it to that too, and then it worked. I did not find any more broken hintstrings on the map after that. So I think the key to this fix working is to make sure you apply it to as many triggers on the map as possible, because that brings the total count of hintstrings down.

Regardless I don't like that this is not a confirmed 100% fix so I'm going to make some major changes to the way it works and release an update.

Please try adding the current fix to more triggers on your map and tell me if you still can't tell if it's working.
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 08:49:40 pm
Did another test having 3 triggers labeled A, B, and C 128 units apart. When their sums once again hits near 48, they dissappear when they change again after hintstring A, B, and C, hit 15, totalling 45. (the other 3 is my windows and the one wall weapon with the fix unapplied)
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 08:57:09 pm
Alright the wiki is completely updated with a new method that doesn't use hintstrings at all. It should actually work this time :)
Title: Re: [Wiki] How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 09:15:56 pm
Alright the wiki is completely updated with a new method that doesn't use hintstrings at all. It should actually work this time :)

Works. Found a bug, when a "hintstring" change happens while in the trigger, it flickers between the new and the previous hintstring until you walk away and back to it.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 09:16:52 pm
Made a small update to the script to make sure the trig is still defined in the setHintString_show() thread and a check to keep the same thread from being started repeatedly on the same trig. These issues did not affect the functionality of the script but they improve efficiency and eliminate some script errors for those of you in developer_script mode.

Works. Found a bug, when a "hintstring" change happens while in the trigger, it flickers between the new and the previous hintstring until you walk away and back to it.
I'll look into it. Try 1.2, that might fix it.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 09:21:15 pm
Made a small update to the script to make sure the trig is still defined in the setHintString_show() thread and a check to keep the same thread from being started repeatedly on the same trig. These issues did not affect the functionality of the script but they improve efficiency and eliminate some script errors for those of you in developer_script mode.
I'll look into it. Try 1.2, that might fix it.

1.2 fixed the flickering, but a slightly similar, but minor issue, the hintstring won't update until you walk away and come back. :P
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 09:26:19 pm
1.2 fixed the flickering, but a slightly similar, but minor issue, the hintstring won't update until you walk away and come back. :P
Alright I'll look into that after lunch. It's because the thread doesn't end until you walk away, so I need to kill it when a new hintstring is passed to the function.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 10:01:27 pm
Ah, I jus tnoticed that I had forgot to change "self endon("new_thread");" to "trig endon("new_thread");" in the sethintString_show() function. Try making that change and see if it fixes that issue.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 10:06:41 pm
Changed it. Went up to a hintstring and changed it, it didn't update, and it actually didn't go away until I went up into a different hintstring.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 10:16:47 pm
Changed it. Went up to a hintstring and changed it, it didn't update, and it actually didn't go away until I went up into a different hintstring.
Try replacing two functions in the trem_hintstring.gsc with these:
Code Snippet
Plaintext
setHintString_fixed_thread(string)
{
self notify("new_thread");
self endon("new_thread");
if(!isDefined(string)) return;
tokens = strTok(string, " ");
end = false;
leftstring = "";
rightstring = "";
for(i=0;i<tokens.size;i++)
{
if(tokens[i] == "&&1" || tokens[i] == "F" || tokens[i] == "[{+activate}]" || tokens[i] == "[Use]") //use key will be added by the menufile
{
tokens[i] = "";
end = true;
}
if(end) rightstring = rightstring + tokens[i] + " ";
else leftstring = leftstring + tokens[i] + " ";
}
players = getPlayers();
while(isDefined(self))
{
for(k=0;k<players.size;k++)
if(players[k] islookingatent(self) && (distance(players[k].origin, self.origin) < 75) || players[k] isTouching(self))
{
self.leftstring = leftstring;
players[k] thread setHintString_show(self, leftstring, rightstring);
}
wait 0.1;
}
}
setHintString_show(trig, leftstring, rightstring)
{
if(isDefined(self.lookingattrig) && self.lookingattrig == trig) return; //no need to keep calling the thread if we're still standing at the same trig
while(isDefined(trig) && leftstring == self.leftstring && (self islookingatent(trig) && (distance(self.origin, trig.origin) < 75) || self isTouching(trig)))
{
self.lookingattrig = trig;
self setClientDvar("trem_hintstring_left", string(leftstring));
self setClientDvar("trem_hintstring_right", string(rightstring));
self setClientDvar("trem_hintstring_vis", 1);
wait 0.1;
}
self.lookingattrig = undefined;
self setClientDvar("trem_hintstring_left", " ");
self setClientDvar("trem_hintstring_right", " ");
self setClientDvar("trem_hintstring_vis", 0);
}
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 10:17:48 pm
Try replacing two functions in the trem_hintstring.gsc with these:
Code Snippet
Plaintext
setHintString_fixed_thread(string)
{
self notify("new_thread");
self endon("new_thread");
if(!isDefined(string)) return;
tokens = strTok(string, " ");
end = false;
leftstring = "";
rightstring = "";
for(i=0;i<tokens.size;i++)
{
if(tokens[i] == "&&1" || tokens[i] == "F" || tokens[i] == "[{+activate}]" || tokens[i] == "[Use]") //use key will be added by the menufile
{
tokens[i] = "";
end = true;
}
if(end) rightstring = rightstring + tokens[i] + " ";
else leftstring = leftstring + tokens[i] + " ";
}
players = getPlayers();
while(isDefined(self))
{
for(k=0;k<players.size;k++)
if(players[k] islookingatent(self) && (distance(players[k].origin, self.origin) < 75) || players[k] isTouching(self))
{
self.leftstring = leftstring;
players[k] thread setHintString_show(self, leftstring, rightstring);
}
wait 0.1;
}
}
setHintString_show(trig, leftstring, rightstring)
{
if(isDefined(self.lookingattrig) && self.lookingattrig == trig) return; //no need to keep calling the thread if we're still standing at the same trig
while(isDefined(trig) && leftstring == self.leftstring && (self islookingatent(trig) && (distance(self.origin, trig.origin) < 75) || self isTouching(trig)))
{
self.lookingattrig = trig;
self setClientDvar("trem_hintstring_left", string(leftstring));
self setClientDvar("trem_hintstring_right", string(rightstring));
self setClientDvar("trem_hintstring_vis", 1);
wait 0.1;
}
self.lookingattrig = undefined;
self setClientDvar("trem_hintstring_left", " ");
self setClientDvar("trem_hintstring_right", " ");
self setClientDvar("trem_hintstring_vis", 0);
}

Before you posted this, I removed the if statement above it while also changing what you said, now it works great!
 Edit: I'll try this nonetheless.
Edit2: That fix didn't work. What I mentioned did.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 10:25:32 pm
That's because I wrote self instead of players[k]. I don't follow what you are saying fixed it but try changing
Code Snippet
Plaintext
self.leftstring = leftstring;
to
Code Snippet
Plaintext
players[k].leftstring = leftstring;
first.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 10:33:08 pm
That's because I wrote self instead of players[k]. I don't follow what you are saying fixed it but try changing
Code Snippet
Plaintext
self.leftstring = leftstring;
to
Code Snippet
Plaintext
players[k].leftstring = leftstring;
first.

What I meant that I fixed it as when you said

Ah, I jus tnoticed that I had forgot to change "self endon("new_thread");" to "trig endon("new_thread");" in the sethintString_show() function. Try making that change and see if it fixes that issue.

I did exactly that while also removing the line

Code Snippet
Plaintext
if(isDefined(self.lookingattrig) && self.lookingattrig == trig) return; //no need to keep calling the thread

After I did that the hintstring properly updates when still in the trigger.



Other than that, the fix you suggested in the last post also worked. (It dissappears for like a tenth of a second but I don't mind that)
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 10:39:22 pm
Alright, thanks. Wiki updated to v1.3.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 10:59:00 pm
Alright, thanks. Wiki updated to v1.3.

You forgot the isLookingAtEnt(ent) function in the source code. xD
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 11:10:29 pm
You forgot the isLookingAtEnt(ent) function in the source code. xD
Oops, wiki updated.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 11:29:39 pm
A little video showing off the fix on my test triggers as of v1.3. :)

www.youtube.com/watch?v=rkKigfjeaAs (http://www.youtube.com/watch?v=rkKigfjeaAs#ws)
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 11:31:59 pm
Awesome!
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 26, 2014, 11:44:04 pm
Bug Report: Having a thing for the USE key like "&&1" causes the hintstring not to update until you walk away from the trigger than towards it.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 26, 2014, 11:47:23 pm
Bug Report: Having a thing for the USE key like "&&1" causes the hintstring not to update until you walk away from the trigger than towards it.
Maybe because I only check the left side of the string. Please write the full hintstring you are using and what you are changing it to.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 27, 2014, 12:15:02 am
Maybe because I only check the left side of the string. Please write the full hintstring you are using and what you are changing it to.

Pretty much the same thing in the video, Just randomly added in a "Press &&1"

Code Snippet
Plaintext
trig _setHintString("[Hintstring A] Press &&1 This is hintstring number: " + level.hintstringtest + "!");

Fixed using the info you gave me.

Added
Code Snippet
Plaintext
players[k].rightstring = rightstring;
under
Code Snippet
Plaintext
players[k].leftstring = leftstring;

and replaced

Code Snippet
Plaintext
while(isDefined(trig) && isDefined(self.leftstring) && self.leftstring == leftstring && (self islookingatent(trig) && (distance(self.origin, trig.origin) < 75) || self isTouching(trig)))

with

Code Snippet
Plaintext
while(isDefined(trig) && isDefined(self.leftstring) && self.leftstring == leftstring && isDefined(self.rightstring) && self.rightstring == rightstring && (self islookingatent(trig) && (distance(self.origin, trig.origin) < 75) || self isTouching(trig)))
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 27, 2014, 03:11:19 am
Looks good, fixed and updated to 1.4.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on June 27, 2014, 06:19:19 am
Also small question. Does use up any limits? Not sure hud.menu counts as towards the hud limit.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on June 27, 2014, 06:20:19 am
Also small question. Does use up any limits? Not sure hud.menu counts as towards the hud limit.
None whatsoever.
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: gympie6 on May 15, 2018, 06:47:17 pm
I am currently trying to implement this feature but the link to: http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd (http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd) doesn't work anymore.

I know the source is on the wiki but you commented this in the script:
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//|||| Name     : trem_hintstrings.gsc
//|||| Info     : Fixes hintstrings that don't update.
//|||| Site     :
www.ugx-mods.com (http://www.ugx-mods.com)
//|||| Author       : [UGX] treminaor
//|||| Notes        : v1.3
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

I checked it and I think you only forgot to change the version number from 1.3 to 1.4?
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: ProGamerzFTW on May 16, 2018, 03:22:17 am
I am currently trying to implement this feature but the link to: http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd (http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd) doesn't work anymore.

I know the source is on the wiki but you commented this in the script:
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//|||| Name     : trem_hintstrings.gsc
//|||| Info     : Fixes hintstrings that don't update.
//|||| Site     :
www.ugx-mods.com (http://www.ugx-mods.com)
//|||| Author       : [UGX] treminaor
//|||| Notes        : v1.3
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

I checked it and I think you only forgot to change the version number from 1.3 to 1.4?

Yeah he simply forgot to change the version number there. Doesn't change anything ingame though. ^^
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: gympie6 on May 16, 2018, 05:49:50 am
Yeah he simply forgot to change the version number there. Doesn't change anything ingame though. ^^

Thank you ProGamerzFTW for answering this question!
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: Joeycx on May 16, 2018, 02:28:46 pm
Thank you ProGamerzFTW for answering this question!

Does makecent's hintstrings work the same way in reducing the hintstring limit (48 Max in one map) and reduce the trigger entity?

https://www.ugx-mods.com/forum/scripts/55/no-triggers-needed-hintstring-icons-and-ee-hint-images-and-messages/11221/ (https://www.ugx-mods.com/forum/scripts/55/no-triggers-needed-hintstring-icons-and-ee-hint-images-and-messages/11221/)
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: Harry Bo21 on May 16, 2018, 03:48:04 pm
Me and mcs custom triggers don’t use the engine himtstrings at all

Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: Joeycx on May 16, 2018, 09:01:15 pm
Me and mcs custom triggers don’t use the engine himtstrings at all

Since i'm using your scripts, there isn't a need to limit the hintstring?
Title: Re: [Wiki] (Updated) How to fix hintstrings that don't update.
Post by: treminaor on May 18, 2018, 07:48:46 am
I am currently trying to implement this feature but the link to: http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd (http://ugx-mods.com/downloads/tutorials/trem_hintstrings.iwd) doesn't work anymore.

I checked it and I think you only forgot to change the version number from 1.3 to 1.4?
The link works fine, you just have to right click and choose "Save as" because your browser doesn't know how to handle a .iwd file.

And yes, I probably just forgot to update the header in the file.