public WeaponMenu() { headerTitle = "Weapons"; foreach (var weapon in Enum.GetValues(typeof(WeaponHash)).Cast<WeaponHash>()) { var weaponItem = InventoryItems.GetInvItemData($"WEAPON_{weapon.ToString().ToLower()}"); if(weaponItem != null) { menuItems.Add(new WeaponSubItem(weaponItem)); } } menuItems = menuItems.OrderBy(o => o.Title).ToList(); }
private void removeAmmoFromWeapon(string weaponType, int newAmmoCount) { //await LocalSession.UpdateData("Character.Inventory"); var playerInv = new PlayerInventory(LocalSession.GetGlobalData("Character.Inventory", ""), LocalSession); var ammoObject = playerInv.GetItem($"{weaponType}ammo") ?? InventoryItems.GetInvItemData($"{weaponType}ammo"); if (ammoObject == null) { return; } var currentWeaponAmmo = ammoObject.itemAmount; var ammoToLose = currentWeaponAmmo - newAmmoCount; if (ammoToLose <= 0) { return; } Magicallity.Client.Client.Instance.TriggerServerEvent("Inventory.AddInvItem", JsonConvert.SerializeObject(ammoObject), -ammoToLose); }
private void AttemptAddFish(Session.Session playerSession) { var playerInv = playerSession./*GetInventory()*/ Inventory; var caughtFish = getRandomFish(); if (caughtFish != "none") { if (playerInv.CanStoreItem(caughtFish, 1)) { Log.ToClient("[Fishing]", $"You caught a {InventoryItems.GetInvItemData(caughtFish).itemName}", ConstantColours.Job, playerSession.Source); playerInv.AddItem(caughtFish, 1); } else { Log.ToClient("[Fishing]", $"You cannot carry anymore fish", ConstantColours.Job, playerSession.Source); playerSession.SetLocalData("Character.IsFishing", false); } } else { Log.ToClient("[Fishing]", "You caught nothing", ConstantColours.Job, playerSession.Source); } }
private async void StartVehicleLockpick(int lockpickType) { try { if (!isLockpicking) { isLockpicking = true; var targetVeh = GTAHelpers.GetVehicleInFrontOfPlayer(3.0f); var closeRegister = GTAHelpers.GetObjectInRange(ObjectHash.prop_till_01); if (targetVeh != null) { Log.ToChat("", "You begin lockpicking the vehicle"); var chosenLockpick = (LockpickTypes)lockpickType; await Game.PlayerPed.Task.PlayAnimation("missheistfbisetup1", "unlock_loop_janitor", 2.0f, 2.0f, -1, (AnimationFlags)49, 0); await BaseScript.Delay(chosenLockpick == LockpickTypes.BobbyPin? 6250 : 5000); var checkVeh = GTAHelpers.GetVehicleInFrontOfPlayer(3.0f); if (targetVeh == checkVeh) { var shouldUnlock = chosenLockpick == LockpickTypes.BobbyPin ? rand.NextBool(30) : rand.NextBool(40) || chosenLockpick == LockpickTypes.SlimJim; if (shouldUnlock) { Log.ToChat("[Robbery]", "You successfully lockpicked the vehicle", ConstantColours.Blue); targetVeh.SetDecor("Vehicle.ID", -1); targetVeh.LockStatus = VehicleLockStatus.Unlocked; Client.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(targetVeh)); } else { Log.ToChat("[Robbery]", "You failed to lockpick the vehicle", ConstantColours.Blue); setVehicleAlarm(targetVeh); var breakPick = chosenLockpick == LockpickTypes.BobbyPin ? rand.NextBool(40) : rand.NextBool(20); if (breakPick) { string lockpickName = chosenLockpick == LockpickTypes.BobbyPin ? "bobby pin" : "lockpick"; Log.ToChat("[Robbery]", $"Your {lockpickName} broke while trying to get into the vehicle", ConstantColours.Blue); //BaseScript.TriggerEvent("addInvItem", lockpickName.RemoveSpaces(), -1); Client.TriggerServerEvent("Inventory.AddInvItem", JsonConvert.SerializeObject(InventoryItems.GetInvItemData(lockpickName.RemoveSpaces())), -1); } } } else { Log.ToChat("", "You moved too far away from the vehicle"); } } else if (closeRegister != 0) { Client.Instances.RobberyHandler.AttemptRegisterRobbery(); } else { Log.ToChat("", "There is nothing near you that can be lockpicked"); } isLockpicking = false; Game.PlayerPed.Task.ClearAll(); } } catch (Exception e) { Log.Error(e); } }