schadler17 36 Posted November 16, 2015 Made this a while ago but never got around to using it. Could be useful for some. Assigns loadouts to a player based on their classname. Feel free to do with it as you please. Call for it in initPlayerLocal.sqf: [player] execVM "defaultGear.sqf"; defaultGear.sqf: // Player Loadouts Via Classnames // Written by Schadler.C private ["_unit", "_type", "_side"]; _unit = _this select 0; _type = (typeOf _unit); _side = (side _unit); // Remove Starting Items removeallWeapons _unit; removeAllAssignedItems _unit; removeBackpack _unit; // Common Items _unit addWeapon "ItemMap"; _unit addWeapon "ItemCompass"; _unit addWeapon "ItemWatch"; _unit addItem "FirstAidKit"; // Start Gear Assignment switch (_side) do { // Blufor Loadout case west: { // Common WEST Gear _unit addWeapon "NVGoggles"; // Common Ammo/Items/etc here if needed. switch (_type) do { // Commander case "rhsusf_usmc_marpat_d_officer": { // Backpack/Radio _unit addBackpack "tf_rt1523g_big_rhs"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "optic_Hamr"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["SmokeShellRed", 1]; _unit addMagazines ["SmokeShellOrange", 1]; _unit addMagazines ["SmokeShellBlue", 1]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "ItemGPS"; _unit linkItem "tf_anprc152"; _unit addWeapon "Laserdesignator"; _unit addMagazine "LaserBatteries"; }; // Squad Leader case "rhsusf_usmc_marpat_d_squadleader": { // Backpack/Radio _unit addBackpack "tf_rt1523g_big_rhs"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "optic_Hamr"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["SmokeShellRed", 1]; _unit addMagazines ["SmokeShellOrange", 1]; _unit addMagazines ["SmokeShellBlue", 1]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "ItemGPS"; _unit linkItem "tf_anprc152"; _unit addWeapon "Laserdesignator"; _unit addMagazine "LaserBatteries"; }; // Team Leader case "rhsusf_usmc_marpat_d_teamleader": { // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit addWeapon "Binocular"; _unit linkItem "tf_anprc152"; }; // UAV Operator case "rhsusf_usmc_marpat_d_uav": { // Backpack/Radio _unit addBackpack "tf_rt1523g_big_rhs"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["SmokeShellRed", 1]; _unit addMagazines ["SmokeShellOrange", 1]; _unit addMagazines ["SmokeShellBlue", 1]; // Items _unit linkItem "B_UavTerminal"; _unit linkItem "tf_anprc152"; }; // Rifleman case "rhsusf_usmc_marpat_d_rifleman": { // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "optic_Hamr"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit addWeapon "Binocular"; _unit linkItem "tf_anprc152"; }; // Medic case "rhsusf_usmc_marpat_d_rifleman_light": { // Backpack _unit addBackpack "B_kitbag_rgr"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["SmokeShell", 8]; _unit addMagazines ["rhs_mag_m67", 2]; // Items _unit linkItem "tf_anprc152"; (unitbackpack _unit) addItemCargoGlobal ["FirstAidKit", 15]; _unit addItem "Medikit"; _unit addWeapon "Binocular"; }; // Grenadier case "rhsusf_usmc_marpat_d_grenadier": { // Weapons _unit addWeapon "rhs_weap_m4a1_m320"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["rhs_mag_M441_HE", 8]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Combat Engineer case "rhsusf_usmc_marpat_d_engineer": { // Backpack _unit addBackpack "B_kitbag_rgr"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["DemoCharge_Remote_Mag", 5]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; _unit linkItem "MineDetector"; }; // Light MG case "rhsusf_usmc_marpat_d_autorifleman_m249": { // Backpack _unit addBackpack "B_Kitbag_rgr"; // Weapons _unit addWeapon "rhs_weap_m249_pip_L"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; // Ammo _unit addMagazines ["rhsusf_100Rnd_556x45_soft_pouch", 6]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Heavy MG case "rhsusf_usmc_marpat_d_machinegunner": { // Backpack _unit addBackpack "B_Kitbag_rgr"; // Weapons _unit addWeapon ""; _unit addPrimaryWeaponItem ""; // Ammo _unit addMagazines ["", 0]; _unit addMagazines ["rhs_mag_m67", 0]; _unit addMagazines ["SmokeShell", 0]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Light AT case "rhsusf_usmc_marpat_d_riflemanat": { // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; _unit addWeapon "rhs_weap_M136"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["rhs_m136_mag", 1]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Heavy AT case "rhsusf_usmc_marpat_d_javelin": { // Backpack _unit addBackpack "B_Kitbag_rgr"; // Weapons _unit addWeapon "rhs_weap_m4a1_grip"; _unit addPrimaryWeaponItem "rhsusf_acc_SFMB556"; _unit addPrimaryWeaponItem "rhsusf_acc_compm4"; _unit addWeapon "rhs_weap_fgm148"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red", 2]; _unit addMagazines ["rhs_fgm148_Magazines_AT", 2]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Marksman case "rhsusf_usmc_marpat_d_marksman": { // Weapons _unit addWeapon "rhs_weap_m14ebrri_leu"; _unit addPrimaryWeaponItem "rhsusf_acc_LEUPOLDMK4"; // Ammo _unit addMagazines ["rhsusf_20Rnd_762x51_m118_special_Mag", 8]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; }; // Sniper case "rhsusf_usmc_marpat_d_sniper": { // Remove Default Uniform removeUniform _unit; removeGoggles _unit; removeVest _unit; removeHeadgear _unit; removeAllAssignedItems _unit; // Uniform _unit addUniform "U_B_GhillieSuit"; _unit addHeadgear "rhs_Booniehat_marpatwd"; _unit addVest "rhsusf_spc_marksman"; // Weapons _unit addWeapon "rhs_weap_XM2010"; _unit addPrimaryWeaponItem "rhsusf_acc_LEUPOLDMK4_2"; _unit addPrimaryWeaponItem "rhsusf_acc_harris_bipod"; // Ammo _unit addMagazines ["rhsusf_5Rnd_300winmag_xm2010", 10]; _unit addMagazines ["rhs_mag_m67", 2]; _unit addMagazines ["SmokeShell", 2]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Rangefinder"; }; // Crewman case "rhsusf_usmc_marpat_d_crewman": { // Weapons _unit addWeapon "rhs_weap_m4a1"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["SmokeShell", 2]; _unit addMagazines ["SmokeShellRed", 1]; _unit addMagazines ["SmokeShellOrange", 1]; _unit addMagazines ["SmokeShellBlue", 1]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; _unit linkItem "ItemGPS"; }; // Heli Pilot case "rhsusf_usmc_marpat_d_helipilot": { // Parachute _unit addBackpack "B_Parachute"; // Weapons _unit addWeapon "rhs_weap_m4a1"; // Ammo _unit addMagazines ["rhs_mag_30Rnd_556x45_M855A1_Stanag", 5]; _unit addMagazines ["SmokeShell", 2]; _unit addMagazines ["SmokeShellRed", 1]; _unit addMagazines ["SmokeShellOrange", 1]; _unit addMagazines ["SmokeShellBlue", 1]; // Items _unit linkItem "tf_anprc152"; _unit addWeapon "Binocular"; _unit linkItem "ItemGPS"; }; // Default default {/*Default Loadout or Error Message*/}; }; }; // Opfor Loadout case east: { /* EAST LOADOUT HERE! */ }; case guer: { /* RESISTANCE LOADOUT HERE! */ }; case civ: { /* CIV LOADOUT HERE! */ }; }; Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 Thank you! I found this very useful! Is that script is right? Edit: I tested it now and the "B_officer_F" units are completely "naked". private ["_unit", "_type", "_side"]; _unit = _this select 0; _type = (typeOf _unit); _side = (side _unit); // Remove Starting Items removeAllWeapons _unit; removeAllItems _unit; removeAllAssignedItems _unit; removeUniform _unit; removeVest _unit; removeBackpack _unit; removeHeadgear _unit; removeGoggles _unit; // Common Items _unit addWeapon "ItemMap"; _unit addWeapon "ItemCompass"; _unit addWeapon "ItemWatch"; _unit linkItem "tf_anprc152"; _unit addItemToUniform "ACE_EarPlugs"; for "_i" from 1 to 3 do {_unit addItemToUniform "ACE_fieldDressing";}; // Start Gear Assignment switch (_side) do { // Blufor Loadout case west: { // Common WEST Gear _unit forceAddUniform "***"; _unit unassignItem "NVGoggles"; // Common Ammo/Items/etc here if needed. switch (_type) do { //Officer case "B_officer_F": { //Uniform/Vest/Headgear & etc. _unit addVest "***"; _unit addHeadgear "***"; // Weapons _unit addWeapon "RH_M16A2"; _unit addWeapon "hgun_Rook40_F"; // Ammo for "_i" from 1 to 3 do {_unit addItemToUniform "16Rnd_9x21_Mag";}; for "_i" from 1 to 4 do {_unit addItemToVest "RH_30Rnd_556x45_M855A1";}; for "_i" from 1 to 3 do {_unit addItemToVest "HandGrenade";}; for "_i" from 1 to 2 do {_unit addItemToVest "Chemlight_red";}; for "_i" from 1 to 3 do {_unit addItemToVest "rhs_mag_mk84";}; for "_i" from 1 to 2 do {_unit addItemToVest "SmokeShell";}; }; Share this post Link to post Share on other sites
spidypiet 17 Posted November 17, 2015 check _unit forceAddUniform "***"; Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 check _unit forceAddUniform "***"; It's not like this in my script. I did it here because I don't want to publish the uniform I'm using :) Share this post Link to post Share on other sites
schadler17 36 Posted November 17, 2015 Just make sure the classname is correct for your uniform. Are the other items being added? Weapons/assignedItems? Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 Just make sure the classname is correct for your uniform. Are the other items being added? Weapons/assignedItems? No, he has nothing. No vest, Helmet , Weapon, nothing. Share this post Link to post Share on other sites
davidoss 552 Posted November 17, 2015 It's not like this in my script. I did it here because I don't want to publish the uniform I'm using :) I wonder what is the reason of keeping it as secret? :D Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 I wonder what is the reason of keeping it as secret? :D Well, hm it's about the mission and I don't want the mission to publish until its done XD But first I need to make the script working. Do you know why it's not working? :( EDIT: I just made it working. I missed three brrackets semicolon at the end of the script >< Share this post Link to post Share on other sites
davidoss 552 Posted November 17, 2015 Well you have naked unit because you have remove all clothes and not given any other wear back to the unit. Or if i can be more specified... You do not want fallow our hints, thats the reason. Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 Well you have naked unit because you have remove all clothes and not given any other wear back to the unit. Or if i can be more specified... You do not want fallow our hints, thats the reason. see my edit :) Share this post Link to post Share on other sites
davidoss 552 Posted November 17, 2015 Are you sure? Lets play a game. Lets say you have even complete your brackets. I am the game engine and i read your script and execute in cascade type like arma does. private ["_unit", "_type", "_side"]; _unit = _this select 0; _type = (typeOf _unit); _side = (side _unit); :) Affirmative!! // Remove Starting Items removeAllWeapons _unit; removeAllItems _unit; removeAllAssignedItems _unit; removeUniform _unit; removeVest _unit; removeBackpack _unit; removeHeadgear _unit; removeGoggles _unit; Ok! can do this. :) DONE! // Common Items _unit addWeapon "ItemMap"; _unit addWeapon "ItemCompass"; _unit addWeapon "ItemWatch"; _unit linkItem "tf_anprc152"; _unit addItemToUniform "ACE_EarPlugs"; for "_i" from 1 to 3 do {_unit addItemToUniform "ACE_fieldDressing";}; :blink: Cant do this!! This _unit has no container.. Where i should put the ACE_EarPlugs? :wacko: Maybe in ears right away? :( Oh no _unit has no ears!. Oh.. there are more, the "ACE_fieldDressing", what? addItemToUniform? _unit has no uniform it was removed from unit before. GAME OVER Share this post Link to post Share on other sites
schadler17 36 Posted November 17, 2015 Yeah thats why as you see in all of my classname cases, I add the Uniform/Vests/Clothing(Backpacks in my case cause I was using default uniforms/vests). Then the weapons, then magazines, then assigned Items. Can't add items to a player when he has nowhere to add them too. Only issue is there will be no magazines loaded into the player's weapon, but really, its not an issue. Prevents players from accidentally firing on mission-startup (incase they're alt tabbed when it starts) To fix that, do: _unit addPrimaryWeaponItem "MagazineClassname"; But yeah, all brackets are needed to finish the script. Use Notepad++ and enable script errors on startup for the game and it shoulda told you that from the beginning. Share this post Link to post Share on other sites
AdirB 18 Posted November 17, 2015 Yeah thats why as you see in all of my classname cases, I add the Uniform/Vests/Clothing(Backpacks in my case cause I was using default uniforms/vests). Then the weapons, then magazines, then assigned Items. Can't add items to a player when he has nowhere to add them too. Only issue is there will be no magazines loaded into the player's weapon, but really, its not an issue. Prevents players from accidentally firing on mission-startup (incase they're alt tabbed when it starts) To fix that, do: _unit addPrimaryWeaponItem "MagazineClassname"; But yeah, all brackets are needed to finish the script. Use Notepad++ and enable script errors on startup for the game and it shoulda told you that from the beginning. Ok thanks. About the weapon, I noticed this, I prefer to leave it like that because the mission starts in a base, and weapon not suppose not be loaded. Share this post Link to post Share on other sites
schadler17 36 Posted November 17, 2015 Ok thanks. About the weapon, I noticed this, I prefer to leave it like that because the mission starts in a base, and weapon not suppose not be loaded. https://forums.bistudio.com/topic/185212-safezone-loop/ That might also be useful for you. Share this post Link to post Share on other sites