Seger Posted May 8, 2016 Share Posted May 8, 2016 (edited) Hey guys, can someone help me fix my code? I'm the tech manager on a modded I&A server and we recently switched over from CUP to RHS. I tried to modify the weapon restrictions file to include RHS weapons, but it doesn't work. The spawn protection and the whitelist for vanilla arma 3 weapons doesn't work either. I did the same thing with CUP and it worked fine, but this doesn't seem to work. I've read through the code multiple times looking for any syntax errors but I haven't found any. Is it possible that spelling a classname wrong would cause it to not work completely? Thanks! /* Author: Quiksilver Last modified: 5/6/2016 ArmA 1.32 by Seger Description: Restricts certain weapon systems to different roles _________________________________________________*/ private ["_opticsAllowed","_specialisedOptics","_optics","_basePos","_firstRun","_insideSafezone","_outsideSafezone"]; #define AT_MSG "Only AT Soldiers may use this weapon system. Launcher removed." #define SNIPER_MSG "Only Snipers may use this weapon system. Sniper rifle removed." #define AUTOTUR_MSG "You are not allowed to use this weapon system, Backpack removed." #define UAV_MSG "Only UAV operator may use this Item, UAV terminal removed." #define OPTICS_MSG "Thermal optics such as TWS and Nightstalker are restricted to Squad Leaders. Optic removed." #define MG_MSG "Only Autoriflemen may use this weapon system. LMG removed." #define SOPT_MSG "SOS and LRPS are designated for Snipers and Spotters only. Optic removed." #define MRK_MSG "Only Marksman and Spotters may use this weapon system. Rifle removed." //===== UAV TERMINAL _uavOperator = ["B_soldier_UAV_F","B_officer_F","rhsusf_army_ocp_uav"]; _uavRestricted = ["B_UavTerminal","O_UavTerminal","I_UavTerminal"]; //===== AT / MISSILE LAUNCHERS (excl RPG) _missileSoldiers = ["B_soldier_LAT_F","B_soldier_AA_F","B_soldier_AT_F","B_officer_F","B_recon_LAT_F","rhsusf_army_ocp_javelin","rhsusf_usmc_marpat_d_javelin"]; _missileSpecialised = ["launch_NLAW_F","launch_B_Titan_F","launch_O_Titan_F","launch_I_Titan_F","launch_B_Titan_short_F","launch_O_Titan_short_F","launch_I_Titan_short_F","rhs_weap_fgm148","launch_RPG32_F","rhs_weap_fim92","rhs_weap_smaw","rhs_weap_smaw_green","rhs_weap_igla","rhs_weap_rpg7"]; //===== SNIPER RIFLES _snipers = ["B_sniper_F","B_officer_F","rhsusf_usmc_marpat_d_sniper"]; _sniperSpecialised = ["srifle_GM6_F","srifle_GM6_LRPS_F","srifle_GM6_SOS_F","srifle_LRR_F","srifle_LRR_LRPS_F","srifle_LRR_SOS_F","srifle_GM6_camo_F","srifle_GM6_camo_LRPS_F","srifle_GM6_camo_SOS_F","srifle_LRR_camo_F","srifle_LRR_camo_LRPS_F","srifle_LRR_camo_SOS_F","rhs_weap_XM2010","rhs_weap_XM2010_d","rhs_weap_XM2010_sa","rhs_weap_XM2010_wd"]; //===== THERMAL OPTICS _opticsAllowed = ["B_Soldier_SL_F","rhsusf_army_ocp_teamleader","rhsusf_army_ocp_squadleader","rhsusf_usmc_lar_marpat_d_teamleader"]; _specialisedOptics = ["optic_Nightstalker","optic_tws","optic_tws_mg"]; //===== BACKPACKS _backpackRestricted = ["O_Mortar_01_support_F","I_Mortar_01_support_F","O_Mortar_01_weapon_F","I_Mortar_01_weapon_F","O_UAV_01_backpack_F","I_UAV_01_backpack_F","O_HMG_01_support_F","I_HMG_01_support_F","O_HMG_01_support_high_F","I_HMG_01_support_high_F","O_HMG_01_weapon_F","I_HMG_01_weapon_F","O_HMG_01_A_weapon_F","I_HMG_01_A_weapon_F","O_GMG_01_weapon_F","I_GMG_01_weapon_F","O_GMG_01_A_weapon_F","I_GMG_01_A_weapon_F","O_HMG_01_high_weapon_F","I_HMG_01_high_weapon_F","O_HMG_01_A_high_weapon_F","I_HMG_01_A_high_weapon_F","O_GMG_01_high_weapon_F","I_GMG_01_high_weapon_F","O_GMG_01_A_high_weapon_F","I_GMG_01_A_high_weapon_F","I_AT_01_weapon_F","O_AT_01_weapon_F","I_AA_01_weapon_F","O_AA_01_weapon_F"]; //===== LMG _autoRiflemen = ["B_soldier_AR_F","B_officer_F","rhsusf_army_ocp_autorifleman"]; _autoSpecialised = ["MMG_02_black_F","MMG_02_camo_F","MMG_02_sand_F","MMG_02_black_RCO_BI_F","MMG_02_sand_RCO_LP_F","MMG_01_base_F","MMG_01_hex_F","MMG_01_hex_ARCO_LP_F","MMG_01_tan_F","rhs_weap_m240B","rhs_weap_m240B_CAP","rhs_weap_m240G","rhs_weap_m249_pip_L","rhs_weap_m249_pip_L_para","rhs_weap_m249_pip_L_vfg","rhs_weap_m249_pip_S","rhs_weap_m249_pip_S_para","rhs_weap_m249_pip_S_vfg","rhs_weap_pkm","rhs_weap_pkp"]; //===== SNIPER OPTICS _sniperTeam = ["B_sniper_F","B_spotter_F","rhsusf_usmc_marpat_d_spotter","rhsusf_usmc_marpat_d_sniper"]; _sniperOpt = ["optic_SOS","optic_LRPS"]; //===== MARKSMAN _marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F","rhsusf_usmc_marpat_d_spotter","rhsusf_army_ocp_marksman","rhsusf_usmc_lar_marpat_d_marksman","rhsusf_usmc_marpat_d_sniper"]; _marksmanGun = ["srifle_DMR_02_ACO_F","srifle_DMR_02_ARCO_F","srifle_DMR_02_camo_AMS_LP_F","srifle_DMR_02_DMS_F","srifle_DMR_02_MRCO_F","srifle_DMR_02_sniper_AMS_LP_S_F","srifle_DMR_02_F","srifle_DMR_02_camo_F","srifle_DMR_02_sniper_F","srifle_DMR_02_SOS_F","srifle_DMR_03_ACO_F","srifle_DMR_03_AMS_F","srifle_DMR_03_ARCO_F","srifle_DMR_03_DMS_F","srifle_DMR_03_DMS_snds_F","srifle_DMR_03_MRCO_F","srifle_DMR_03_SOS_F","srifle_DMR_03_tan_AMS_LP_F","srifle_DMR_03_F","srifle_DMR_03_khaki_F","srifle_DMR_03_multicam_F","srifle_DMR_03_tan_F","srifle_DMR_03_woodland_F","srifle_DMR_04_ACO_F","srifle_DMR_04_ARCO_F","srifle_DMR_04_DMS_F","srifle_DMR_05_ACO_F","srifle_DMR_05_ARCO_F","srifle_DMR_05_DMS_F","srifle_DMR_05_DMS_snds_F","srifle_DMR_05_KHS_LP_F","srifle_DMR_05_MRCO_F","srifle_DMR_05_SOS_F","srifle_DMR_05_blk_F","srifle_DMR_05_hex_F","srifle_DMR_05_tan_f","srifle_DMR_06_camo_F","srifle_DMR_06_camo_khs_F", "srifle_DMR_06_olive_F","rhs_weap_m14ebrri","rhs_weap_sr25","rhs_weap_sr25_ec","rhs_weap_svdp","rhs_weap_svdp_npz","rhs_weap_svdp_wd","rhs_weap_svdp_wd_npz","rhs_weap_svds","rhs_weap_svds_npz"]; _basePos = getMarkerPos "respawn_west"; _szmkr = getMarkerPos "safezone_marker"; #define SZ_RADIUS 300 _EHFIRED = { deleteVehicle (_this select 6); hintC "You are discharging your weapon at base without approval. Cease your actions Immediately!"; hintC_EH = findDisplay 57 displayAddEventHandler ["unload", { 0 = _this spawn { _this select 0 displayRemoveEventHandler ["unload", hintC_EH]; hintSilent ""; }; }]; }; _firstRun = TRUE; if (_firstRun) then { _firstRun = FALSE; if ((player distance _szmkr) <= SZ_RADIUS) then { _insideSafezone = TRUE; _outsideSafezone = FALSE; EHFIRED = player addEventHandler ["Fired",_EHFIRED]; } else { _outsideSafezone = TRUE; _insideSafezone = FALSE; }; }; restrict_Thermal = false; restrict_LMG = false; restrict_sOptics = false; restrict_Marksman = false; if (PARAMS_rThermal != 0) then {restrict_Thermal = true;}; if (PARAMS_rLMG != 0) then {restrict_LMG = true;}; if (PARAMS_rSOptics != 0) then {restrict_sOptics = true;}; if (PARAMS_rMarksman != 0) then {restrict_Marksman = true;}; while {true} do { //------------------------------------- Launchers if (({player hasWeapon _x} count _missileSpecialised) > 0) then { if (({player isKindOf _x} count _missileSoldiers) < 1) then { player removeWeapon (secondaryWeapon player); titleText [AT_MSG,"PLAIN",3]; }; }; sleep 1; //------------------------------------- Sniper Rifles if (({player hasWeapon _x} count _sniperSpecialised) > 0) then { if (({player isKindOf _x} count _snipers) < 1) then { player removeWeapon (primaryWeapon player); titleText [sNIPER_MSG,"PLAIN",3]; }; }; sleep 1; //------------------------------------- UAV _assignedItems = assignedItems player; if (({"B_UavTerminal" == _x} count _assignedItems) > 0) then { if (({player isKindOf _x} count _uavOperator) < 1) then { player unassignItem "B_UavTerminal"; player removeItem "B_UavTerminal"; titleText [uAV_MSG,"PLAIN",3]; }; }; sleep 1; //------------------------------------- Thermal optics if (restrict_Thermal) then { _optics = primaryWeaponItems player; if (({_x in _optics} count _specialisedOptics) > 0) then { if (({player isKindOf _x} count _opticsAllowed) < 1) then { {player removePrimaryWeaponItem _x;} count _specialisedOptics; titleText [OPTICS_MSG,"PLAIN",3]; }; }; sleep 1; }; //------------------------------------- sniper optics if (restrict_sOptics) then { _optics = primaryWeaponItems player; if (({_x in _optics} count _sniperOpt) > 0) then { if (({player isKindOf _x} count _sniperTeam) < 1) then { {player removePrimaryWeaponItem _x;} count _sniperOpt; titleText [sOPT_MSG,"PLAIN",3]; }; }; sleep 1; }; //------------------------------------- LMG if (restrict_LMG) then { if (({player hasWeapon _x} count _autoSpecialised) > 0) then { if (({player isKindOf _x} count _autoRiflemen) < 1) then { player removeWeapon (primaryWeapon player); titleText [MG_MSG,"PLAIN",3]; }; }; sleep 1; }; //------------------------------------- Marksman if (restrict_Marksman) then { if (({player hasWeapon _x} count _marksmanGun) > 0) then { if (({player isKindOf _x} count _marksman) < 1) then { player removeWeapon (primaryWeapon player); titleText [MRK_MSG,"PLAIN",3]; }; }; sleep 1; }; //------------------------------------- Opfor turret backpacks if ((backpack player) in _backpackRestricted) then { removeBackpack player; titleText [AUTOTUR_MSG, 3 "PLAIN",]; }; //===================================== SAFE ZONE MANAGER _szmkr = getMarkerPos "safezone_marker"; if (_insideSafezone) then { if ((player distance _szmkr) > SZ_RADIUS) then { _insideSafezone = FALSE; _outsideSafezone = TRUE; player removeEventHandler ["Fired",EHFIRED]; }; }; sleep 2; if (_outsideSafezone) then { if ((player distance _szmkr) < SZ_RADIUS) then { _outsideSafezone = FALSE; _insideSafezone = TRUE; EHFIRED = player addEventHandler ["Fired",_EHFIRED]; }; }; //----- Sleep _basePos = getMarkerPos "respawn_west"; if ((player distance _basePos) <= 500) then { sleep 1; } else { sleep 20; }; }; Edited May 13, 2016 by PERO Added spoiler to shorten the post Link to comment Share on other sites More sharing options...
PERO Posted May 13, 2016 Share Posted May 13, 2016 If the safe zone and vanilla restriction dont work either, sounds like a typo to me. Try redoing it or really go from entry to entry and compare it to the original file. Link to comment Share on other sites More sharing options...
Seger Posted May 14, 2016 Author Share Posted May 14, 2016 So could spelling a classname wrong mess it up? Link to comment Share on other sites More sharing options...
PERO Posted May 15, 2016 Share Posted May 15, 2016 Yes or a missing ; or " somewhere, most likely the 2nd part. Link to comment Share on other sites More sharing options...
Seger Posted May 16, 2016 Author Share Posted May 16, 2016 Ok I'll try that and see if it fixes it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now