private void Rearm() { bool usePrefixPistolModel = SettingsIni.GetValueBool("UsePrefixPistolModel", "WorldSettings", false); Weapon PrimaryWeapon1, PrimaryWeapon2, PrefixPistol = new Weapon(); int PrimaryAmmo1, PrimaryAmmo2, PistolAmmo; try { switch ((Weapon)Enum.Parse(typeof(Weapon), SettingsIni.GetValueString("PrimaryWeapon1", "WorldSettings"), true)) { // Default (when no value is present), then cases // Handles SMG, Rifles, Sniper Rifles, and Heavy Weapons // Runs on Episodic Check default: PrimaryWeapon1 = Weapon.SMG_MP5; break; case Weapon.Rifle_AK47: PrimaryWeapon1 = Weapon.Rifle_AK47; break; case Weapon.Rifle_M4: PrimaryWeapon1 = Weapon.Rifle_M4; break; case Weapon.TBOGT_AdvancedMG: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon1 = Weapon.TBOGT_AdvancedMG; // M249 } else { PrimaryWeapon1 = Weapon.Rifle_M4; } break; case Weapon.TBOGT_AdvancedSniper: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon1 = Weapon.TBOGT_AdvancedSniper; // DSR-1 } else { PrimaryWeapon1 = Weapon.SniperRifle_M40A1; } break; case Weapon.SMG_MP5: PrimaryWeapon1 = Weapon.SMG_MP5; break; case Weapon.SniperRifle_Basic: PrimaryWeapon1 = Weapon.SniperRifle_Basic; break; case Weapon.SniperRifle_M40A1: PrimaryWeapon1 = Weapon.SniperRifle_M40A1; break; case Weapon.Heavy_RocketLauncher: PrimaryWeapon1 = Weapon.Heavy_RocketLauncher; break; case Weapon.TBOGT_AssaultSMG: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon1 = Weapon.TBOGT_AssaultSMG; // P90 } else { PrimaryWeapon1 = Weapon.SMG_MP5; } break; case (Weapon)21: // HK69A1 40mm (this is, however, assigned in Rifle class if using My Realistic WeaponInfo v5) if (currentGameEpPlatform == GameEpisode.TLAD) { PrimaryWeapon1 = Weapon.TLAD_GrenadeLauncher; } else if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon1 = Weapon.TBOGT_GrenadeLauncher; } else { PrimaryWeapon1 = Weapon.Heavy_RocketLauncher; // Defaulted to the Rocket Launcher if you are using vanilla WeaponInfo } break; } switch ((Weapon)Enum.Parse(typeof(Weapon), SettingsIni.GetValueString("PrimaryWeapon2", "WorldSettings"), true)) { default: PrimaryWeapon2 = Weapon.Shotgun_Baretta; break; case Weapon.Shotgun_Baretta: PrimaryWeapon2 = Weapon.Shotgun_Baretta; break; case Weapon.Shotgun_Basic: PrimaryWeapon2 = Weapon.Shotgun_Basic; break; case Weapon.TBOGT_ExplosiveShotgun: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon2 = Weapon.TBOGT_ExplosiveShotgun; // AA-12 12ga Frag-12 } else { PrimaryWeapon2 = Weapon.Shotgun_Baretta; } break; case Weapon.TBOGT_NormalShotgun: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrimaryWeapon2 = Weapon.TBOGT_NormalShotgun; // AA-12 Shotgun } else { PrimaryWeapon2 = Weapon.Shotgun_Baretta; } break; case Weapon.TLAD_AssaultShotgun: if (currentGameEpPlatform == GameEpisode.TLAD) { PrimaryWeapon2 = Weapon.TLAD_AssaultShotgun; // Striker } else { PrimaryWeapon2 = Weapon.Shotgun_Baretta; } break; case Weapon.TLAD_SawedOffShotgun: if (currentGameEpPlatform == GameEpisode.TLAD) { PrimaryWeapon2 = Weapon.TLAD_SawedOffShotgun; // Lupara? } else { PrimaryWeapon2 = Weapon.Shotgun_Basic; } break; } } catch (Exception ex) { Log.Error("Error on getting weapon data: " + ex, this); return; } try { // Get ammo counts (if empty will be defaulted to original clip size based on My Realistic Weapon Mod v5) // First Primary Weapon will be categorized for its weapon type (Heavy Weapons will have ammo set to 3, regardless of settings made) if (PrimaryWeapon1 == Weapon.Heavy_RocketLauncher || PrimaryWeapon1 == (Weapon)21) { PrimaryAmmo1 = 3; } else { PrimaryAmmo1 = SettingsIni.GetValueInteger("PrimaryAmmo1", "WorldSettings", 30); } PrimaryAmmo2 = SettingsIni.GetValueInteger("PrimaryAmmo2", "WorldSettings", 8); PistolAmmo = SettingsIni.GetValueInteger("PistolAmmo", "WorldSettings", 15); } catch (Exception ex) { Log.Error("Error on getting weapon ammunition data: " + ex, this); return; } // Checks if the prefix pistol model value returned true if (usePrefixPistolModel) { try { switch ((Weapon)Enum.Parse(typeof(Weapon), SettingsIni.GetValueString("PrefixPistolModel", "WorldSettings"), true)) { default: PrefixPistol = Weapon.Handgun_Glock; break; case Weapon.Handgun_Glock: PrefixPistol = Weapon.Handgun_Glock; break; case Weapon.Handgun_DesertEagle: PrefixPistol = Weapon.Handgun_DesertEagle; break; case Weapon.TLAD_Automatic9mm: if (currentGameEpPlatform == GameEpisode.TLAD) { PrefixPistol = Weapon.TLAD_Automatic9mm; // CZ75-Auto } else { PrefixPistol = Weapon.Handgun_Glock; } break; case Weapon.TBOGT_Pistol44: if (currentGameEpPlatform == GameEpisode.TBOGT) { PrefixPistol = Weapon.TBOGT_Pistol44; // SA Auto .44 } else { PrefixPistol = Weapon.Handgun_DesertEagle; } break; } } catch (Exception ex) { Log.Error("Error on getting weapon data: " + ex, this); return; } } try { // First primary depend on the weapon slot LPlayer.LocalPlayer.Ped.Weapons.FromType(PrimaryWeapon1).Ammo += PrimaryAmmo1; // Second primary have their own slot: Shotguns LPlayer.LocalPlayer.Ped.Weapons.FromType(PrimaryWeapon2).Ammo += PrimaryAmmo2; // Secondary is pistol if (usePrefixPistolModel) { LPlayer.LocalPlayer.Ped.Weapons.FromType(PrefixPistol).Ammo += PistolAmmo; } else if (LPlayer.LocalPlayer.Ped.Weapons.inSlot(WeaponSlot.Handgun) == null) { LPlayer.LocalPlayer.Ped.Weapons.Glock.Ammo = PistolAmmo; } else { LPlayer.LocalPlayer.Ped.Weapons.inSlot(WeaponSlot.Handgun).Ammo += PistolAmmo; } // Free Grenades! (If you have other throwables, it'll be added) if (LPlayer.LocalPlayer.Ped.Weapons.inSlot(WeaponSlot.Thrown) == null) { LPlayer.LocalPlayer.Ped.Weapons.Grenades.Ammo = 3; } else { LPlayer.LocalPlayer.Ped.Weapons.inSlot(WeaponSlot.Thrown).Ammo += 3; } } catch (Exception ex) { Log.Error("Cannot apply weapons to player: " + ex, this); Functions.PrintText("Cannot apply weapons to player, check LCPDFR.log for errors", 3000); } }