Kyancyan 2 Posted May 27, 2021 Hey folks, sorry if this is a duplicate I searched all over, didn't find anything that looked like what I needed. I'm working on a little S.T.A.L.K.E.R-esque mission for some friends of mine who are fans of the games, and I was hoping to add some randomized 'sideChat'-based dialogue for them to see as they walked through repeatable triggers centered around groups of AI at the safezones. I've created an array with all the different sentences of dialogue but I'm utterly clueless on how I would take a randomized sentence from the array and make the [west, "HQ"] sideChat "(randomly-selected dialogue)"; code reference it. I'm not even sure if dialogue storage is the proper application of arrays but that's what I get for being a scripting novice, so I apologize in advance if this is braindead simple. Also, if anyone could point me in the right direction as to how to do the same thing to a playSound3D command, that would be excellent - I've got a selection of sounds I'd like to randomly play in hand-picked houses all over the map. Share this post Link to post Share on other sites
7erra 629 Posted May 27, 2021 https://community.bistudio.com/wiki/selectRandom might help you. so: [west, "HQ"] sideChat (selectRandom ["Hello.", "Good day.", "Hi."]); Share this post Link to post Share on other sites
Kyancyan 2 Posted May 27, 2021 Thanks for the swift response, I appreciate it. Good to know I wasn't too far off at least, I was tinkering with selectRandom but couldn't figure out the syntax. Would this be made any easier or simpler if the array was already defined in init.sqf? Just so each trigger doesn't have to have duplicates of the massive amount of options I've set up. Share this post Link to post Share on other sites
7erra 629 Posted May 27, 2021 6 hours ago, Kyancyan said: Would this be made any easier or simpler if the array was already defined in init.sqf? Yes, if you declared a global variable in the init.sqf it will be available in all other scripts. In that case it would look something like this: //--- init.sqf TAG_greetings = ["Hello.", "Hi.", "Good day."]; //--- Wherever you want: [west, "HQ"] sideChat (selectRandom TAG_greetings); Your own TAG_ prefix serves the purpose so that your variable is absolutely unique and can not overwrite/be overwritten by the script of another author. I use TER_ for example. Share this post Link to post Share on other sites
7erra 629 Posted May 27, 2021 Oh and also you could give the Functions Library a shot if you have code that is reused on multiple occasions. It will save you from editing all that code in different places. 1 Share this post Link to post Share on other sites
Kyancyan 2 Posted May 28, 2021 Perfect, thanks for all your help 7erra, everything is working perfectly now thanks to you. Share this post Link to post Share on other sites