scottdog62 9 Posted March 5, 2017 Trying to learn scripting Made a very simple script, one thing that is happening is its not being activated, only if I put a sleep command before it and activate in that time, I want it to be activate-able at any time in the mission. _target = BOB; _runner = jim; _begger = greg; if (!alive _target) then { hint "bob is dead"; _runner globalchat "bob is dead good job"; _runner doMove (position player); sleep 3; hint "jim is a traitor"; }; if (!alive _runner) then { hint "jim is dead"; sleep 3; _begger globalchat "please have mercy"; }; if (!alive _begger) then { _begger globalchat "Nooooooooo"; hint "good job"; }; Share this post Link to post Share on other sites
serena 151 Posted March 5, 2017 We have to guess the answers to these questions? Where do you put this code? How do you run this code? Which errors occur during execution? Share this post Link to post Share on other sites
scottdog62 9 Posted March 5, 2017 Hey yeah sorry for the lack of information. 1) It is the init.sqf in my mission. 2) so it triggers on start up 3) so what i want is that when the conditions are met I want them to activate. So say when I kill "target" I want it to "hint "bob is dead"." At the moment it runs through all the code, so when i kill target it doesn't activate the hint's and other commands. I want the way so that it activates once i kill target, ect. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted March 5, 2017 This should do the trick, if I understood right: _wait = [] spawn { _target = BOB; _runner = jim; _begger = greg; waitUntil {!alive _target OR !alive _runner OR !alive _begger}; if (!alive _target) exitWith { hint "bob is dead"; _runner globalchat "bob is dead good job"; _runner doMove (position player); sleep 3; hint "jim is a traitor"; }; if (!alive _runner) exitWith { hint "jim is dead"; sleep 3; _begger globalchat "please have mercy"; }; if (!alive _begger) exitWith { _begger globalchat "Nooooooooo"; hint "good job"; }; }; Cheers 1 Share this post Link to post Share on other sites
serena 151 Posted March 5, 2017 39 minutes ago, scottdog62 said: Hey yeah sorry for the lack of information. 1) It is the init.sqf in my mission. 2) so it triggers on start up 3) so what i want is that when the conditions are met I want them to activate. So say when I kill "target" I want it to "hint "bob is dead"." At the moment it runs through all the code, so when i kill target it doesn't activate the hint's and other commands. I want the way so that it activates once i kill target, ect. I see two problems: Code of your script can executing before BOB, jim and greg variables gets initialized. In most cases you need for delay at begin of init.sqf Your code executes once, while you need to check for conditions continously all the time (as GrumpyOldMan already found above) //delay in init.sqf waitUntil {time > 0}; // other code here Share this post Link to post Share on other sites
serena 151 Posted March 5, 2017 Based on Grumpy Old Man variant: waitUntil {time > 0}; private _target = BOB; private _runner = jim; private _begger = greg; while {true} do { if (!alive _target) exitWith { hint "bob is dead"; _runner globalchat "bob is dead good job"; _runner doMove (position player); sleep 3; hint "jim is a traitor"; }; if (!alive _runner) exitWith { hint "jim is dead"; sleep 3; _begger globalchat "please have mercy"; }; if (!alive _begger) exitWith { _begger globalchat "Nooooooooo"; hint "good job"; }; sleep 1; // important pause }; Share this post Link to post Share on other sites
scottdog62 9 Posted March 6, 2017 hey thanks for the help, getting more of a grasp of how things work. Share this post Link to post Share on other sites