Johnson11B2P 3 Posted July 28, 2013 Here's my situation. I've created a briefing.sqf file that adds each unit type to an array so that I can pass different diary notes to different sections. /* * briefing.sqf * for =RG=Operation Raging Titans * created by [RG]RexJoker */ /* * Adding units to arrays */ Mohegan = [mohegan26,mohegan21,mohegan22,mohegan23, mohegan21a,mohegan21a1,mohegan21a2,mohegan21a3,mohegan21b,mohegan21b1,mohegan21b2,mohegan21b3, mohegan22a,mohegan22a1,mohegan22a2,mohegan22a3,mohegan22b,mohegan22b1,mohegan22b2,mohegan22b3, mohegan23a,mohegan23a1,mohegan23a2,mohegan23a3,mohegan23b,mohegan23b1,mohegan23b2,mohegan23b3]; Talon = [talon00,talon01,talon02,talon03,talon04,talon05,talon06,talon07,talon08,talon09,talon10]; Highroller = [andrews,wulfyn,caesar,Chewie,taker,harry,lightning]; Vegas = [vegas000,vegas001,vegas002,vegas003,vegas004,vegas005]; Excalibur = [excalibur00,excalibur01,excalibur02,excalibur03,excalibur04,excalibur05,excalibur06,excalibur07]; Gambler_1_7 = [gambler00,gambler01,gambler02,gambler03,gambler04,gambler05,gambler06,gambler07,gambler08,gambler09,gambler010,gambler011,gambler012,gambler013,gambler014,gambler015,gambler016,gambler018,gambler019]; Reserve = [reserve00,reserve01,reserve02,reserve03,reserve04,reserve05]; combatCameraFag = [locomotion]; /* * Diary Subject about mission author(me) */ player createDiarySubject ["me","RexJoker"]; player createDiaryRecord ["me",["Contact Me" , "Steam ID: RexJoker"]]; player createDiaryRecord ["me",["Contact Me" , "Origin ID: RexJoker"]]; player createDiaryRecord ["me",["Contact Me" , "Email: RamonJohnson47@gmail.com"]]; /* * Basic Op Order that will show for different units. Only highroller, talon, excalibur, and Combat Camera can see all. * Talon, Mohegan, Gambler can only see a few. */ player createDiaryRecord ["Diary", ["Command Signal", "Task Force RG SOP."]]; player createDiaryRecord ["Diary", ["Service and Support", "Talon or Excalibur available as MEDEVAC or Resupply request."]]; player createDiaryRecord ["Diary", ["Execution", "Highroller, Talon, and Excalibur units provide support towards Gambler, Mohecan, and Vegas units as needed."]]; {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]} forEach Highroller; {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]} forEach Talon; {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]} forEach Excalibur; {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]} forEach Mohegan; {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]} forEach combatCameraFag ; {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]} forEach Talon; {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]} forEach Highroller; {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]} forEach Vegas; {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]} forEach Excalibur; {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]} forEach combatCameraFag ; {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]} forEach Talon; {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]} forEach Highroller; {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]} forEach Vegas; {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]} forEach Excalibur; {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]} forEach combatCameraFag ; {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]} forEach Talon; {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]} forEach Highroller; {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]} forEach Gambler_1_7; {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]} forEach Excalibur; {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]} forEach combatCameraFag ; player createDiaryRecord ["Diary", ["Situation", "Enemy Opfor have strategic basees at Kamino Firing Range and Air Station Mike. This airbase allows them to supply QRF throughout Stratis. While new APC's are located at AS Mike."]]; This runs perfectly inside the editor but my mission is for MP and if no one is in a slot it will through undeclared variable in expression. Now that we have the whole expression error popping up everywhere I have two questions. Is there try catch that I can use to get rid of the message? Is there a simpler way that I don't know about that would solve the issue? Share this post Link to post Share on other sites
Deadfast 43 Posted July 28, 2013 You cannot catch script errors with catch, you can only catch what you throw yourself. What you need it the following: /* * briefing.sqf * for =RG=Operation Raging Titans * created by [RG]RexJoker */ /* * Adding units to arrays */ Mohegan = [mohegan26,mohegan21,mohegan22,mohegan23, mohegan21a,mohegan21a1,mohegan21a2,mohegan21a3,mohegan21b,mohegan21b1,mohegan21b2,mohegan21b3, mohegan22a,mohegan22a1,mohegan22a2,mohegan22a3,mohegan22b,mohegan22b1,mohegan22b2,mohegan22b3, mohegan23a,mohegan23a1,mohegan23a2,mohegan23a3,mohegan23b,mohegan23b1,mohegan23b2,mohegan23b3]; Talon = [talon00,talon01,talon02,talon03,talon04,talon05,talon06,talon07,talon08,talon09,talon10]; Highroller = [andrews,wulfyn,caesar,Chewie,taker,harry,lightning]; Vegas = [vegas000,vegas001,vegas002,vegas003,vegas004,vegas005]; Excalibur = [excalibur00,excalibur01,excalibur02,excalibur03,excalibur04,excalibur05,excalibur06,excalibur07]; Gambler_1_7 = [gambler00,gambler01,gambler02,gambler03,gambler04,gambler05,gambler06,gambler07,gambler08,gambler09,gambler010,gambler011,gambler012,gambler013,gambler014,gambler015,gambler016,gambler018,gambler019]; Reserve = [reserve00,reserve01,reserve02,reserve03,reserve04,reserve05]; combatCameraFag = [locomotion]; /* * Diary Subject about mission author(me) */ player createDiarySubject ["me","RexJoker"]; player createDiaryRecord ["me",["Contact Me" , "Steam ID: RexJoker"]]; player createDiaryRecord ["me",["Contact Me" , "Origin ID: RexJoker"]]; player createDiaryRecord ["me",["Contact Me" , "Email: RamonJohnson47@gmail.com"]]; /* * Basic Op Order that will show for different units. Only highroller, talon, excalibur, and Combat Camera can see all. * Talon, Mohegan, Gambler can only see a few. */ player createDiaryRecord ["Diary", ["Command Signal", "Task Force RG SOP."]]; player createDiaryRecord ["Diary", ["Service and Support", "Talon or Excalibur available as MEDEVAC or Resupply request."]]; player createDiaryRecord ["Diary", ["Execution", "Highroller, Talon, and Excalibur units provide support towards Gambler, Mohecan, and Vegas units as needed."]]; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]}} forEach Highroller; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]}} forEach Talon; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]}} forEach Excalibur; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]}} forEach Mohegan; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]}} forEach combatCameraFag ; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]}} forEach Talon; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]}} forEach Highroller; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]}} forEach Vegas; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]}} forEach Excalibur; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]}} forEach combatCameraFag ; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]}} forEach Talon; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]}} forEach Highroller; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]}} forEach Vegas; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]}} forEach Excalibur; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]}} forEach combatCameraFag ; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]}} forEach Talon; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]}} forEach Highroller; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]}} forEach Gambler_1_7; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]}} forEach Excalibur; {if (!isNil "_x" && {!isNull _x}) then {_x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]]}} forEach combatCameraFag ; player createDiaryRecord ["Diary", ["Situation", "Enemy Opfor have strategic basees at Kamino Firing Range and Air Station Mike. This airbase allows them to supply QRF throughout Stratis. While new APC's are located at AS Mike."]]; Share this post Link to post Share on other sites
Johnson11B2P 3 Posted July 28, 2013 You da bes thanks. Share this post Link to post Share on other sites
Johnson11B2P 3 Posted July 28, 2013 Still causes the error message? Is there a way to iterate through before I add them to the array? Maybe put something in the init of each unit that will add itself to the array. Share this post Link to post Share on other sites
Deadfast 43 Posted July 28, 2013 You could add this to the init line of each unit: if (isNil "Talon") then {Talon = []}; Talon set [count Talon, this] Share this post Link to post Share on other sites
Johnson11B2P 3 Posted July 28, 2013 {Talon = []}; Wouldn't that reset the array for each person? Share this post Link to post Share on other sites
galzohar 31 Posted July 28, 2013 Only if Talon is nil. Next time such a line runs it will not be nil and thus it won't be re-initialized. Of course, there are better and cleaner way to initialize stuff, but this will get you going if you're still trying to figure things out. Share this post Link to post Share on other sites
Johnson11B2P 3 Posted July 29, 2013 Roger galzohar I'm trackin now. Thanks for the insight. Share this post Link to post Share on other sites
kylania 568 Posted July 29, 2013 Of course, there are better and cleaner way to initialize stuff Examples please? :) Share this post Link to post Share on other sites
galzohar 31 Posted July 29, 2013 For example you could use a script to properly iterate over the units and keep the array up to date during the mission if needed. Of course you'd need to know how to filter out the units you need, so if you only know 3 sqf commands it won't be very easy to do. But if you can use allUnits, foreach, and proper conditions to get what you want (be it typeOf, isKindOf, side, group, vehicleVarName or whatever) then you can put all your initialization code in 1 place and be much more flexible. Relying on init lines is generally not a good idea for missions that support JIP and/or base respawn. Of course the details depend on what you actually plan to do with the array. Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 3, 2013 if (isNil Highroller) then {Highroller = []}; Highroller set [count Highroller, this]; Error count: Type Object, expected Array,Config entry I've tried different ways to get around this error but it still comes to this. I placed this in the init of the units. Share this post Link to post Share on other sites
Ghost 40 Posted August 3, 2013 make sure highroller is an array. also isnil checks a string or code, so isnil "highroller" would be the proper format Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 3, 2013 How do I instantiate an array for ARMA? Share this post Link to post Share on other sites
Ghost 40 Posted August 3, 2013 _marvar = []; maybe post what you have right now? Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 3, 2013 (edited) Question I have the array in a briefing.sqf. But the line I just posted is in the init of the units in the editor. Do I need to change anything? Check the first page of this thread that is how I have it setup. Edited August 3, 2013 by Johnson11B2P Share this post Link to post Share on other sites
Ghost 40 Posted August 3, 2013 off hand i do not remember the order of init on mission start but i think the init.sqf is first. Share this post Link to post Share on other sites
kylania 568 Posted August 3, 2013 (edited) Per Moricky: Initialization Order When mission is starting, its components are initialized in the following order: Functions with recompile param set to 1 are recompiled Functions with preInit param set to 1 are called Object Init Event Handlers are called Object initialization fields are called init.sqs is executed in singleplayer init.sqf is executed in singleplayer Persistent multiplayer functions are called (client only) Modules are initialized initServer.sqf is executed (server only) initPlayerLocal.sqf is executed initPlayerServer.sqf is executed (server only) Functions with postInit param set to 1 are called BIS_fnc_init" variable is set to true init.sqs is executed in multiplayer init.sqf is executed in multiplayer Edited August 7, 2013 by kylania Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 5, 2013 Mohegan = []; Mohegan = Mohegan +(units twoSix) + (units twoOne) + (units twoTwo) + (units twoThree) + (units twoOneAlpha) + (units twoOneBravo)+(units twoTwoAlpha) + (units twoTwoBravo) + (units twoThreeAlpha) + (units twoThreeBravo); Talon = []; Talon = Talon +(units talon2); Highroller = []; Highroller = Highroller + (units highroller2) + (units combatCamera); Vegas = []; Vegas = Vegas + (units vegas2); Excalibur = []; Excalibur = Excalibur + (units excalibur2); Gambler17 = []; Gambler17 = Gambler17 + (units oneSeven) + (units oneSevenAlpha) + (units oneSevenBravo) + (units oneSevenCharlie); Reserve = []; Reserve = Reserve + (units reserve2); /* * Basic Op Order that will show for different units. Only highroller, talon, excalibur, and Combat Camera can see all. * Talon, Mohegan, Gambler can only see a few. */ player createDiaryRecord ["Diary", ["Command Signal", "Task Force RG SOP."]]; player createDiaryRecord ["Diary", ["Service and Support", "Talon or Excalibur available as MEDEVAC or Resupply request."]]; player createDiaryRecord ["Diary", ["Execution", "Highroller, Talon, and Excalibur units provide support towards Gambler, Mohegan, and Vegas units as needed."]]; if(!isNil "Mohegan") then { { _x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]];} forEach Mohegan; }; if(!isNil "Highroller") then { { _x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]; _x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]; _x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]; _x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]];} forEach Highroller; }; if(!isNil "Talon") then { { _x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]; _x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]; _x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]; _x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]];} forEach Talon; }; if(!isNil "Excalibur") then { { _x createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]; _x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]; _x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]]; _x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]];} forEach Excalibur; }; if(!isNil "Vegas") then { { _ createDiaryRecord ["Diary", ["Mission", "Destroy the new APCs the OPFOR have situated at Air Station Mike."]]; _x createDiaryRecord ["Diary", ["Mission", "Take down the Mortar pit at LZ Baldy."]]; _x createDiaryRecord ["Diary", ["Mission", "Assassinate OPFOR's Regional Officer located at Camp Rogain."]];} forEach Vegas; }; if(!isNil "Gambler17") then { { _x createDiaryRecord ["Diary", ["Mission", "Destroy helicopters located at Kamino Firing Range."]];} forEach Gambler17; }; player createDiaryRecord ["Diary", ["Situation", "Enemy Opfor have strategic bases at Kamino Firing Range and Air Station Mike. This airbase allows them to supply QRF throughout Stratis. While new APC's are located at AS Mike."]]; Would this be the correct way to do this now? I put a nil check to make sure the group isn't nil and if it's a multiplayer game with no A.I. technically only slots that are filled with players should be returned to the array. Do I need the isNull check too? Share this post Link to post Share on other sites