Dramacius 8 Posted June 30, 2023 Spoiler DM_fnc_StartOpSouthHostiles = { if (opSouth_mode == 1) then { hostileCount = {alive _x} count opSouth_hostileArray; hint format ["Hostiles Remaining, %1!", hostileCount]; Hint "Is their anyone already running this training scenario?"; hint "If not, reset Op South Hostiles first"; hint ""; } else { missionNamespace setVariable ["level", 0, true]; missionNamespace setVariable ["maxLevel", 10, true]; missionNamespace setVariable ["opSouth_mode", 1, true]; // opSouth_mode 0 = disabled, 1 = tower defence, 2 = tower attack _index = lbCurSel 1500; _hostileForce = hostileListArray select _index; hint format ["Spawning %1, please wait...", _hostileForce]; if (_hostileForce == "Ardistan Army") then { //-------- Ardistan Army INFANTRY opSouth_INF = [ "UK3CB_ARD_O_AT", "UK3CB_ARD_O_AR", "UK3CB_ARD_O_DEM", "UK3CB_ARD_O_ENG", "UK3CB_ARD_O_GL", "UK3CB_ARD_O_STATIC_GUN_DSHKM", "UK3CB_ARD_O_STATIC_GUN_METIS", "UK3CB_ARD_O_STATIC_GUN_NSV", "UK3CB_ARD_O_STATIC_GUN_PKM", "UK3CB_ARD_O_STATIC_GUN_PODNOS", "UK3CB_ARD_O_STATIC_GUN_SPG9", "UK3CB_ARD_O_JNR_OFF", "UK3CB_ARD_O_LAT", "UK3CB_ARD_O_MG", "UK3CB_ARD_O_MK", "UK3CB_ARD_O_MD", "UK3CB_ARD_O_OFF", "UK3CB_ARD_O_RIF_1", "UK3CB_ARD_O_RIF_2", "UK3CB_ARD_O_SL", "UK3CB_ARD_O_SNI", "UK3CB_ARD_O_TL", "UK3CB_ARD_O_AA", "UK3CB_ARD_O_SF_AA", "UK3CB_ARD_O_SF_AT", "UK3CB_ARD_O_SF_AR", "UK3CB_ARD_O_SF_DEM", "UK3CB_ARD_O_SF_ENG", "UK3CB_ARD_O_SF_GL", "UK3CB_ARD_O_SF_LAT", "UK3CB_ARD_O_SF_MG", "UK3CB_ARD_O_SF_MK", "UK3CB_ARD_O_SF_MD", "UK3CB_ARD_O_SF_RIF_1", "UK3CB_ARD_O_SF_RIF_2", "UK3CB_ARD_O_SF_SL", "UK3CB_ARD_O_SF_SNI", "UK3CB_ARD_O_SF_SPOT", "UK3CB_ARD_O_SF_TL" ]; //-------- Ardistan Army Vehicles opSouth_VEH = [ "UK3CB_ARD_O_BRDM2", "UK3CB_ARD_O_BRDM2_ATGM", "UK3CB_ARD_O_BRDM2_HQ", "UK3CB_ARD_O_BRDM2_UM", "UK3CB_ARD_O_GAZ_Vodnik_Cannon", "UK3CB_ARD_O_GAZ_Vodnik_KVPT", "UK3CB_ARD_O_GAZ_Vodnik_PKT", "UK3CB_ARD_O_GAZ_Vodnik", "UK3CB_ARD_O_Hilux_GMG", "UK3CB_ARD_O_Hilux_Rocket_Arty", "UK3CB_ARD_O_Hilux_Closed", "UK3CB_ARD_O_Hilux_Dshkm", "UK3CB_ARD_O_Hilux_M2", "UK3CB_ARD_O_Hilux_Metis", "UK3CB_ARD_O_Hilux_Mortar", "UK3CB_ARD_O_Hilux_Open", "UK3CB_ARD_O_Hilux_Pkm", "UK3CB_ARD_O_Hilux_Rocket", "UK3CB_ARD_O_Hilux_Spg9", "UK3CB_ARD_O_Hilux_Zu23_Front", "UK3CB_ARD_O_Hilux_Zu23", "UK3CB_ARD_O_UAZ_AGS30", "UK3CB_ARD_O_UAZ_Closed", "UK3CB_ARD_O_UAZ_MG", "UK3CB_ARD_O_UAZ_Open", "UK3CB_ARD_O_UAZ_SPG9", "UK3CB_ARD_O_Ural", "UK3CB_ARD_O_Ural_Open", "UK3CB_ARD_O_YAVA", "UK3CB_ARD_O_Zil131_Covered", "UK3CB_ARD_O_Zil131_Open", "UK3CB_ARD_O_Zil131_Flatbed", "UK3CB_ARD_O_BMP1", "UK3CB_ARD_O_BMP2", "UK3CB_ARD_O_BMP2K", "UK3CB_ARD_O_BRM1K", "UK3CB_ARD_O_BTR40", "UK3CB_ARD_O_BTR40_MG", "UK3CB_ARD_O_BTR60", "UK3CB_ARD_O_BTR70", "UK3CB_ARD_O_BTR80", "UK3CB_ARD_O_BTR80a", "UK3CB_ARD_O_MTLB_Cannon", "UK3CB_ARD_O_MTLB_BMP", "UK3CB_ARD_O_MTLB_KPVT", "UK3CB_ARD_O_MTLB_PKT" ]; //-------- Ardistan Army Air opSouth_Air = [ "UK3CB_ARD_O_Mi_24P", "UK3CB_ARD_O_Mi_24V", "UK3CB_ARD_O_Mi8AMTSh" ]; }; if (_hostileForce == "Chernarussian Movement of the Red Star") then { //-------- Chernarussian Movement of the Red Star INFANTRY opSouth_INF = [ "UK3CB_CHD_O_TL", "UK3CB_CHD_O_AT", "UK3CB_CHD_O_AT_ASST", "UK3CB_CHD_O_RIF_1", "UK3CB_CHD_O_MK", "UK3CB_CHD_O_MG", "UK3CB_CHD_O_MG_ASST", "UK3CB_CHD_O_GL", "UK3CB_CHD_O_AR", "UK3CB_CHD_O_RIF_2" ]; //-------- Chernarussian Movement of the Red Star Vehicles opSouth_VEH = [ "UK3CB_CHD_O_BTR60", "UK3CB_CHD_O_MTLB_BMP", "UK3CB_CHD_O_MTLB_KPVT", "UK3CB_CHD_O_BRDM2", "UK3CB_CHD_O_Hilux_Dshkm", "UK3CB_CHD_O_Hilux_M2" ]; //-------- Chernarussian Movement of the Red Star Air opSouth_Air = [ "UK3CB_CHD_O_Mi8AMTSh" ]; }; if (_hostileForce == "Middle East Extremists") then { //-------- Middle East Extremists INFANTRY opSouth_INF = [ "UK3CB_MEE_O_TL", "UK3CB_MEE_O_AA", "UK3CB_MEE_O_AA_ASST", "UK3CB_MEE_O_RIF_1", "UK3CB_MEE_O_AT", "UK3CB_MEE_O_AT_ASST", "UK3CB_MEE_O_MK", "UK3CB_MEE_O_MG", "UK3CB_MEE_O_MG_ASST", "UK3CB_MEE_O_RIF_2", "UK3CB_MEE_O_LAT", "UK3CB_MEE_O_AR", "UK3CB_MEE_O_GL" ]; //-------- Middle East Extremists Vehicles opSouth_VEH = [ "UK3CB_MEE_O_BMP1", "UK3CB_MEE_O_BTR40", "UK3CB_MEE_O_BTR40_MG", "UK3CB_MEE_O_BTR60", "UK3CB_MEE_O_M113tank_M2", "UK3CB_MEE_O_M113tank_M2_90", "UK3CB_MEE_O_M113tank_MK19_90", "UK3CB_MEE_O_M113tank_M240", "UK3CB_MEE_O_MTLB_BMP", "UK3CB_MEE_O_MTLB_KPVT", "UK3CB_MEE_O_MTLB_PKT", "UK3CB_MEE_O_BRDM2", "UK3CB_MEE_O_BRDM2_ATGM", "UK3CB_MEE_O_BRDM2_HQ", "UK3CB_MEE_O_BRDM2_UM", "UK3CB_MEE_O_Datsun_Open", "UK3CB_MEE_O_Datsun_Pkm", "UK3CB_MEE_O_Hilux_Igla_Chair", "UK3CB_MEE_O_Hilux_GMG", "UK3CB_MEE_O_Hilux_Rocket_Arty", "UK3CB_MEE_O_Hilux_BMP", "UK3CB_MEE_O_Hilux_BTR", "UK3CB_MEE_O_Hilux_Dshkm", "UK3CB_MEE_O_Hilux_Vulcan_Front", "UK3CB_MEE_O_Hilux_M2", "UK3CB_MEE_O_Hilux_Metis", "UK3CB_MEE_O_Hilux_Open", "UK3CB_MEE_O_Hilux_Pkm", "UK3CB_MEE_O_Hilux_Rocket", "UK3CB_MEE_O_Hilux_Spg9", "UK3CB_MEE_O_Hilux_Zu23_Front", "UK3CB_MEE_O_Hilux_Zu23", "UK3CB_MEE_O_LR_Closed", "UK3CB_MEE_O_LR_AGS30", "UK3CB_MEE_O_LR_M2", "UK3CB_MEE_O_LR_Open", "UK3CB_MEE_O_LR_SPG9", "UK3CB_MEE_O_M1025_MK19", "UK3CB_MEE_O_M1025_M2", "UK3CB_MEE_O_M1025_TOW", "UK3CB_MEE_O_M1025_Unarmed", "UK3CB_MEE_O_M998_2DR", "UK3CB_MEE_O_M998_4DR", "UK3CB_MEE_O_Offroad", "UK3CB_MEE_O_Offroad_M2", "UK3CB_MEE_O_Offroad_AT", "UK3CB_MEE_O_Pickup", "UK3CB_MEE_O_Pickup_Igla_Chair", "UK3CB_MEE_O_Pickup_Rocket_Arty", "UK3CB_MEE_O_Pickup_DSHKM", "UK3CB_MEE_O_Pickup_GMG", "UK3CB_MEE_O_Pickup_M2", "UK3CB_MEE_O_Pickup_Metis", "UK3CB_MEE_O_Pickup_Rocket", "UK3CB_MEE_O_Pickup_SPG9", "UK3CB_MEE_O_Pickup_ZU23_Front", "UK3CB_MEE_O_Pickup_ZU23", "UK3CB_MEE_O_V3S_Closed", "UK3CB_MEE_O_V3S_Open", "UK3CB_MEE_O_Van_Transport" ]; //-------- Middle East Extremists Air opSouth_Air = [ "" ]; }; if (_hostileForce == "Goa'Uld") then { //-------- Goa'Uld INFANTRY opSouth_INF = [ "sga_jaffa_black", "sga_jaffa_black_leader", "sga_jaffa_black_serpent_guard_closed", "sga_jaffa_black_serpent_guard_open", "sga_jaffa_gold", "sga_jaffa_gold_leader", "sga_jaffa_gold_serpent_guard_closed", "sga_jaffa_gold_serpent_guard_open", "sga_jaffa", "sga_jaffa_leader", "sga_jaffa_serpent_guard_closed", "sga_jaffa_serpent_guard_open", "sga_jaffa_red", "sga_jaffa_red_leader", "sga_jaffa_red_serpent_guard_closed", "sga_jaffa_red_serpent_guard_open" ]; //-------- Goa'Uld Vehicles opSouth_VEH = [ "" ]; //-------- Goa'Uld Air opSouth_Air = [ "deathglider_normal" ]; }; closeDialog 0; while { opSouth_mode == 1 } do { waitUntil { { alive _x } count opSouth_hostileArray < 1; }; if ( level != maxLevel ) then { missionNamespace setVariable ["level", (level + 1), true]; for "_i" from 1 to level do { parsetext format ["<t color='#FF0000' size='1.2'>level %1</t>", level] remoteExec ["hint", 0]; _enemySpawnLocation = [opSouth, 500, 1000, 15] call BIS_fnc_findSafePos; _enemyAirSpawnLocation = [opSouth, 1000, 1500, 15] call BIS_fnc_findSafePos; _opSouthHostileGroup = createGroup [East, true]; for "_i" from 0 to 4 do { selectRandom opSouth_INF createUnit [_enemySpawnLocation, _opSouthHostileGroup]; }; opSouth_hostileArray = opSouth_hostileArray + (units _opSouthHostileGroup); [_opSouthHostileGroup, opSouth, 5] call CBA_fnc_taskAttack; }; for "_i" from 0 to (level/2) do { if (level > 3) then { opSouth_hostileVehicle = createVehicle [selectRandom opSouth_VEH, _enemySpawnLocation, [], 0, "NONE"]; opSouth_hostileVicArray = opSouth_hostileVicArray + [opSouth_hostileVehicle]; createVehicleCrew opSouth_hostileVehicle; opSouth_hostileArray = opSouth_hostileArray + (units opSouth_hostileVehicle); [opSouth_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; if (level > 6) then { opSouth_hostileVehicle = createVehicle [selectRandom opSouth_Air, _enemyAirSpawnLocation, [], 0, "FLY"]; opSouth_hostileVicArray = opSouth_hostileVicArray + [opSouth_hostileVehicle]; createVehicleCrew opSouth_hostileVehicle; opSouth_hostileArray = opSouth_hostileArray + (units opSouth_hostileVehicle); [opSouth_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; }; } else { missionNamespace setVariable ["opSouth_mode", 0, true]; parsetext format ["<t color='#FF0000' size='1.2'>Mission Complete</t>", level] remoteExec ["hint", 0]; hostileVicCount = count opSouth_hostileVicArray; {deleteVehicle _x} forEach opSouth_hostileArray; if (hostileVicCount > 0) then { {deleteVehicle _x} forEach crew opSouth_hostileVehicle; {deleteVehicle _x} forEach opSouth_hostileVicArray; }; missionNamespace setVariable ["level", 0, true]; missionNamespace setVariable ["opSouth_hostileArray", [], true]; missionNamespace setVariable ["opSouth_hostileVicArray", [], true]; }; }; }; }; DM_fnc_EndOpSouth = { if (opSouth_mode != 0) then { missionNamespace setVariable ["opSouth_mode", 0, true]; hostileVicCount = count opSouth_hostileVicArray; {deleteVehicle _x} forEach opSouth_hostileArray; if (hostileVicCount > 0) then { {deleteVehicle _x} forEach crew opSouth_hostileVehicle; {deleteVehicle _x} forEach opSouth_hostileVicArray; }; missionNamespace setVariable ["level", 0, true]; missionNamespace setVariable ["opSouth_hostileArray", [], true]; missionNamespace setVariable ["opSouth_hostileVicArray", [], true]; } else { hint "Select a faction to fight!"; }; }; createDialog "missionSelectDialog"; hostileListArray = [ "Ardistan Army", "Chernarussian Movement of the Red Star", "Middle East Extremists", "Goa'Uld" ]; { lbAdd [1500, _x]; } forEach hostileListArray; lbSetCurSel [1500, 0]; ctrlSetText [1600, "Start Tower Defense"]; buttonSetAction [1600, " [] spawn DM_fnc_StartOpSouthHostiles; "]; ctrlSetText [1601, "Reset"]; buttonSetAction [1601, " [] call DM_fnc_EndOpSouth; "]; This is my full script for a wave based mission that players are able to activate themselves when on the server. I have a few bugs to iron out but currently I have to run the script using []Spawn due to the waitUntil. Can anyone suggest a way around that please? Share this post Link to post Share on other sites
Larrow 2820 Posted June 30, 2023 Spoiler //Description.ext class CfgFunctions { class DM_OpSouth { tag = "DM"; class functions { file = "DM_OpSouth\functions"; class opSouth_init { postInit = 1; }; class opSouth_start {}; class opSouth_reset {}; class opSouth_spawnHostiles {}; class opSouth_end {}; class opSouth_showDisplay {}; }; }; }; //DM_OpSouth\functions\fn_opSouth_Init.sqf DM_opSouth_Factions = [ //Ardistan Army [ "Ardistan Army", //Infantry [ "UK3CB_ARD_O_AT", "UK3CB_ARD_O_AR", "UK3CB_ARD_O_DEM", "UK3CB_ARD_O_ENG", "UK3CB_ARD_O_GL", "UK3CB_ARD_O_STATIC_GUN_DSHKM", "UK3CB_ARD_O_STATIC_GUN_METIS", "UK3CB_ARD_O_STATIC_GUN_NSV", "UK3CB_ARD_O_STATIC_GUN_PKM", "UK3CB_ARD_O_STATIC_GUN_PODNOS", "UK3CB_ARD_O_STATIC_GUN_SPG9", "UK3CB_ARD_O_JNR_OFF", "UK3CB_ARD_O_LAT", "UK3CB_ARD_O_MG", "UK3CB_ARD_O_MK", "UK3CB_ARD_O_MD", "UK3CB_ARD_O_OFF", "UK3CB_ARD_O_RIF_1", "UK3CB_ARD_O_RIF_2", "UK3CB_ARD_O_SL", "UK3CB_ARD_O_SNI", "UK3CB_ARD_O_TL", "UK3CB_ARD_O_AA", "UK3CB_ARD_O_SF_AA", "UK3CB_ARD_O_SF_AT", "UK3CB_ARD_O_SF_AR", "UK3CB_ARD_O_SF_DEM", "UK3CB_ARD_O_SF_ENG", "UK3CB_ARD_O_SF_GL", "UK3CB_ARD_O_SF_LAT", "UK3CB_ARD_O_SF_MG", "UK3CB_ARD_O_SF_MK", "UK3CB_ARD_O_SF_MD", "UK3CB_ARD_O_SF_RIF_1", "UK3CB_ARD_O_SF_RIF_2", "UK3CB_ARD_O_SF_SL", "UK3CB_ARD_O_SF_SNI", "UK3CB_ARD_O_SF_SPOT", "UK3CB_ARD_O_SF_TL" ], //Vehicles [ "UK3CB_ARD_O_BRDM2", "UK3CB_ARD_O_BRDM2_ATGM", "UK3CB_ARD_O_BRDM2_HQ", "UK3CB_ARD_O_BRDM2_UM", "UK3CB_ARD_O_GAZ_Vodnik_Cannon", "UK3CB_ARD_O_GAZ_Vodnik_KVPT", "UK3CB_ARD_O_GAZ_Vodnik_PKT", "UK3CB_ARD_O_GAZ_Vodnik", "UK3CB_ARD_O_Hilux_GMG", "UK3CB_ARD_O_Hilux_Rocket_Arty", "UK3CB_ARD_O_Hilux_Closed", "UK3CB_ARD_O_Hilux_Dshkm", "UK3CB_ARD_O_Hilux_M2", "UK3CB_ARD_O_Hilux_Metis", "UK3CB_ARD_O_Hilux_Mortar", "UK3CB_ARD_O_Hilux_Open", "UK3CB_ARD_O_Hilux_Pkm", "UK3CB_ARD_O_Hilux_Rocket", "UK3CB_ARD_O_Hilux_Spg9", "UK3CB_ARD_O_Hilux_Zu23_Front", "UK3CB_ARD_O_Hilux_Zu23", "UK3CB_ARD_O_UAZ_AGS30", "UK3CB_ARD_O_UAZ_Closed", "UK3CB_ARD_O_UAZ_MG", "UK3CB_ARD_O_UAZ_Open", "UK3CB_ARD_O_UAZ_SPG9", "UK3CB_ARD_O_Ural", "UK3CB_ARD_O_Ural_Open", "UK3CB_ARD_O_YAVA", "UK3CB_ARD_O_Zil131_Covered", "UK3CB_ARD_O_Zil131_Open", "UK3CB_ARD_O_Zil131_Flatbed", "UK3CB_ARD_O_BMP1", "UK3CB_ARD_O_BMP2", "UK3CB_ARD_O_BMP2K", "UK3CB_ARD_O_BRM1K", "UK3CB_ARD_O_BTR40", "UK3CB_ARD_O_BTR40_MG", "UK3CB_ARD_O_BTR60", "UK3CB_ARD_O_BTR70", "UK3CB_ARD_O_BTR80", "UK3CB_ARD_O_BTR80a", "UK3CB_ARD_O_MTLB_Cannon", "UK3CB_ARD_O_MTLB_BMP", "UK3CB_ARD_O_MTLB_KPVT", "UK3CB_ARD_O_MTLB_PKT" ], //Air [ "UK3CB_ARD_O_Mi_24P", "UK3CB_ARD_O_Mi_24V", "UK3CB_ARD_O_Mi8AMTSh" ] ], //Chernarussian Movement of the Red Star [ "Chernarussian Movement of the Red Star", //Infantry [ "UK3CB_CHD_O_TL", "UK3CB_CHD_O_AT", "UK3CB_CHD_O_AT_ASST", "UK3CB_CHD_O_RIF_1", "UK3CB_CHD_O_MK", "UK3CB_CHD_O_MG", "UK3CB_CHD_O_MG_ASST", "UK3CB_CHD_O_GL", "UK3CB_CHD_O_AR", "UK3CB_CHD_O_RIF_2" ], //Vehicles [ "UK3CB_CHD_O_BTR60", "UK3CB_CHD_O_MTLB_BMP", "UK3CB_CHD_O_MTLB_KPVT", "UK3CB_CHD_O_BRDM2", "UK3CB_CHD_O_Hilux_Dshkm", "UK3CB_CHD_O_Hilux_M2" ], //Air [ "UK3CB_CHD_O_Mi8AMTSh" ] ], //Middle East Extremists [ "Middle East Extremists", //Infantry [ "UK3CB_MEE_O_TL", "UK3CB_MEE_O_AA", "UK3CB_MEE_O_AA_ASST", "UK3CB_MEE_O_RIF_1", "UK3CB_MEE_O_AT", "UK3CB_MEE_O_AT_ASST", "UK3CB_MEE_O_MK", "UK3CB_MEE_O_MG", "UK3CB_MEE_O_MG_ASST", "UK3CB_MEE_O_RIF_2", "UK3CB_MEE_O_LAT", "UK3CB_MEE_O_AR", "UK3CB_MEE_O_GL" ], //Vehicles [ "UK3CB_MEE_O_BMP1", "UK3CB_MEE_O_BTR40", "UK3CB_MEE_O_BTR40_MG", "UK3CB_MEE_O_BTR60", "UK3CB_MEE_O_M113tank_M2", "UK3CB_MEE_O_M113tank_M2_90", "UK3CB_MEE_O_M113tank_MK19_90", "UK3CB_MEE_O_M113tank_M240", "UK3CB_MEE_O_MTLB_BMP", "UK3CB_MEE_O_MTLB_KPVT", "UK3CB_MEE_O_MTLB_PKT", "UK3CB_MEE_O_BRDM2", "UK3CB_MEE_O_BRDM2_ATGM", "UK3CB_MEE_O_BRDM2_HQ", "UK3CB_MEE_O_BRDM2_UM", "UK3CB_MEE_O_Datsun_Open", "UK3CB_MEE_O_Datsun_Pkm", "UK3CB_MEE_O_Hilux_Igla_Chair", "UK3CB_MEE_O_Hilux_GMG", "UK3CB_MEE_O_Hilux_Rocket_Arty", "UK3CB_MEE_O_Hilux_BMP", "UK3CB_MEE_O_Hilux_BTR", "UK3CB_MEE_O_Hilux_Dshkm", "UK3CB_MEE_O_Hilux_Vulcan_Front", "UK3CB_MEE_O_Hilux_M2", "UK3CB_MEE_O_Hilux_Metis", "UK3CB_MEE_O_Hilux_Open", "UK3CB_MEE_O_Hilux_Pkm", "UK3CB_MEE_O_Hilux_Rocket", "UK3CB_MEE_O_Hilux_Spg9", "UK3CB_MEE_O_Hilux_Zu23_Front", "UK3CB_MEE_O_Hilux_Zu23", "UK3CB_MEE_O_LR_Closed", "UK3CB_MEE_O_LR_AGS30", "UK3CB_MEE_O_LR_M2", "UK3CB_MEE_O_LR_Open", "UK3CB_MEE_O_LR_SPG9", "UK3CB_MEE_O_M1025_MK19", "UK3CB_MEE_O_M1025_M2", "UK3CB_MEE_O_M1025_TOW", "UK3CB_MEE_O_M1025_Unarmed", "UK3CB_MEE_O_M998_2DR", "UK3CB_MEE_O_M998_4DR", "UK3CB_MEE_O_Offroad", "UK3CB_MEE_O_Offroad_M2", "UK3CB_MEE_O_Offroad_AT", "UK3CB_MEE_O_Pickup", "UK3CB_MEE_O_Pickup_Igla_Chair", "UK3CB_MEE_O_Pickup_Rocket_Arty", "UK3CB_MEE_O_Pickup_DSHKM", "UK3CB_MEE_O_Pickup_GMG", "UK3CB_MEE_O_Pickup_M2", "UK3CB_MEE_O_Pickup_Metis", "UK3CB_MEE_O_Pickup_Rocket", "UK3CB_MEE_O_Pickup_SPG9", "UK3CB_MEE_O_Pickup_ZU23_Front", "UK3CB_MEE_O_Pickup_ZU23", "UK3CB_MEE_O_V3S_Closed", "UK3CB_MEE_O_V3S_Open", "UK3CB_MEE_O_Van_Transport" ], //Air [ ] ], //Goa'Uld [ "Goa'Uld", //Infantry [ "sga_jaffa_black", "sga_jaffa_black_leader", "sga_jaffa_black_serpent_guard_closed", "sga_jaffa_black_serpent_guard_open", "sga_jaffa_gold", "sga_jaffa_gold_leader", "sga_jaffa_gold_serpent_guard_closed", "sga_jaffa_gold_serpent_guard_open", "sga_jaffa", "sga_jaffa_leader", "sga_jaffa_serpent_guard_closed", "sga_jaffa_serpent_guard_open", "sga_jaffa_red", "sga_jaffa_red_leader", "sga_jaffa_red_serpent_guard_closed", "sga_jaffa_red_serpent_guard_open" ], //Vehicles [ "sga_jaffa_black", "sga_jaffa_black_leader", "sga_jaffa_black_serpent_guard_closed", "sga_jaffa_black_serpent_guard_open", "sga_jaffa_gold", "sga_jaffa_gold_leader", "sga_jaffa_gold_serpent_guard_closed", "sga_jaffa_gold_serpent_guard_open", "sga_jaffa", "sga_jaffa_leader", "sga_jaffa_serpent_guard_closed", "sga_jaffa_serpent_guard_open", "sga_jaffa_red", "sga_jaffa_red_leader", "sga_jaffa_red_serpent_guard_closed", "sga_jaffa_red_serpent_guard_open" ], //Air [ "deathglider_normal" ] ] ]; if ( isServer ) then { [] call DM_fnc_opSouth_reset; }; //DM_OpSouth\functions\fn_opSouth_start.sqf params[ "_index" ]; _hostileCount = { !isNull _x && { alive _x } }count DM_opSouth_hostileArray; if ( _hostileCount == 0 ) then { format ["Spawning %1, please wait...", DM_opSouth_Factions select _index select 0 ] remoteExec[ "hint", remoteExecutedOwner ] [ _index ] call DM_fnc_opSouth_spawnHostiles; }else{ format[ "Hostiles Remaining, %1! \n\n If nobody is running this training scenario then reset Op South Hostiles first", _hostileCount ] remoteExec[ "hint", remoteExecutedOwner ]; }; //DM_OpSouth\functions\fn_opSouth_reset.sqf DM_opSouth_mode = 0; // opSouth_mode 0 = disabled, 1 = tower defence, 2 = tower attack DM_opSouth_level = 0; DM_opSouth_maxLevel = 10; DM_opSouth_currentFactionIndex = 0; DM_opSouth_hostileArray = []; DM_opSouth_hostileVicArray = []; //DM_OpSouth\functions\fn_opSouth_spawnHostiles.sqf params[ "_index" ]; DM_opSouth_currentFactionIndex = _index; DM_opSouth_Factions select DM_opSouth_currentFactionIndex params[ "_opSouth_factionName", "_opSouth_Inf", "_opSouth_Veh", "_opSouth_Air" ]; if ( DM_opSouth_level != DM_opSouth_maxLevel ) then { DM_opSouth_level = DM_opSouth_level + 1; for "_i" from 1 to DM_opSouth_level do { parseText format ["<t color='#FF0000' size='1.2'>level %1</t>", DM_opSouth_level] remoteExec ["hint", 0]; _enemySpawnLocation = [opSouth, 500, 1000, 15] call BIS_fnc_findSafePos; _enemyAirSpawnLocation = [opSouth, 1000, 1500, 15] call BIS_fnc_findSafePos; _opSouthHostileGroup = createGroup [east, true]; for "_i" from 0 to 4 do { selectRandom _opSouth_INF createUnit [_enemySpawnLocation, _opSouthHostileGroup]; }; DM_opSouth_hostileArray append units _opSouthHostileGroup; [_opSouthHostileGroup, opSouth, 5] call CBA_fnc_taskAttack; }; for "_i" from 0 to (level/2) do { if (DM_opSouth_level > 3) then { _hostileVehicle = createVehicle [selectRandom _opSouth_VEH, _enemySpawnLocation, [], 0, "NONE"]; DM_opSouth_hostileVicArray append [_hostileVehicle]; createVehicleCrew _hostileVehicle; opSouth_hostileArray append units _hostileVehicle; [_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; if (DM_opSouth_level > 6) then { _hostileVehicle = createVehicle [selectRandom _opSouth_Air, _enemyAirSpawnLocation, [], 0, "FLY"]; DM_opSouth_hostileVicArray append [_hostileVehicle]; createVehicleCrew _hostileVehicle; DM_opSouth_hostileArray append units _hostileVehicle; [_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; }; { _x addEventHandler[ "Killed", { if ( DM_opSouth_hostileArray findIf{ !isNull _x && { alive _x } } == -1 ) then { [ DM_opSouth_currentFactionIndex ] call DM_fnc_opSouth_spawnHostiles; }; }]; }forEach DM_opSouth_hostileArray; } else { parseText format ["<t color='#FF0000' size='1.2'>Mission Complete</t>", DM_opSouth_level] remoteExec ["hint", 0]; [] call DM_fnc_opSouth_end; }; //DM_OpSouth\functions\fn_opSouth_end.sqf { deleteVehicle _x }forEach DM_opSouth_hostileArray; { deleteVehicle _x }forEach DM_opSouth_hostileVicArray; [] call DM_fnc_opSouth_reset; //DM_OpSouth\functions\fn_opSouth_showDisplay.sqf _display = findDisplay 46 createDisplay "missionSelectDialog"; waitUntil{ !isNull _display }; _lb = _display displayCtrl 1500; { _x params[ "_factionName" ]; _lb lbAdd _factionName; }forEach DM_opSouth_Factions; _lb lbSetCurSel 0; _towerButton = _display displayCtrl 1600; _towerButton ctrlSetText "Start Tower Defense"; _towerButton ctrlAddEventHandler[ "ButtonUp", { params[ "_ctrl" ]; _display = ctrlParent _ctrl; _index = lbCurSel( _display displayCtrl 1500 ); [ _index ] remoteExec [ "DM_fnc_opSouth_start", 2 ]; ctrlParent _ctrl closeDisplay 1; }]; _resetButton = _display displayCtrl 1601; _resetButton ctrlSetText "Reset"; _resetButton ctrlAddEventHandler[ "ButtonUp", { params[ "_ctrl" ]; [] remoteExec [ "DM_fnc_opSouth_end", 2 ]; ctrlParent _ctrl closeDisplay 1; }]; Only gone through it very quickly but it should give you some things to think about... answering your initial question turning it into a server-authoritative system ...so not all clients need to know everything about the system's state. 2 Share this post Link to post Share on other sites
Dramacius 8 Posted July 3, 2023 On 6/30/2023 at 7:10 PM, Larrow said: Hide contents //Description.ext class CfgFunctions { class DM_OpSouth { tag = "DM"; class functions { file = "DM_OpSouth\functions"; class opSouth_init { postInit = 1; }; class opSouth_start {}; class opSouth_reset {}; class opSouth_spawnHostiles {}; class opSouth_end {}; class opSouth_showDisplay {}; }; }; }; //DM_OpSouth\functions\fn_opSouth_Init.sqf DM_opSouth_Factions = [ //Ardistan Army [ "Ardistan Army", //Infantry [ "UK3CB_ARD_O_AT", "UK3CB_ARD_O_AR", "UK3CB_ARD_O_DEM", "UK3CB_ARD_O_ENG", "UK3CB_ARD_O_GL", "UK3CB_ARD_O_STATIC_GUN_DSHKM", "UK3CB_ARD_O_STATIC_GUN_METIS", "UK3CB_ARD_O_STATIC_GUN_NSV", "UK3CB_ARD_O_STATIC_GUN_PKM", "UK3CB_ARD_O_STATIC_GUN_PODNOS", "UK3CB_ARD_O_STATIC_GUN_SPG9", "UK3CB_ARD_O_JNR_OFF", "UK3CB_ARD_O_LAT", "UK3CB_ARD_O_MG", "UK3CB_ARD_O_MK", "UK3CB_ARD_O_MD", "UK3CB_ARD_O_OFF", "UK3CB_ARD_O_RIF_1", "UK3CB_ARD_O_RIF_2", "UK3CB_ARD_O_SL", "UK3CB_ARD_O_SNI", "UK3CB_ARD_O_TL", "UK3CB_ARD_O_AA", "UK3CB_ARD_O_SF_AA", "UK3CB_ARD_O_SF_AT", "UK3CB_ARD_O_SF_AR", "UK3CB_ARD_O_SF_DEM", "UK3CB_ARD_O_SF_ENG", "UK3CB_ARD_O_SF_GL", "UK3CB_ARD_O_SF_LAT", "UK3CB_ARD_O_SF_MG", "UK3CB_ARD_O_SF_MK", "UK3CB_ARD_O_SF_MD", "UK3CB_ARD_O_SF_RIF_1", "UK3CB_ARD_O_SF_RIF_2", "UK3CB_ARD_O_SF_SL", "UK3CB_ARD_O_SF_SNI", "UK3CB_ARD_O_SF_SPOT", "UK3CB_ARD_O_SF_TL" ], //Vehicles [ "UK3CB_ARD_O_BRDM2", "UK3CB_ARD_O_BRDM2_ATGM", "UK3CB_ARD_O_BRDM2_HQ", "UK3CB_ARD_O_BRDM2_UM", "UK3CB_ARD_O_GAZ_Vodnik_Cannon", "UK3CB_ARD_O_GAZ_Vodnik_KVPT", "UK3CB_ARD_O_GAZ_Vodnik_PKT", "UK3CB_ARD_O_GAZ_Vodnik", "UK3CB_ARD_O_Hilux_GMG", "UK3CB_ARD_O_Hilux_Rocket_Arty", "UK3CB_ARD_O_Hilux_Closed", "UK3CB_ARD_O_Hilux_Dshkm", "UK3CB_ARD_O_Hilux_M2", "UK3CB_ARD_O_Hilux_Metis", "UK3CB_ARD_O_Hilux_Mortar", "UK3CB_ARD_O_Hilux_Open", "UK3CB_ARD_O_Hilux_Pkm", "UK3CB_ARD_O_Hilux_Rocket", "UK3CB_ARD_O_Hilux_Spg9", "UK3CB_ARD_O_Hilux_Zu23_Front", "UK3CB_ARD_O_Hilux_Zu23", "UK3CB_ARD_O_UAZ_AGS30", "UK3CB_ARD_O_UAZ_Closed", "UK3CB_ARD_O_UAZ_MG", "UK3CB_ARD_O_UAZ_Open", "UK3CB_ARD_O_UAZ_SPG9", "UK3CB_ARD_O_Ural", "UK3CB_ARD_O_Ural_Open", "UK3CB_ARD_O_YAVA", "UK3CB_ARD_O_Zil131_Covered", "UK3CB_ARD_O_Zil131_Open", "UK3CB_ARD_O_Zil131_Flatbed", "UK3CB_ARD_O_BMP1", "UK3CB_ARD_O_BMP2", "UK3CB_ARD_O_BMP2K", "UK3CB_ARD_O_BRM1K", "UK3CB_ARD_O_BTR40", "UK3CB_ARD_O_BTR40_MG", "UK3CB_ARD_O_BTR60", "UK3CB_ARD_O_BTR70", "UK3CB_ARD_O_BTR80", "UK3CB_ARD_O_BTR80a", "UK3CB_ARD_O_MTLB_Cannon", "UK3CB_ARD_O_MTLB_BMP", "UK3CB_ARD_O_MTLB_KPVT", "UK3CB_ARD_O_MTLB_PKT" ], //Air [ "UK3CB_ARD_O_Mi_24P", "UK3CB_ARD_O_Mi_24V", "UK3CB_ARD_O_Mi8AMTSh" ] ], //Chernarussian Movement of the Red Star [ "Chernarussian Movement of the Red Star", //Infantry [ "UK3CB_CHD_O_TL", "UK3CB_CHD_O_AT", "UK3CB_CHD_O_AT_ASST", "UK3CB_CHD_O_RIF_1", "UK3CB_CHD_O_MK", "UK3CB_CHD_O_MG", "UK3CB_CHD_O_MG_ASST", "UK3CB_CHD_O_GL", "UK3CB_CHD_O_AR", "UK3CB_CHD_O_RIF_2" ], //Vehicles [ "UK3CB_CHD_O_BTR60", "UK3CB_CHD_O_MTLB_BMP", "UK3CB_CHD_O_MTLB_KPVT", "UK3CB_CHD_O_BRDM2", "UK3CB_CHD_O_Hilux_Dshkm", "UK3CB_CHD_O_Hilux_M2" ], //Air [ "UK3CB_CHD_O_Mi8AMTSh" ] ], //Middle East Extremists [ "Middle East Extremists", //Infantry [ "UK3CB_MEE_O_TL", "UK3CB_MEE_O_AA", "UK3CB_MEE_O_AA_ASST", "UK3CB_MEE_O_RIF_1", "UK3CB_MEE_O_AT", "UK3CB_MEE_O_AT_ASST", "UK3CB_MEE_O_MK", "UK3CB_MEE_O_MG", "UK3CB_MEE_O_MG_ASST", "UK3CB_MEE_O_RIF_2", "UK3CB_MEE_O_LAT", "UK3CB_MEE_O_AR", "UK3CB_MEE_O_GL" ], //Vehicles [ "UK3CB_MEE_O_BMP1", "UK3CB_MEE_O_BTR40", "UK3CB_MEE_O_BTR40_MG", "UK3CB_MEE_O_BTR60", "UK3CB_MEE_O_M113tank_M2", "UK3CB_MEE_O_M113tank_M2_90", "UK3CB_MEE_O_M113tank_MK19_90", "UK3CB_MEE_O_M113tank_M240", "UK3CB_MEE_O_MTLB_BMP", "UK3CB_MEE_O_MTLB_KPVT", "UK3CB_MEE_O_MTLB_PKT", "UK3CB_MEE_O_BRDM2", "UK3CB_MEE_O_BRDM2_ATGM", "UK3CB_MEE_O_BRDM2_HQ", "UK3CB_MEE_O_BRDM2_UM", "UK3CB_MEE_O_Datsun_Open", "UK3CB_MEE_O_Datsun_Pkm", "UK3CB_MEE_O_Hilux_Igla_Chair", "UK3CB_MEE_O_Hilux_GMG", "UK3CB_MEE_O_Hilux_Rocket_Arty", "UK3CB_MEE_O_Hilux_BMP", "UK3CB_MEE_O_Hilux_BTR", "UK3CB_MEE_O_Hilux_Dshkm", "UK3CB_MEE_O_Hilux_Vulcan_Front", "UK3CB_MEE_O_Hilux_M2", "UK3CB_MEE_O_Hilux_Metis", "UK3CB_MEE_O_Hilux_Open", "UK3CB_MEE_O_Hilux_Pkm", "UK3CB_MEE_O_Hilux_Rocket", "UK3CB_MEE_O_Hilux_Spg9", "UK3CB_MEE_O_Hilux_Zu23_Front", "UK3CB_MEE_O_Hilux_Zu23", "UK3CB_MEE_O_LR_Closed", "UK3CB_MEE_O_LR_AGS30", "UK3CB_MEE_O_LR_M2", "UK3CB_MEE_O_LR_Open", "UK3CB_MEE_O_LR_SPG9", "UK3CB_MEE_O_M1025_MK19", "UK3CB_MEE_O_M1025_M2", "UK3CB_MEE_O_M1025_TOW", "UK3CB_MEE_O_M1025_Unarmed", "UK3CB_MEE_O_M998_2DR", "UK3CB_MEE_O_M998_4DR", "UK3CB_MEE_O_Offroad", "UK3CB_MEE_O_Offroad_M2", "UK3CB_MEE_O_Offroad_AT", "UK3CB_MEE_O_Pickup", "UK3CB_MEE_O_Pickup_Igla_Chair", "UK3CB_MEE_O_Pickup_Rocket_Arty", "UK3CB_MEE_O_Pickup_DSHKM", "UK3CB_MEE_O_Pickup_GMG", "UK3CB_MEE_O_Pickup_M2", "UK3CB_MEE_O_Pickup_Metis", "UK3CB_MEE_O_Pickup_Rocket", "UK3CB_MEE_O_Pickup_SPG9", "UK3CB_MEE_O_Pickup_ZU23_Front", "UK3CB_MEE_O_Pickup_ZU23", "UK3CB_MEE_O_V3S_Closed", "UK3CB_MEE_O_V3S_Open", "UK3CB_MEE_O_Van_Transport" ], //Air [ ] ], //Goa'Uld [ "Goa'Uld", //Infantry [ "sga_jaffa_black", "sga_jaffa_black_leader", "sga_jaffa_black_serpent_guard_closed", "sga_jaffa_black_serpent_guard_open", "sga_jaffa_gold", "sga_jaffa_gold_leader", "sga_jaffa_gold_serpent_guard_closed", "sga_jaffa_gold_serpent_guard_open", "sga_jaffa", "sga_jaffa_leader", "sga_jaffa_serpent_guard_closed", "sga_jaffa_serpent_guard_open", "sga_jaffa_red", "sga_jaffa_red_leader", "sga_jaffa_red_serpent_guard_closed", "sga_jaffa_red_serpent_guard_open" ], //Vehicles [ "sga_jaffa_black", "sga_jaffa_black_leader", "sga_jaffa_black_serpent_guard_closed", "sga_jaffa_black_serpent_guard_open", "sga_jaffa_gold", "sga_jaffa_gold_leader", "sga_jaffa_gold_serpent_guard_closed", "sga_jaffa_gold_serpent_guard_open", "sga_jaffa", "sga_jaffa_leader", "sga_jaffa_serpent_guard_closed", "sga_jaffa_serpent_guard_open", "sga_jaffa_red", "sga_jaffa_red_leader", "sga_jaffa_red_serpent_guard_closed", "sga_jaffa_red_serpent_guard_open" ], //Air [ "deathglider_normal" ] ] ]; if ( isServer ) then { [] call DM_fnc_opSouth_reset; }; //DM_OpSouth\functions\fn_opSouth_start.sqf params[ "_index" ]; _hostileCount = { !isNull _x && { alive _x } }count DM_opSouth_hostileArray; if ( _hostileCount == 0 ) then { format ["Spawning %1, please wait...", DM_opSouth_Factions select _index select 0 ] remoteExec[ "hint", remoteExecutedOwner ] [ _index ] call DM_fnc_opSouth_spawnHostiles; }else{ format[ "Hostiles Remaining, %1! \n\n If nobody is running this training scenario then reset Op South Hostiles first", _hostileCount ] remoteExec[ "hint", remoteExecutedOwner ]; }; //DM_OpSouth\functions\fn_opSouth_reset.sqf DM_opSouth_mode = 0; // opSouth_mode 0 = disabled, 1 = tower defence, 2 = tower attack DM_opSouth_level = 0; DM_opSouth_maxLevel = 10; DM_opSouth_currentFactionIndex = 0; DM_opSouth_hostileArray = []; DM_opSouth_hostileVicArray = []; //DM_OpSouth\functions\fn_opSouth_spawnHostiles.sqf params[ "_index" ]; DM_opSouth_currentFactionIndex = _index; DM_opSouth_Factions select DM_opSouth_currentFactionIndex params[ "_opSouth_factionName", "_opSouth_Inf", "_opSouth_Veh", "_opSouth_Air" ]; if ( DM_opSouth_level != DM_opSouth_maxLevel ) then { DM_opSouth_level = DM_opSouth_level + 1; for "_i" from 1 to DM_opSouth_level do { parseText format ["<t color='#FF0000' size='1.2'>level %1</t>", DM_opSouth_level] remoteExec ["hint", 0]; _enemySpawnLocation = [opSouth, 500, 1000, 15] call BIS_fnc_findSafePos; _enemyAirSpawnLocation = [opSouth, 1000, 1500, 15] call BIS_fnc_findSafePos; _opSouthHostileGroup = createGroup [east, true]; for "_i" from 0 to 4 do { selectRandom _opSouth_INF createUnit [_enemySpawnLocation, _opSouthHostileGroup]; }; DM_opSouth_hostileArray append units _opSouthHostileGroup; [_opSouthHostileGroup, opSouth, 5] call CBA_fnc_taskAttack; }; for "_i" from 0 to (level/2) do { if (DM_opSouth_level > 3) then { _hostileVehicle = createVehicle [selectRandom _opSouth_VEH, _enemySpawnLocation, [], 0, "NONE"]; DM_opSouth_hostileVicArray append [_hostileVehicle]; createVehicleCrew _hostileVehicle; opSouth_hostileArray append units _hostileVehicle; [_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; if (DM_opSouth_level > 6) then { _hostileVehicle = createVehicle [selectRandom _opSouth_Air, _enemyAirSpawnLocation, [], 0, "FLY"]; DM_opSouth_hostileVicArray append [_hostileVehicle]; createVehicleCrew _hostileVehicle; DM_opSouth_hostileArray append units _hostileVehicle; [_hostileVehicle, opSouth, 5] call CBA_fnc_taskAttack; }; }; { _x addEventHandler[ "Killed", { if ( DM_opSouth_hostileArray findIf{ !isNull _x && { alive _x } } == -1 ) then { [ DM_opSouth_currentFactionIndex ] call DM_fnc_opSouth_spawnHostiles; }; }]; }forEach DM_opSouth_hostileArray; } else { parseText format ["<t color='#FF0000' size='1.2'>Mission Complete</t>", DM_opSouth_level] remoteExec ["hint", 0]; [] call DM_fnc_opSouth_end; }; //DM_OpSouth\functions\fn_opSouth_end.sqf { deleteVehicle _x }forEach DM_opSouth_hostileArray; { deleteVehicle _x }forEach DM_opSouth_hostileVicArray; [] call DM_fnc_opSouth_reset; //DM_OpSouth\functions\fn_opSouth_showDisplay.sqf _display = findDisplay 46 createDisplay "missionSelectDialog"; waitUntil{ !isNull _display }; _lb = _display displayCtrl 1500; { _x params[ "_factionName" ]; _lb lbAdd _factionName; }forEach DM_opSouth_Factions; _lb lbSetCurSel 0; _towerButton = _display displayCtrl 1600; _towerButton ctrlSetText "Start Tower Defense"; _towerButton ctrlAddEventHandler[ "ButtonUp", { params[ "_ctrl" ]; _display = ctrlParent _ctrl; _index = lbCurSel( _display displayCtrl 1500 ); [ _index ] remoteExec [ "DM_fnc_opSouth_start", 2 ]; ctrlParent _ctrl closeDisplay 1; }]; _resetButton = _display displayCtrl 1601; _resetButton ctrlSetText "Reset"; _resetButton ctrlAddEventHandler[ "ButtonUp", { params[ "_ctrl" ]; [] remoteExec [ "DM_fnc_opSouth_end", 2 ]; ctrlParent _ctrl closeDisplay 1; }]; Only gone through it very quickly but it should give you some things to think about... answering your initial question turning it into a server-authoritative system ...so not all clients need to know everything about the system's state. Oh wow, thank you very much. I am still very early on in learning how to use functions and they still confuse me. I will take a look at implementing this over the next day or two. Stage two of this mission is to switch the hostiles that are alive to defend the base if there are no players within about 200m of the base requiring the players to respawn at a remote location then travel back to the base and retake control before the tower defense continues where it left off but I will work on implementing the above system first. Thank you again. Share this post Link to post Share on other sites
Dramacius 8 Posted July 4, 2023 @Larrow Hi, I really apprieciate what you did for me however when I press the dialog button nothing happens on any of them. This is my dialog code Spoiler class missionSelectDialog { idd = 1000; class controls { class IGUIBack_2200: IGUIBack { idc = 2200; x = 0.00199851 * safezoneW + safezoneX; y = 0.00159198 * safezoneH + safezoneY; w = 0.996003 * safezoneW; h = 0.996816 * safezoneH; colorBackground[] = {0,0,0,0.7}; colorActive[] = {0,0,0,0.7}; }; class MOUT_missionSelectFrame: RscFrame { idc = 1800; x = 0.411858 * safezoneW + safezoneX; y = 0.274306 * safezoneH + safezoneY; w = 0.176284 * safezoneW; h = 0.451388 * safezoneH; }; class MOUT_missionSelectList: RscListBox { idc = 1500; x = 0.416265 * safezoneW + safezoneX; y = 0.321325 * safezoneH + safezoneY; w = 0.16747 * safezoneW; h = 0.272714 * safezoneH; }; class MOUT_missionSelectStart: RscButton { idc = 1600; action = ""; text = ""; //--- ToDo: Localize; x = 0.416265 * safezoneW + safezoneX; y = 0.612847 * safezoneH + safezoneY; w = 0.16747 * safezoneW; h = 0.0470196 * safezoneH; colorBackground[] = {0,255,0,0.7}; }; class MOUT_ClearButton: RscButton { idc = 1601; action = ""; text = ""; //--- ToDo: Localize; x = 0.416265 * safezoneW + safezoneX; y = 0.669271 * safezoneH + safezoneY; w = 0.16747 * safezoneW; h = 0.0470196 * safezoneH; colorBackground[] = {255,0,0,0.7}; }; class MOUT_missionSelectHeader: RscText { idc = 1001; text = "Home World Security"; //--- ToDo: Localize; x = 0.416265 * safezoneW + safezoneX; y = 0.28371 * safezoneH + safezoneY; w = 0.145434 * safezoneW; h = 0.0282118 * safezoneH; }; class MOUT_missionSelectClose: RscButton { idc = 1602; text = "X"; //--- ToDo: Localize; action = "closedialog 1;" x = 0.566106 * safezoneW + safezoneX; y = 0.28371 * safezoneH + safezoneY; w = 0.0176284 * safezoneW; h = 0.0282118 * safezoneH; }; }; }; Share this post Link to post Share on other sites
Larrow 2820 Posted July 8, 2023 Think I've quashed most of the mistakes, but should suffice as an example. DOWNLOAD 1 Share this post Link to post Share on other sites
Dramacius 8 Posted July 9, 2023 On 7/8/2023 at 7:53 PM, Larrow said: Think I've quashed most of the mistakes, but should suffice as an example. DOWNLOAD Thank you loads, I will take a look at this tomorrow and see about getting it implemented and what I can learn to improve my understanding of SQF. I am still baffled by params[] but hopefully I can learn how that works soon. Share this post Link to post Share on other sites
Larrow 2820 Posted July 10, 2023 18 hours ago, Dramacius said: I am still baffled by params[] Nothing mysterious about params, it basically makes private variables out of the contents of an array. So you have likely done this before... [ player, "someText", 10, getPosATL player ] call TAG_fnc_someFunction; TAG_fnc_someFunction = { _player = _this select 0; _someText = _this select 1; _aNumber = _this select 2; _playerPos = _this select 3; }; ...which is the same as doing... TAG_fnc_someFunction = { params[ "_player", "_someText", "_aNumber", "_playerPos" ]; }; ...if there is no array prior to the params command then it defaults to using _this, which is the default variable in Arma that holds the parameters passed to a function. params also makes the variables private, so it is actually equivalent to... TAG_fnc_someFunction = { private _player = _this select 0; private _someText = _this select 1; private _aNumber = _this select 2; private _playerPos = _this select 3; }; ...then you can make params do error checking for you by stating what the variable will default to if missing or of incorrect type and what type the variable must be e.g STRING, OBJECT, ARRAY etc and if it is an ARRAY how many indices it can have... TAG_fnc_someFunction = { params[ //[ Variable, default, allowed types, array size ] //Variable _player, will default to objNull, must be of type OBJECT [ "_player", objNull, [ objNull ] ], //Variable _someText, will default to "", must be of type STRING [ "_someText", "", [ "" ] ], //Variable _aNumber, will default to 0, must be of type NUMBER [ "_aNumber", 0, [ 0 ] ], //Variable _playerPos, will default to [0,0,0], must be of type array, array can be 2 or 3 in length( position 2D or 3D ) [ "_playerPos", [0,0,0], [ [] ], [ 2, 3 ] ] ]; }; ...you can also state multiple types for the variable as well. Let's say you wanted a function that would return a 3D position for you but could take many different types, in arma we have objects, markers, locations, groups and of course an array that could be 2D or 3D... TAG_fnc_getPosition3D = { // vv all the different types we will allow this variable to be passed params[ [ "_theThing", [0,0,0], [ "", objNull, locationNull, grpNull, [] ], [ 2, 3 ] ] ]; private _position3D = switch ( true ) do { //STRING a marker name case ( _theThing isEqualType "" ) : { getMarkerPos _theThing; }; //OBJECT case ( _theThing isEqualType objNull ) : { getPosATL _theThing; }; //LOCATION case ( _theThing isEqualType locationNull ) : { locationPosition _theThing; }; //GROUP case ( _theThing isEqualType grpNull ) : { getPosATL leader _theThing; }; //ARRAY case ( _theThing isEqualType [] ) : { if ( count _theThing == 2 ) then { _theThing append[ 0 ]; }; _theThing }; }; _position3D }; ...of course, there should be more error checking in there. For example, make sure the STRING is not empty or the GROUP/OBJECT is not null but for clarity, I have left all that out. You will notice in your script that have used params to pull the correct info from your faction data, heres some commented code that explains the concept... Spoiler TAG_fnc_spawnGroup = { params[ [ "_side", east, [ east ] ], //must be passed a side [ "_position", [0,0,0], [ [] ], [ 3 ] ] //must be passed a 3D position ]; //Lets error check the position to make sure the array contains numbers if !( _position isEqualTypeAll 0 ) exitWith { //If not then display error showing passed contents format[ "The array must contain a 3D position: %1", _position ] call BIS_fnc_error; }; _data = [ // [ number of soldiers, array of soldier types ] //East [ 3, [ "O_Soldier_F" ] ], //West [ 2, [ "B_Soldier_F" ] ], //Indep [ 4, [ "I_Soldier_F" ] ] ]; //BIS_fnc_sideID enumerates sides as East = 0, West = 1, Indep = 3 _sideIndex = _side call BIS_fnc_sideID; //Get data for the correct side _sideData = _data select _sideIndex; //If side was West, _sideIndex will be 1, so _sideData will be [ 2, [ "B_Soldier_F" ] ] //Make variables from _sideData _sideData params[ "_numUnits", "_unitTypes" ]; //If side was West, _numUnits will be 2 and _unitTypes will be [ "B_Soldier_F" ] //OR the above as just one line // _data select ( _side call BIS_fnc_sideID ) params[ "_numUnits", "_unitTypes" ]; //Spawn group _group = createGroup[ _side, true ]; for "_i" from 1 to _numUnits do { _type = selectRandom _unitTypes; _unit = _group createUnit[ _type, _position, [], 0, "FORM" ]; }; _group }; 1 Share this post Link to post Share on other sites