MuRaZorWitchKING 725 Posted November 30, 2018 As the title says, I'm needing help calling a script once the character touches the surface of water, I have tried calling in the script from a game logic module but when I attempt that on the intro of the mission the script is running and it begins and it bugs out, any help would be greatly appreciated. Not sure if it's as simple as // while {surfaceiswater (getPos Player)} do {execVM "Coldwaters.sqf";// or some type of call like that, but I keep getting errors in my expressions as I don't know the syntax very well, thanks! If it cannot be called by a Gamelogic module then I'll be needing help with inserting the call at the beginning of the script as well. :) Share this post Link to post Share on other sites
pierremgi 4850 Posted November 30, 2018 0 = [] spawn { waitUntil {sleep 0.5; (surfaceIsWater getpos yourUnit) && getPosASL yourUnit select 2 < 0}; execVM "yourScript"; }; 1 Share this post Link to post Share on other sites
MuRaZorWitchKING 725 Posted November 30, 2018 @pierremgi I got the script to work when touching water but now need a way to terminate the loop once on land? Would I do the same thing with a gamelogic module? Or throw the termination in the script itself once land is reached? Thanks for the help! Share this post Link to post Share on other sites
davidoss 552 Posted November 30, 2018 Well first of all you should use lazy evaluation in above example. Next there are couple of possibilities for exit this according to where you want exit. You can terminate your script using _thisScript from itself Share this post Link to post Share on other sites
MuRaZorWitchKING 725 Posted November 30, 2018 @davidoss Currently using another .sqf to terminate the script, so once you exit the water it calls "Terminatescript.sqf" which is this script: Spoiler _script = [] execVM "Coldwaters.sqf"; sleep 5; terminate _script; Now if that's correct or not, I'm unsure. Share this post Link to post Share on other sites
davidoss 552 Posted November 30, 2018 Hard to say for sure not seeing Coldwaters.sqf, but if there are no subsequent spawn blocks , yes you're correct!! 1 Share this post Link to post Share on other sites
MuRaZorWitchKING 725 Posted November 30, 2018 My current problem is cancelling the script once the player exits the water, I would like to terminate the loop once dry land is reached but I can't for the life of me figure it out. The script I've tried is: Spoiler 0 = [] spawn { waitUntil {sleep 0.5; (surfaceIsGrass getpos player) && getPosASL player select 2 < 0}; execVM "Terminatescript.sqf"; } But I'm getting errors in expression right before //(#surfaceIsGrass// So I'm stuck ha ha! Share this post Link to post Share on other sites
davidoss 552 Posted November 30, 2018 The loop of waituntil exits self after condition meet. If you want to exit script executed after waituntil loop you can do this from inside this script or from outside. Select your best and let us known PS there are no such command like surfaceIsGrass, use oposite to surfaceIsWater from outside: 0 = [] spawn { waitUntil { sleep 0.5; surfaceIsWater (getPosASL yourUnit) && {((getPosASL yourUnit) select 2) < 0} }; private _inWater = [] execVM "coldWater.sqf"; waitUntil {sleep 0.5;!(surfaceIsWater getPosASL yourUnit)}; hint "Oh man... i hate water!!"; terminate _inWater; }; from inside: waitUntil {sleep 0.5;!(surfaceIsWater getPosASL yourUnit)}; hint "Oh man... i hate water!!"; terminate _thisScript; 2 Share this post Link to post Share on other sites