Search the Community
Showing results for tags 'while'.
Found 10 results
-
Just thinking... Which one is faster, generally? Of course, considering the same code into the loopings. TAG_fnc_functionName = { // Doc string... // Returns nothing. params ["_something"]; private ["_varPrivate1"]; // code that's need to be checked many, many times... // CPU breath: sleep 1; // Restart the function in a new branch: [_something] spawn TAG_fnc_functionName; // Return: true; }; true; Or while { _someCondTrue } do { // code that's need to be checked many, many times... // CPU breath: sleep 1; }; 🧐
-
Hi guys, I have created a script to spawn enemies until a player in an area has been outnumbered, then wait until the player isn't outnumbers and resume spawning. I'm using a while for this with some If and uisleep. While this script is running I'm seeing a severe impact on performance, FPS is fine but server command processing is slowed, Zeus spawning or module placing lags. Is this an efficient way of performing this task? Is there a better way to do this? Also how do I stop the script from running?
-
Hello! I am trying to loop some commands within an .SQF that includes IF ELSE statements. I need the script to loop while a certain variable is true so that the mission may later set the variable to false, disabling the script. Here is my current script: tester.sqf ____________________________________________________ _xxx3 = true; While {_xxx3 == true} do { sleep 1; if (istouchingground player) then { hint "You are on ground"; } else { hint "Game Detected you are in water, will reset position in 3 seconds"; sleep 3; if (istouchingground player) then { hint "Not in water anymore"; } else { player setpos [0,0,0]; hint "Position reset";};}; ______________________________________________________ After the player has been detected in the water (or not touching ground) I have the script run another check 3 seconds afterwards to ensure that the player is actually in water and not glitching out in air for a few seconds, as is common in Arma, so that is why I have included another IF-ELSE statement below. The "sleep 1" I included in the beginning is to help minimize the impact on performance, so that the script only runs every second instead of every frame. Running execvm "tester.sqf"; gives no error messages but the script does not run. I tried scouring the forums for a similar situation and somehow I haven't found anything. If anyone can help me out I would be very grateful, I've been stumped on this for a few days now. Thank you!!
-
Helo. I have a seeding problem with the random function that I just can't figure out. while { surfaceIsWater _suitable || count _list > 0} do { while {_spot distance officer_jeff < 1000 || surfaceIsWater _spot} do { _prevStep = _center getPos[ (random 2000), (random 350)]; for "_i" from 0 to 2 do { _step = _prevStep getPos[ (random 2001), (random 351)]; _prevStep = _step; }; _spot = [_step select 0,_step select 1,0]; }; _suitable = [_spot, 0, 300, 20, 0, 0.7, 0] call BIS_fnc_findSafePos; _list = nearestTerrainObjects [_suitable,["TREE","BUILDING","RUIN","ROCK","HOUSE"], _howBig,false]; }; If the script can't find a position that is not a water surface, it restarts BUT the RANDOM functions just keeps giving me the same position every time the cycle ends. I don't understand, is it not supposed to be random? I also tried this with seed using the alternate syntax of random: while { surfaceIsWater _suitable || count _list > 0} do { while {_spot distance officer_jeff < 1000 || surfaceIsWater _spot} do { _prevStep = _center getPos[ (time random 2000), (time random 350)]; for "_i" from 0 to 2 do { _step = _prevStep getPos[ (time random 2001), (time random 351)]; _prevStep = _step; }; _spot = [_step select 0,_step select 1,0]; }; _suitable = [_spot, 0, 300, 20, 0, 0.7, 0] call BIS_fnc_findSafePos; _list = nearestTerrainObjects [_suitable,["TREE","BUILDING","RUIN","ROCK","HOUSE"], _howBig,false]; }; Here is an example output: 15:12:48 "[823.795,10712.5] as _suitable, 56 as count _list, [816.133,10551.5,0] as _spot " 15:12:49 "[820.423,10745.8] as _suitable, 46 as count _list, [816.133,10551.5,0] as _spot " 15:12:50 "[828.004,10684.4] as _suitable, 76 as count _list, [816.133,10551.5,0] as _spot " Any help would be much appreciated.
-
Hey, I'm working on a horror mission with puzzles. The trouble has to do with some scripts due to my knowledge. I have one trigger playing a sound. The sound is 21 seconds long. Once the sound trigger has been activated, the player has to go and activate another trigger within those 21 seconds. The second trigger should be activated only when the sound is being played. I'm asking for a solution for the condition field of the second trigger. I'm thinking of something like: this && while {true} do (or something like this) Puzzle idea from Amnesia: The Dark Descent. Link to video: https://youtu.be/dLTcEDjR4VY?t=408 Highly appreciate your help, and thanks in advance! :)
-
while loop not restarting on save load
lordfrith posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
hi folks i've written a while loop to scan for nearby buildings as player moves around. on mission load everything is working beautifully but on loading a save game the loop doesn't continue. the structure of the loop being spawned is as follows, in the mission init there is: which has a bunch of variable/function defines and then at the bottom: which contains the while loop: is there anythings obviously wrong with the scheduled/unscheduled environment thing here? I'm a bit hazy on it still... i thought when the save is loaded the while loop state would be loaded and continue -
waitUntil vs (while + sleep) performance cost
ColonelKernel posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi. I was wondering which one of these two commands has a bigger effect on performance: waitUntil { !cond }; or while {cond} do { sleep 0.5; }; Also, does the amount of sleep time matter? What about the condition? For example, if we have to check a series of conditions (e.g {alive _x} foreach Allunits) which one is better? -
Question regarding while{true} dependability
Midnighters posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello forum users. I have written a script to animate the hummingbird based on crew members and everything works fine. One thing I fret very badly about is performance. I'm just not sure if it would be best to use something like bis_fnc_loop instead. { if((typeOf _x) == "B_Heli_Light_01_F") then { while{true} do { if((count (crew _x)) >= 2) then { if(isTouchingGround _x) then { _x animateSource["BenchR_Up",0]; _x animateSource["BenchL_Up",0]; }; }; if((count (crew _x)) <= 2) then { if(!(isTouchingGround _x)) then { _x animateSource["BenchR_Up",1]; _x animateSource["BenchL_Up",1]; }; }; }; }; } forEach vehicles; -
Hi folks I've got an issue with trying to write a script that lets me keep doing an action until the point where I don't want to do the action any longer. A player has a camera in their gear. When they want to take a photo, the script fires up. The script makes them put away their current weapon, and an image of the back of a camera pops up on their screen. picture sharing Now the bit that has me stumped. I want to be able to have the player take as many photos as they want before putting the camera away. The script snippet I have for 'clicking' the camera is this: (The inputAction "Fire" is done by the player holding Left-Ctrl + Left mouse click). This works a treat in my script, but sadly can only be done once at the moment due to my lack of scripting know-how. I then have another script snippet which lets the rest of the script continue, thus closing the camera and letting the player get his weapon out again: (The inputAction "toggleRaiseWeapon" by default is a double tap of the Left-Ctrl key). The other problem here is that the player has to take a photo before the script continues on to the part where the player can put the camera away. What if the player opens the camera, but then decides to put it away without taking any shots. He/she can't in the script's current state. Here's the whole script currently: So in summery, I want the player to be able to point and 'click' the camera as many times and at as many objects as they want, then when they're ready, put the camera away. I hope that all makes sense. Any help with this is appreciated. Thanks heaps. Vapour