private async void LoadWeapons()
        {
            await LocalSession.UpdateData("Character.Inventory");

            if (Client.Get <JobHandler>().OnDutyAsJob(JobType.EMS | JobType.Police))
            {
                return;
            }

            var playerInv     = new PlayerInventory(LocalSession.GetGlobalData("Character.Inventory", ""), LocalSession);
            var playerWeapons = playerInv.InventoryItems.FindAll(o => o.itemCode.Contains("WEAPON_"));
            var playerPed     = Game.PlayerPed;

            playerPed.Weapons.RemoveAll();
            playerWeapons.ForEach(o =>
            {
                var weaponHash = (WeaponHash)Game.GenerateHash(o.itemCode);
                if (!playerPed.Weapons.HasWeapon(weaponHash))
                {
                    if (weaponHash == WeaponHash.PetrolCan)
                    {
                        playerPed.Weapons.Give(weaponHash, 2250, false, false);
                    }
                    else
                    {
                        playerPed.Weapons.Give(weaponHash, 0, false, false);
                    }
                }
            });
            setAmmoForWeaponType("pistol", playerInv.GetItem("pistolammo")?.itemAmount ?? 0);
            setAmmoForWeaponType("smg", playerInv.GetItem("smgammo")?.itemAmount ?? 0);
            setAmmoForWeaponType("rifle", playerInv.GetItem("rifleammo")?.itemAmount ?? 0);
            setAmmoForWeaponType("shotgun", playerInv.GetItem("shotgunammo")?.itemAmount ?? 0);
        }
Exemplo n.º 2
0
        private async void updateOutfitList(MenuItemSubMenu menu)
        {
            await LocalSession.UpdateData("Character.Settings");

            menu.SubMenu.menuItems = new List <MenuItem> {
                new MenuItemStandard {
                    Title = "You have no outfits"
                }
            };

            var playerOutifts = GetPlayerOutfits();

            if (playerOutifts.Count > 0)
            {
                menu.SubMenu.menuItems = new List <MenuItem>();
                foreach (var kvp in playerOutifts)
                {
                    menu.SubMenu.menuItems.Add(new MenuItemStandard
                    {
                        Title      = kvp.Key,
                        OnActivate = item =>
                        {
                            CitizenFX.Core.Native.API.ExecuteCommand($"useoutfit {kvp.Key}");
                        }
                    });
                }
            }

            menu.SubMenu.SelectedIndex = menu.SubMenu.SelectedIndex;
        }