Jump to content
Sign in to follow this  
lawman_actual

Display variable in chat

Recommended Posts

Fairly newbie question but bear with me - I'm only just starting to get the hang of this scripting business.

I want to be able to check throughout a mission I'm making that a variable is being altered correctly, so I made a radio trigger to display to me the value of the trigger. Only problem is I can't figure out how to get the variable to be "called" as part of the text...

In my init.sqf file I define a global variable - the number of units available on standby:

standbyUnits = 0; 

Now I call a radio trigger so that my unit (dag1a1) can check this value at any time...

 dag1a1 groupChat standbyUnits; 

I figured that by placing the variable name where the text is usually typed, the engine would type the value of the variable as the chat.

Apparently not...

How can I achieve this? I've checked the radio trigger with some text and it works fine.

Many thanks.

Share this post


Link to post
Share on other sites
_unit groupChat (format ["%1",_myVariableName]);

Share this post


Link to post
Share on other sites
_unit groupChat (format ["%1",_myVariableName]);

Thanks very much, worked a charm!

Not that I understand why...

Can you explain what the format ["1%" is doing?

Share this post


Link to post
Share on other sites

Format is just a command that takes a variable and converts it into a string for you, the %1 (make sure it is %1 not 1%) refers to the first argument that you give to it (in the square brackets), basically

_argument1=16;

_argument2=randomUnit;

hint format ["number=%1 and unit=%2",_argument1,_argument2];

would give you a box saying

number=16 and unit=randomUnit

Share this post


Link to post
Share on other sites

you can just simply dag1a1 groupChat str standbyUnits; str converts anything to string.

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  

×