Valfunction 1 Posted August 31, 2013 I am trying to create an addAction which displays a variable in the action menu. For instance I want the action to say "Move to [VARIABLE]" where [VARIABLE] is the name of a variable. How do I format my addaction display string to display the variable name after the "Move to" part? So for example: _this addAction ["Move to [VARIABLE]", "move.sqf"] //this is obviously not correct syntax but just wanted to know what the correct syntax is. Share this post Link to post Share on other sites
austin_medic 109 Posted August 31, 2013 errrrrrrrr........................ prehaps try this: _this addaction format [["Move to %1","move.sqf"],_urvarhere]; I haven't tested this. Probably doesn't work, but maybe it does... Share this post Link to post Share on other sites
RegEdit 10 Posted August 31, 2013 Probably doesn't work, but maybe it does... You right, it won’t work, correct variant is: _this addAction [format ["Move to %1",_var],"move.sqf"] In this case your variable must be probably string. Share this post Link to post Share on other sites
Valfunction 1 Posted August 31, 2013 Thanks guys. I added some funky colors and other conditions but in the end it came out like this: _jipPole addAction [("<t color=""#FFFF33"">" + ("Move to " + _marker1 + " - NATO base") + "</t>"), "move_to_basel.sqf", [], 1, false, false] and yes _marker1 must be a string. Share this post Link to post Share on other sites
kylania 568 Posted August 31, 2013 Keep in mind this won't update as you change the value of _var. You'd need to remove and readd the the action. Share this post Link to post Share on other sites
Valfunction 1 Posted September 1, 2013 That's true. I have it inside a while loop that updates every 60 seconds and does what you said. Share this post Link to post Share on other sites
galzohar 31 Posted September 1, 2013 Instead of doing it every 60 seconds, you could do it every time you change the variable value (either call a function from all scripts that actually changes the variable value, or have another script run in the background and check when the variable is changed). Share this post Link to post Share on other sites
Valfunction 1 Posted September 1, 2013 That is a good iead. At the moment the variable is only used in the one script and it doesn't seem to have massive overheads by updating it every 60 seconds. But I'll keep that in mind if I expand the concept of the script. To check variable value would I just use: if (_marker1 != _marker1 ) then {//magic} and just check that every 60 seconds? Share this post Link to post Share on other sites
austin_medic 109 Posted September 1, 2013 I would probably do waitUntil {_marker1 != _marker1}; since I believe an if statement can't go inside a loop. Also my method is probably more efficient. Share this post Link to post Share on other sites
galzohar 31 Posted September 1, 2013 Well the whole point of checking the variable value was to be able to update the action as soon as it changed (so that it is always up to date). Of course, for best efficiency you would update the action in the same script that changes the variable, preferably by calling a pre-defined function that does it. Share this post Link to post Share on other sites
Valfunction 1 Posted September 2, 2013 Forgot about waitUntil. That one will work perfectly. No longer related to what the original script is doing just a general question - if I wanted the variable to change every time a player entered the server the best would still be waitUntil is that right? Share this post Link to post Share on other sites
kylania 568 Posted September 2, 2013 Have your onPlayerConnected script change the variable. Share this post Link to post Share on other sites
galzohar 31 Posted September 2, 2013 If you want to change it based on player count, use playersNumber. I'd personaly rather avoid using onPlayerConnected because it's hard to use properly in large missions that have multiple aspects that depend on player count, so I just use playersNumber every time I need to do something based on player count. Share this post Link to post Share on other sites