sgtelis 11 Posted August 2, 2015 Hi! So I am making a mission where blufor is hunting a independent and there is a lot of civilians around that should be able to spot the independent and if then a blufor comes and talk to them I want them to remember if they have spotted the independent or not. So what I have been able to find out is that knowsAbout is something that can be used to determen if a character have seen someone or not however I can't figure out how to use it. What I want it to do: If a civilian spotts a independent a script is called, this script sets a variable in that specific civilian that sais he have spotted a independent. The rest I want it to do I can fix my self. (Btw, I know how to use set- and getVariable) Thank you! Share this post Link to post Share on other sites
Magirot 14 Posted August 2, 2015 I guess it'd probably be simplest to loop allUnits. Execute this from your initServer.sqf: // loop as long as TRUE is TRUE, = forever while {TRUE} do { { // forEach block start // _x is the magic variable referring to the currently selected forEach object if (side _x == civilian) then { // you can use side with knowsAbout; // 4 is the maximum knowsAbout that is achieved pretty easily if (_x knowsAbout independent >= 4) then { // script you want to call here _x setVariable ["knowsAboutIndependent", TRUE, TRUE]; }; }; } forEach allUnits; sleep 6; // wait a bit before looping again };How smart this is depends on how your mission is build. If a lot of CPU-intensive stuff is going on, instead of cycling through all units, you might want to cycle a premade array of civilians instead. Generally I doubt the loop will be a problem, though. If you need help with something specific regarding this, ask ahead, it's a nice setup for a mission that people can probably help with. 1 Share this post Link to post Share on other sites
sgtelis 11 Posted August 3, 2015 I believe this is exactly what I am looking for however a strange bug or something has occured in my mission and the non-edited script that worked yesterday now decided not to work anymore... https://forums.bistudio.com/topic/183531-why-does-this-code-not-work/ Share this post Link to post Share on other sites
sgtelis 11 Posted August 4, 2015 hmm... I pasted it in initServer.sqf and put in some hints to see that it works. I can clearly see that it starts up however the hint that I put at the same place as the setVariable never shows up, aka he never "spotts" the independent even though I stand infront of the civ as a indep for a very long time. Even tried to lower the knowsAbout to 1. Share this post Link to post Share on other sites
Magirot 14 Posted August 4, 2015 Oh, sorry, I didn't realise that only the first parameter (the one whose knowsAbout is checked) can be a side, and the other has to be an object. Since you need to check each civilian individually, I guess it needs be two cycles through allUnits. And now it looks messy: // loop as long as TRUE is TRUE, = forever while {TRUE} do { // get allUnits since it's used more than once _allUnits = allUnits; { // forEach block start // _x is the magic variable referring to the currently selected forEach object _unit = _x; if (side _unit == civilian) then { { // second forEach block start if (side _x == independent) then { // 4 is the maximum knowsAbout that is achieved pretty easily if (_unit knowsAbout _x >= 4) then { // script you want to call here _unit setVariable ["knowsAboutIndependent", TRUE, TRUE]; }; }; } forEach _allUnits }; } forEach _allUnits; sleep 6; // wait a bit before looping again }; I tried to check the impact on the performance with BIS_fnc_codePerformance, and it at least didn't seem to make a huge difference. On another note, you might want to run the game with -showScriptErrors enabled, since with it you can get some visible hints on what's gone wrong with a script like this. 1 Share this post Link to post Share on other sites
sgtelis 11 Posted August 5, 2015 Thank you! Now it works perfectly! :D Also, -showScriptErrors was super helpfull! I was wondering if there was a debug tool of some sort in arma and there it was! :D Thank you again! :) Share this post Link to post Share on other sites