jcae2798 132 Posted December 17, 2015 Sorry i know this was probably posted before, but searching didnt exactly give me the answer i need. My script is below. It is working, but what it is not doing is running through the If/Then on every loop. So for example, i want it to loop every 25 seconds, and after those 25 seconds, i want to restart the If/Then checks. However it seems to only check the condition at start and replay the same code over and over every sleep command. Thoughts? Hopefully i made sense and clear enough _FAR = player distance BROTHER > 5000; _MID = player distance BROTHER == 2500; //Shouldnt matter as long as its between FAR and NEAR _NEAR = player distance BROTHER < 2000; while {alive player} do { Sleep 25; If (_FAR) then { playSound "LongRange"; hint 'LongRange'; } else { if (_NEAR)then {playSound "ShortRange"; hint 'ShortRange';} else {playSound "MidRange"; hint 'MidRange';}; }; }; Share this post Link to post Share on other sites
Von Quest 1163 Posted December 17, 2015 Move the top section INSIDE your 'while loop' so it knows what you are referring to each loop. Share this post Link to post Share on other sites
jcae2798 132 Posted December 17, 2015 LOL. i knew it. Something silly... :) Thanks man! Share this post Link to post Share on other sites
cthulhu616 3 Posted December 17, 2015 hey, you could do this with a switch instead of if evalutaion so you only have to make 1 evaluation each cycle and compare them with the values greetings :-) 1 Share this post Link to post Share on other sites
kovvalsky 13 Posted December 17, 2015 cthulhu616 is right, try this switch (true) do { case ((player distance BROTHER)>5000): { playSound "LongRange"; hint "LongRange"; }; case ((player distance BROTHER)>2450) && ((player distance BROTHER)<2550): { //code.. }; }; Made with KK's SQF to BBCode Converter 1 Share this post Link to post Share on other sites
jcae2798 132 Posted December 18, 2015 Interesting....i'll give this a whirl. I assume this will improve performance (even though for this script it might be minimal...) Thanks again guys,always helpful Share this post Link to post Share on other sites
cthulhu616 3 Posted December 18, 2015 might be minimal for this, but now you know that there are other ways for evaluation aswell ;-) btw... instead of switch (true) do { case ((player distance BROTHER)>5000): { playSound "LongRange"; hint "LongRange"; }; case ((player distance BROTHER)>2450) && ((player distance BROTHER)<2550): { //code.. }; }; you could also do this: _distance= player distance BROTHER switch (true) do { case (_distance>5000): { playSound "LongRange"; hint "LongRange"; }; case (_distance>2450) && ((player distance BROTHER)<2550): { //code.. }; }; so you only have to use that distance command once :-) PS: It's all about being lazy :D 1 Share this post Link to post Share on other sites