Jump to content
Sign in to follow this  
CY4

Returning a value inside a hint

Recommended Posts

Hi,

 

I'm trying to figure out how to make a hint that shows the inventory weight of each player inside a trigger. I'm a total novice when it comes to scripting. I've tried doing this myself for a couple of hours now and I just can't. I need the pros to help. I looked at the BIKI for load, loadAbs, hint, hintSilent, and I can't remember where else. I tried numerous google searches to find some simple answer to this but to no avail.

I'd really appreciate some help,

Thank you.

Share this post


Link to post
Share on other sites

Put in onactivation:

private _hintText = "Players weight:";

{
_hintText = parseText format ["%1<br/>%2: %3", _hintText, name _x, load _x];
} forEach thisList;
hint _hintText;

Untested, let me know if it works

  • Like 3

Share this post


Link to post
Share on other sites

Hi, for some reason I never got a notification that someone replied lol.

That does work to show the weight! Thank you! But instead of going away like a regular hint, I'd like it to stay for as long as there are players in the trigger and I'd also like it to update each second while active as well, is that possible?
EDIT: I figured this part out myself, yay!

Could you instead maybe direct me on how to have the returned weight value show the weight with the proper decimal? For example, as of now, if I have "45.2lbs" of gear, it shows as "452". Any ideas?

Share this post


Link to post
Share on other sites

Okay so check this out, I have been able to modify the code you provided and through a lot of trial and error here is what it looks like:

 

Quote

 

private _hintText = "Loadout Weight"; 


_hintText = parseText format ["%1<br/>%2: %3%4", _hintText, name _x, (round (loadAbs _x * 10 ^ 2 / 10)) / 10 ^ 2, "lbs"]; 
} forEach thisList; 
hintSilent _hintText;

 


Tested on a dedicated server with two friends and I'm left with only ONE more issue currently. I can't figure out how to linebreak after each player on the list. As soon as 2 or more players are in the trigger, the current linebreak between %1 and %2 doesn't even work anymore.

Example of what it looks like with only 1 player named "Cypher" in the trigger:
 

Quote

Loadout Weight
Cypher: 45.2lbs


And what it looks like once there are two players named "Cypher" and "Ace" inside:
 

Quote

Loadout WeightCypher: 45.2lbsAce: 45.2lbs


Any ideas?

Share this post


Link to post
Share on other sites

@CY4, use this code:

_loadoutWeightsInfo = thisList apply { format ["%1: %2lbs", name _x, (round ((loadAbs _x) * 10)) / 10 ^ 2] };

hintSilent (parseText (format ["Loadout Weight<br/>%1", _loadoutWeightsInfo joinString "<br/>"]));

 

  • Like 3

Share this post


Link to post
Share on other sites

Thanks that works like a charm!

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×