NesoxGlass
Member-
Content Count
6 -
Joined
-
Last visited
-
Medals
Community Reputation
1 NeutralAbout NesoxGlass
-
Rank
Rookie
-
Getting a script to restart?
NesoxGlass replied to NesoxGlass's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Yea I tried that and got a stack size violation error lol. Can't find any info about it. -
I'm not sure if I've just got some obvious mistake I've made that I'm blind to, or if there's something I'm not understanding about sqf. Could anyone let me know if, after going through two loops and getting to the end of a script, does the script restart if the variable that controls the first loop get changed so it should loop again? Or does the script just end when it's all been executed, even if there's variables back in the start of the script that say it should go again? Don't mind the horrendous script, I'm just getting into sqf.
-
Keep having issues with SQF
NesoxGlass replied to NesoxGlass's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I hate it here lmao. I can't believe that's all that was needed. It's all working properly now. It's not pretty by any means but it works and that's all I care about atm. Thanks so much for the help ^.^ artilleryPieces = [Art1, Art2, Art3, Art4, Art5, Art6, Art7, Art8, Art9, Art10, Art11, Art12, Art13, Art14, Art15]; //array of the variable names of all artillery pieces test2 = 0; //counter to help cycle through each gun in the array 0-14 gunTracking = artilleryPieces select test2; gunCount = 0; //0-12 gunCountTotal = 0; //12-180 ammostatus = 0; test = count artilleryPieces; //figuring out how many times to loop if (ammostatus == 0) then { while {ammostatus == 0} do { gunCunt = magazinesAmmo gunTracking; gunCount = count gunCunt; gunTracking = artilleryPieces select test2; gunCountTotal = gunCountTotal + gunCount; if (gunCountTotal >= 12) then //checking if the gun has ammo { ammostatus = 0; test2 = test2 + 1; //prepare to select the next gun in the array next loop } else { ammostatus = 1; sleep 1; }; if (test2 == 14) then { test2 = 0; gunCountTotal = 0; }; }; }; if (ammostatus == 1) then { sleep 900; Giving a brief break from the artillery for mission purposes. while {ammostatus == 1} do { gunCunt = magazinesAmmo gunTracking; gunCount = count gunCunt; gunTracking = artilleryPieces select test2; if (gunCountTotal < 200) then //checking if the gun has ammo { ammostatus = 1; gunTracking setVehicleAmmoDef 1; gunTracking reload[]; test2 = test2 + 1; //prepare to select the next gun in the array next loop } else { ammostatus = 0; sleep 1; }; if (test2 == 14) then { test2 = 0; }; }; }; -
Keep having issues with SQF
NesoxGlass replied to NesoxGlass's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've done some fixing up of it, and yea it's only ever checking Art1. I'm not sure I understand why that is though. Every cycle of the loop +1 is added to test2 which is used to reference which part of the array I'm checking. I've gotten it to reload when theres only 1 mag left as reloading when empty messes with the AI. I wouldn't be against having something in each guns init tbh. Might be simpler. I'd just be worried that discrepancies between the time it takes to empty each gun would cause a break that wouldn't be exactly 15 mins. artilleryPieces = [Art1, Art2, Art3, Art4, Art5, Art6, Art7, Art8, Art9, Art10, Art11, Art12, Art13, Art14, Art15]; //array of the variable names of all artillery pieces test2 = 0; //counter to help cycle through each gun in the array gunTracking = artilleryPieces select test2; gunCount = 0; ammostatus = 0; test = count artilleryPieces; //figuring out how many times to loop if (ammostatus == 0) then { while {ammostatus == 0} do { gunCunt = magazinesAmmo gunTracking; gunCount = count gunCunt; if (gunCount > 2) then //checking if the gun has ammo { ammostatus = 0; test2 = test2 + 1; //prepare to select the next gun in the array next loop } else { ammostatus = 1; sleep 1; }; if (test2 == 14) then { test2 = 0; }; }; }; if (ammostatus == 1) then { //sleep 900; Giving a brief break from the artillery for mission purposes. Currrently disabled for testing while {ammostatus == 1} do { gunCunt = magazinesAmmo gunTracking; gunCount = count gunCunt; if (gunCount < 12) then //checking if the gun has ammo { ammostatus = 1; gunTracking setVehicleAmmoDef 1; hint str(gunTracking); gunTracking reload[]; test2 = test2 + 1; //prepare to select the next gun in the array next loop } else { ammostatus = 0; sleep 1; }; if (test2 == 14) then { test2 = 0; }; }; }; -
Keep having issues with SQF
NesoxGlass replied to NesoxGlass's topic in ARMA 3 - MISSION EDITING & SCRIPTING
My goal with that while loop is to have it continually loop through over and over until the detection of no ammo. I didn't want it to just loop 15 times and then never check again. I realized I forgot to add a reset to zero line to get the loop to go back through the 15 different guns. I thought I setup that _x part correctly, as I figured it would reference the part of the array that was selected as that's what made sense to me. How would I go about using it properly? I tried to make this script with AI at first, but after a bit of fiddling around, decided to try and build it from scratch as then I'd at least know what was going on. Not sure if it's a compliment or otherwise to have my code called similar to an AI lol. EDIT: I fixed up the issues you mentioned, and figured out a crude way to check how much ammo is left. It's not pretty but it doesn't throw any errors. I'm not getting to the "you made it this far" hint once the guns only have 1 mag left though. Any idea why? Also don't mind the gunCunt name. I got a bit annoyed at one point working it out. I also realize I forgot to update the bottom with the new selection method. Gonna fix it tomorrow. artilleryPieces = [Art1, Art2, Art3, Art4, Art5, Art6, Art7, Art8, Art9, Art10, Art11, Art12, Art13, Art14, Art15]; //array of the variable names of all artillery pieces test2 = 0; //counter to help cycle through each gun in the array gunTracking = artilleryPieces select test2; gunCount = 0; ammostatus = false; test = count artilleryPieces; //figuring out how many times to loop if (test == 15) then { while {test == 15} do { test2 = test2 + 1; //prepare to select the next gun in the array next loop gunCunt = magazinesAmmo gunTracking; gunCount = count gunCunt; if (gunCount > 1) then //checking if the gun has ammo { ammostatus = false; } else { ammostatus = true; }; if (test2 == 14) then { test2 = 0; }; }; if (ammostatus == true) then { hint "you made it this far"; sleep 900; //Giving a brief break from the artillery for mission purposes while {ammostatus == true} do { artilleryPieces select test2; //Go through each artillery piece and refill it's ammo _x setVehicleAmmoDef 1; }; }; }; -
NesoxGlass started following Keep having issues with SQF
-
I'm trying to get into scripting for some mission making I do for my friends and I. I like to automate things so I can play alongside my friends. I'm trying to get some artillery pieces to reload after a 15min break from the constant barrage once they run out of ammo. Specifically I'm using the D44 85mm Divisional Gun vn_o_vc_static_d44_01 from SOG. Currently I'm having a zero divisor error on line 9. I'm thoroughly confused and I've been trying to problem solve this for about 5 hours now. artilleryPieces = [Art1, Art2, Art3, Art4, Art5, Art6, Art7, Art8, Art9, Art10, Art11, Art12, Art13, Art14, Art15]; //array of the variable names of all artillery pieces test2 = 0; //counter to help cycle through each gun in the array ammostatus = false; test = count artilleryPieces; //figuring out how many times to loop if (test == 15) then { while {test == 15} do { artilleryPieces select test2; //select the current part of the array test2 = test2 + 1; //prepare to select the next gun in the array next loop if (_x ammo "vn_howitzer_85mm" > 1) then //checking if the gun has ammo { ammostatus = false; } else { ammostatus = true; }; }; if (ammostatus == true) then { sleep 900; //Giving a brief break from the artillery for mission purposes while {ammostatus == true} do { artilleryPieces select test2; //Go through each artillery piece and refill it's ammo _x setVehicleAmmoDef 1; }; }; }; Please let me know where I've messed up or if this is even possible. I come from a background of Python so my code might not be as optimal as it could be.