Dramacius 8 Posted July 16, 2023 hey guys, I have found I can allow connections to my server using UID (or more to the point disallow players from joining if they're Steam ID is not in an allowed list. I am sure there is a way of doing other things with it so I have been expermenting with the following idea. I have a nested array of players that includes player name, UID, and a couple of other settings I would like to set when a player joins the server. I use ace so would like to be able to set the Medical, Engineering and EOD perms through this system. players = [ [ "76561198001748042", // Dungeon Master 0, // Medical (0 = none, 1 = Combat Medic, 2 = Doctor) 0, // Engineer (0 = no, 1 = yes) 0 // EOD (0 = no, 1 = yes) ] ]; allowedPlayers = pushBack players (select 0 in each of the sub arrays); // I don't know how to get the position 0 of a sub array and can't find anything on google to explain it. I would like to have these settings set when a player connects so in initPlayerLocal.sqf I need to put the following codes _player = [player name, getplayerUID player]; _name = _player select 0; _uid = _player select 1; _medic = players (each nested array select 1); // I don't know how to do this and the same for engineer and EOD _engineer = players (each nested array select 2); _eod = players (each nested array select 3); if (_uid !in allowedPlayers) then { endMission 3; } else { if (_medic == 1) then { _this setVariable ["ace_medical_medicClass",1,true]; }; if (_medic == 2) then { _this setVariable ["ace_medical_medicClass",2,true]; }; if (_engineer == 1) then { _this setVariable ["ACE_IsEngineer",1,true]; }; if (_EOD == 1) then { _this setVariable ["ACE_isEOD",1,true]; }; Share this post Link to post Share on other sites
pierremgi 4862 Posted July 16, 2023 Try something like: (I modified some variables) DRA_players = [[ "76561198001748042",0,1,1,1] ,[ "76561198001748043",2,1,1,1]]; private _allowedPlayers = DRA_players apply {_x#0}; private _player = [name player, getplayerUID player]; _player params ["_name","_uid"]; if !(_uid in _allowedPlayers) exitWith {endMission "END3"}; private _playerData = DRA_players select (DRA_players find {_x#0 == "_uid"}); _playerData params ["_uid","_medic","_engineer","_eod"]; if (_medic >0) then { player setVariable ["ace_medical_medicClass",_medic,true]}; if (_engineer == 1) then { player setVariable ["ACE_IsEngineer",1,true]}; if (_eod == 1) then { player setVariable ["ACE_isEOD",1,true]}; 2 Share this post Link to post Share on other sites
Harzach 2517 Posted July 16, 2023 *edit* - @pierremgi has provided a nice, concise version ^^^ Iterate through your array "players," pushing back the first nested element: allowedPlayers = []; { allowedPlayers pushBack (_x #0); } forEach players; private _player = [player name, getplayerUID player]; private _name = _player #0; private _uid = _player #1; if (_uid !in allowedPlayers) then { // need to check this before we look for UID in "players" else error endMission 3; } else { private _index = players find _uid; // returns index of element that contains UID private _element = players #_index; private _medic = _element #1; private _engineer = _element #2; private _eod = _element #3; if (_medic == 1) then { _this setVariable ["ace_medical_medicClass",1,true]; }; if (_medic == 2) then { _this setVariable ["ace_medical_medicClass",2,true]; }; if (_engineer == 1) then { _this setVariable ["ACE_IsEngineer",1,true]; }; if (_EOD == 1) then { _this setVariable ["ACE_isEOD",1,true]; }; 1 Share this post Link to post Share on other sites
Dramacius 8 Posted July 16, 2023 thank you guys, both your codes look great and I will try them tomorrow. Share this post Link to post Share on other sites
Dramacius 8 Posted July 17, 2023 hey guys. thanks again for all your help. I have got the majority of this working so far I think however I have added some additional sections. The two problems I am having now is no matter what I set my "Role" as selection 5 of the _allPlayers sub array it always loads the "commander.sqf" script and the second issue is the _this setUnitRank _rank; command is not working it keeps giving me an error saying Type Array expected Object or something similar to that. This is the whole code that runs in initPlayerLocal.sqf Spoiler // UID, Medical (0 = none, 1 = Combat Medic, 2 = Doctor), Engineer (0 = no, 1 = yes), EOD (0 = no, 1 = yes), Rank ("PRIVATE" · "CORPORAL" · "SERGEANT" · "LIEUTENANT" · "CAPTAIN" · "MAJOR" · "COLONEL"), Role ("Commander", "PlatoonLead", "SquadLead", "Rifleman") private _allPlayers = [ [ "myUID", 0, 0, 0, "COLONEL", "rifleman" ], // me [ "aDifferentUID", 0, 0, 0, "COLONEL", "commander" ] // Someone Else ]; private _allowedPlayers = []; { _allowedPlayers pushBack (_x #0); } forEach _allPlayers; private _player = [name player, getplayerUID player]; private _name = _player #0; private _uid = _player #1; if !(_uid in _allowedPlayers) then { // need to check this before we look for UID in "players" else error endMission 3; } else { private _index = DM_allPlayers apply {_x #0 } find _uid; // returns index of element that contains UID private _element = _allPlayers #_index; private _medic = _element #1; private _engineer = _element #2; private _eod = _element #3; private _rank = _element #4; private _role = _element #5; if (_medic == 1) then { _this setVariable ["ace_medical_medicClass",1,true]; }; if (_medic == 2) then { _this setVariable ["ace_medical_medicClass",2,true]; }; if (_engineer == 1) then { _this setVariable ["ACE_IsEngineer",1,true]; }; if (_EOD == 1) then { _this setVariable ["ACE_isEOD",1,true]; }; // _this setUnitRank _rank; execVM format ["DM_Scripts\DM_Loudouts\%1.sqf", _role]; }; I these loadouts stored in seperate SQF files Spoiler commander.sqf Spoiler comment "Exported from Arsenal by Dungeon Master"; comment "[!] UNIT MUST BE LOCAL [!]"; if (!local player) exitWith {}; comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; comment "Add weapons"; player addWeapon "arifle_SPAR_01_blk_F"; player addPrimaryWeaponItem "acc_pointer_IR"; player addPrimaryWeaponItem "optic_Aco"; player addPrimaryWeaponItem "30Rnd_556x45_Stanag"; player addWeapon "hgun_P07_blk_F"; player addHandgunItem "16Rnd_9x21_yellow_Mag"; comment "Add containers"; player forceAddUniform "U_B_CombatUniform_mcam"; player addVest "V_PlateCarrier2_rgr"; player addBackpack "B_Kitbag_mcamo"; comment "Add binoculars"; player addWeapon "ACE_Vector"; comment "Add items to containers"; player addItemToUniform "FirstAidKit"; for "_i" from 1 to 2 do {player addItemToUniform "ACE_CableTie";}; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ItemcTabHCam"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_Flashlight_XL50"; player addItemToVest "ACE_Canteen"; for "_i" from 1 to 2 do {player addItemToVest "ACE_IR_Strobe_Item";}; player addItemToVest "ACE_MapTools"; player addItemToVest "ItemMicroDAGR"; for "_i" from 1 to 8 do {player addItemToVest "30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {player addItemToVest "16Rnd_9x21_yellow_Mag";}; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; for "_i" from 1 to 2 do {player addItemToVest "ACE_CTS9";}; for "_i" from 1 to 6 do {player addItemToVest "ACE_Chemlight_HiGreen";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_elasticBandage";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_quikclot";}; player addItemToBackpack "ACE_EntrenchingTool"; player addItemToBackpack "ACE_Fortify"; player addItemToBackpack "kka3_ace_extension_Land_Camping_Light_off_F"; for "_i" from 1 to 2 do {player addItemToBackpack "ACE_MRE_BeefStew";}; player addItemToBackpack "ACE_SpareBarrel_Item"; for "_i" from 1 to 4 do {player addItemToBackpack "ACE_tourniquet";}; player addHeadgear "H_HelmetB_desert"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "ACE_Altimeter"; player linkItem "TFAR_anprc152"; player linkItem "ACE_NVG_Gen1_Brown"; platoonLead.sqf Spoiler comment "Exported from Arsenal by Dungeon Master"; comment "[!] UNIT MUST BE LOCAL [!]"; if (!local player) exitWith {}; comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; comment "Add weapons"; player addWeapon "arifle_SPAR_01_blk_F"; player addPrimaryWeaponItem "acc_pointer_IR"; player addPrimaryWeaponItem "optic_Aco"; player addPrimaryWeaponItem "30Rnd_556x45_Stanag"; player addWeapon "hgun_P07_blk_F"; player addHandgunItem "16Rnd_9x21_yellow_Mag"; comment "Add containers"; player forceAddUniform "U_B_CombatUniform_mcam"; player addVest "V_PlateCarrier2_rgr"; player addBackpack "B_Kitbag_mcamo"; comment "Add binoculars"; player addWeapon "ACE_Vector"; comment "Add items to containers"; player addItemToUniform "FirstAidKit"; for "_i" from 1 to 2 do {player addItemToUniform "ACE_CableTie";}; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ItemcTabHCam"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_Flashlight_XL50"; player addItemToVest "ACE_Canteen"; for "_i" from 1 to 2 do {player addItemToVest "ACE_IR_Strobe_Item";}; player addItemToVest "ACE_MapTools"; player addItemToVest "ItemMicroDAGR"; for "_i" from 1 to 8 do {player addItemToVest "30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {player addItemToVest "16Rnd_9x21_yellow_Mag";}; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; for "_i" from 1 to 2 do {player addItemToVest "ACE_CTS9";}; for "_i" from 1 to 6 do {player addItemToVest "ACE_Chemlight_HiGreen";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_elasticBandage";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_quikclot";}; player addItemToBackpack "ACE_EntrenchingTool"; player addItemToBackpack "ACE_Fortify"; player addItemToBackpack "kka3_ace_extension_Land_Camping_Light_off_F"; for "_i" from 1 to 2 do {player addItemToBackpack "ACE_MRE_BeefStew";}; player addItemToBackpack "ACE_SpareBarrel_Item"; for "_i" from 1 to 4 do {player addItemToBackpack "ACE_tourniquet";}; player addHeadgear "H_HelmetB_desert"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "ACE_Altimeter"; player linkItem "TFAR_anprc152"; player linkItem "ACE_NVG_Gen1_Brown"; squadLead.sqf Spoiler comment "Exported from Arsenal by Dungeon Master"; comment "[!] UNIT MUST BE LOCAL [!]"; if (!local player) exitWith {}; comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; comment "Add weapons"; player addWeapon "arifle_SPAR_01_blk_F"; player addPrimaryWeaponItem "acc_pointer_IR"; player addPrimaryWeaponItem "optic_Aco"; player addPrimaryWeaponItem "30Rnd_556x45_Stanag"; player addWeapon "hgun_P07_blk_F"; player addHandgunItem "16Rnd_9x21_yellow_Mag"; comment "Add containers"; player forceAddUniform "U_B_CombatUniform_mcam"; player addVest "V_PlateCarrier2_rgr"; player addBackpack "TFAR_rt1523g_black"; comment "Add binoculars"; player addWeapon "ACE_Vector"; comment "Add items to containers"; player addItemToUniform "FirstAidKit"; for "_i" from 1 to 2 do {player addItemToUniform "ACE_CableTie";}; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ItemcTabHCam"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_Flashlight_XL50"; player addItemToVest "ACE_Canteen"; for "_i" from 1 to 2 do {player addItemToVest "ACE_IR_Strobe_Item";}; player addItemToVest "ACE_MapTools"; player addItemToVest "ItemAndroid"; for "_i" from 1 to 6 do {player addItemToVest "30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {player addItemToVest "16Rnd_9x21_yellow_Mag";}; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; for "_i" from 1 to 2 do {player addItemToVest "ACE_CTS9";}; for "_i" from 1 to 6 do {player addItemToVest "ACE_Chemlight_HiGreen";}; player addHeadgear "H_HelmetB_desert"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "ACE_Altimeter"; player linkItem "TFAR_anprc152"; player linkItem "ACE_NVG_Gen1_Brown"; rifleman.sqf Spoiler comment "Exported from Arsenal by Dungeon Master"; comment "[!] UNIT MUST BE LOCAL [!]"; if (!local player) exitWith {}; comment "Remove existing items"; removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; comment "Add weapons"; player addWeapon "arifle_SPAR_01_blk_F"; player addPrimaryWeaponItem "acc_pointer_IR"; player addPrimaryWeaponItem "optic_Aco"; player addPrimaryWeaponItem "30Rnd_556x45_Stanag"; player addWeapon "hgun_P07_blk_F"; player addHandgunItem "16Rnd_9x21_yellow_Mag"; comment "Add containers"; player forceAddUniform "U_B_CombatUniform_mcam"; player addVest "V_PlateCarrier2_rgr"; player addBackpack "B_Kitbag_mcamo"; comment "Add binoculars"; player addWeapon "ACE_Vector"; comment "Add items to containers"; player addItemToUniform "FirstAidKit"; for "_i" from 1 to 2 do {player addItemToUniform "ACE_CableTie";}; player addItemToUniform "ACE_EarPlugs"; player addItemToUniform "ItemcTabHCam"; player addItemToUniform "ACE_Flashlight_MX991"; player addItemToUniform "ACE_Flashlight_XL50"; player addItemToVest "ACE_Canteen"; for "_i" from 1 to 2 do {player addItemToVest "ACE_IR_Strobe_Item";}; player addItemToVest "ACE_MapTools"; player addItemToVest "ItemMicroDAGR"; for "_i" from 1 to 8 do {player addItemToVest "30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {player addItemToVest "16Rnd_9x21_yellow_Mag";}; for "_i" from 1 to 2 do {player addItemToVest "SmokeShell";}; for "_i" from 1 to 2 do {player addItemToVest "HandGrenade";}; for "_i" from 1 to 2 do {player addItemToVest "ACE_CTS9";}; for "_i" from 1 to 6 do {player addItemToVest "ACE_Chemlight_HiGreen";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_elasticBandage";}; for "_i" from 1 to 10 do {player addItemToBackpack "ACE_quikclot";}; player addItemToBackpack "ACE_EntrenchingTool"; player addItemToBackpack "ACE_Fortify"; player addItemToBackpack "kka3_ace_extension_Land_Camping_Light_off_F"; for "_i" from 1 to 2 do {player addItemToBackpack "ACE_MRE_BeefStew";}; player addItemToBackpack "ACE_SpareBarrel_Item"; for "_i" from 1 to 4 do {player addItemToBackpack "ACE_tourniquet";}; player addHeadgear "H_HelmetB_desert"; comment "Add items"; player linkItem "ItemMap"; player linkItem "ItemCompass"; player linkItem "ACE_Altimeter"; player linkItem "TFAR_anprc152"; player linkItem "ACE_NVG_Gen1_Brown"; Solved by changing private _index = DM_allPlayers find _uid; to private _index = DM_allPlayers apply {_x #0 } find _uid; Share this post Link to post Share on other sites
Dramacius 8 Posted July 17, 2023 New task related to this. I want to extend the controls so that players create or join a specified group when they connect Group names are Spartan, Alpha, Hotel, Apollo, Artemis, Hades and Hydra. I want them to set the Squad Leader to highest ranking member unless someone has joined with the role SquadLead. Is this possible? Share this post Link to post Share on other sites