private void CreateMenu() { #region initial setup. // Create the menu. menu = new Menu(Game.Player.Name, "Vehicle Spawner"); // Create the buttons and checkboxes. MenuItem spawnByName = new MenuItem("Spawn Vehicle By Model Name", "Enter the name of a vehicle to spawn."); MenuCheckboxItem spawnInVeh = new MenuCheckboxItem("Spawn Inside Vehicle", "This will teleport you into the vehicle when you spawn it.", SpawnInVehicle); MenuCheckboxItem replacePrev = new MenuCheckboxItem("Replace Previous Vehicle", "This will automatically delete your previously spawned vehicle when you spawn a new vehicle.", ReplaceVehicle); // Add the items to the menu. if (IsAllowed(Permission.VSSpawnByName)) { menu.AddMenuItem(spawnByName); } menu.AddMenuItem(spawnInVeh); menu.AddMenuItem(replacePrev); #endregion #region addon cars menu // Vehicle Addons List Menu addonCarsMenu = new Menu("Addon Vehicles", "Spawn An Addon Vehicle"); MenuItem addonCarsBtn = new MenuItem("Addon Vehicles", "A list of addon vehicles available on this server.") { Label = "→→→" }; menu.AddMenuItem(addonCarsBtn); if (IsAllowed(Permission.VSAddon)) { if (AddonVehicles != null) { if (AddonVehicles.Count > 0) { MenuController.BindMenuItem(menu, addonCarsMenu, addonCarsBtn); MenuController.AddSubmenu(menu, addonCarsMenu); Menu unavailableCars = new Menu("Addon Spawner", "Unavailable Vehicles"); MenuItem unavailableCarsBtn = new MenuItem("Unavailable Vehicles", "These addon vehicles are not currently being streamed (correctly) and are not able to be spawned.") { Label = "→→→" }; MenuController.AddSubmenu(addonCarsMenu, unavailableCars); for (var cat = 0; cat < 23; cat++) { Menu categoryMenu = new Menu("Addon Spawner", GetLabelText($"VEH_CLASS_{cat}")); MenuItem categoryBtn = new MenuItem(GetLabelText($"VEH_CLASS_{cat}"), $"Spawn an addon vehicle from the {GetLabelText($"VEH_CLASS_{cat}")} class.") { Label = "→→→" }; addonCarsMenu.AddMenuItem(categoryBtn); if (!allowedCategories[cat]) { categoryBtn.Description = "This vehicle class is disabled by the server."; categoryBtn.Enabled = false; categoryBtn.LeftIcon = MenuItem.Icon.LOCK; categoryBtn.Label = ""; continue; } // Loop through all addon vehicles in this class. foreach (KeyValuePair <string, uint> veh in AddonVehicles.Where(v => GetVehicleClassFromName(v.Value) == cat)) { string localizedName = GetLabelText(GetDisplayNameFromVehicleModel(veh.Value)); string name = localizedName != "NULL" ? localizedName : GetDisplayNameFromVehicleModel(veh.Value); name = name != "CARNOTFOUND" ? name : veh.Key; MenuItem carBtn = new MenuItem(name, $"Click to spawn {name}.") { Label = $"({veh.Key})", ItemData = veh.Key // store the model name in the button data. }; // This should be impossible to be false, but we check it anyway. if (IsModelInCdimage(veh.Value)) { categoryMenu.AddMenuItem(carBtn); } else { carBtn.Enabled = false; carBtn.Description = "This vehicle is not available"; carBtn.LeftIcon = MenuItem.Icon.LOCK; unavailableCars.AddMenuItem(carBtn); } } //if (AddonVehicles.Count(av => GetVehicleClassFromName(av.Value) == cat && IsModelInCdimage(av.Value)) > 0) if (categoryMenu.Size > 0) { MenuController.AddSubmenu(addonCarsMenu, categoryMenu); MenuController.BindMenuItem(addonCarsMenu, categoryMenu, categoryBtn); categoryMenu.OnItemSelect += (sender, item, index) => { SpawnVehicle(item.ItemData.ToString(), SpawnInVehicle, ReplaceVehicle); TriggerServerEvent("vMenu:DamonLog", $"{Game.Player.Name} Spawned {item.ItemData.ToString()}"); }; } else { categoryBtn.Description = "There are no addon cars available in this category."; categoryBtn.Enabled = false; categoryBtn.LeftIcon = MenuItem.Icon.LOCK; categoryBtn.Label = ""; } } if (unavailableCars.Size > 0) { addonCarsMenu.AddMenuItem(unavailableCarsBtn); MenuController.BindMenuItem(addonCarsMenu, unavailableCars, unavailableCarsBtn); } } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "There are no addon vehicles available on this server."; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "The list containing all addon cars could not be loaded, is it configured properly?"; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "Access to this list has been restricted by the server owner."; } #endregion // These are the max speed, acceleration, braking and traction values per vehicle class. float[] speedValues = new float[23] { 44.9374657f, 50.0000038f, 48.862133f, 48.1321335f, 50.7077942f, 51.3333359f, 52.3922348f, 53.86687f, 52.03867f, 49.2241631f, 39.6176529f, 37.5559425f, 42.72843f, 21.0f, 45.0f, 65.1952744f, 109.764259f, 42.72843f, 56.5962219f, 57.5398865f, 43.3140678f, 26.66667f, 53.0537224f }; float[] accelerationValues = new float[23] { 0.34f, 0.29f, 0.335f, 0.28f, 0.395f, 0.39f, 0.66f, 0.42f, 0.425f, 0.475f, 0.21f, 0.3f, 0.32f, 0.17f, 18.0f, 5.88f, 21.0700016f, 0.33f, 14.0f, 6.86f, 0.32f, 0.2f, 0.76f }; float[] brakingValues = new float[23] { 0.72f, 0.95f, 0.85f, 0.9f, 1.0f, 1.0f, 1.3f, 1.25f, 1.52f, 1.1f, 0.6f, 0.7f, 0.8f, 3.0f, 0.4f, 3.5920403f, 20.58f, 0.9f, 2.93960738f, 3.9472363f, 0.85f, 5.0f, 1.3f }; float[] tractionValues = new float[23] { 2.3f, 2.55f, 2.3f, 2.6f, 2.625f, 2.65f, 2.8f, 2.782f, 2.9f, 2.95f, 2.0f, 3.3f, 2.175f, 2.05f, 0.0f, 1.6f, 2.15f, 2.55f, 2.57f, 3.7f, 2.05f, 2.5f, 3.2925f }; #region vehicle classes submenus // Loop through all the vehicle classes. for (var vehClass = 0; vehClass < 23; vehClass++) { // Get the class name. string className = GetLabelText($"VEH_CLASS_{vehClass}"); // Create a button & a menu for it, add the menu to the menu pool and add & bind the button to the menu. MenuItem btn = new MenuItem(className, $"Spawn a vehicle from the ~o~{className} ~s~class.") { Label = "→→→" }; Menu vehicleClassMenu = new Menu("Vehicle Spawner", className); MenuController.AddSubmenu(menu, vehicleClassMenu); menu.AddMenuItem(btn); if (allowedCategories[vehClass]) { MenuController.BindMenuItem(menu, vehicleClassMenu, btn); } else { btn.LeftIcon = MenuItem.Icon.LOCK; btn.Description = "This category has been disabled by the server owner."; btn.Enabled = false; } // Create a dictionary for the duplicate vehicle names (in this vehicle class). var duplicateVehNames = new Dictionary <string, int>(); #region Add vehicles per class // Loop through all the vehicles in the vehicle class. foreach (var veh in VehicleData.Vehicles.VehicleClasses[className]) { // Convert the model name to start with a Capital letter, converting the other characters to lowercase. string properCasedModelName = veh[0].ToString().ToUpper() + veh.ToLower().Substring(1); // Get the localized vehicle name, if it's "NULL" (no label found) then use the "properCasedModelName" created above. string vehName = GetVehDisplayNameFromModel(veh) != "NULL" ? GetVehDisplayNameFromModel(veh) : properCasedModelName; string vehModelName = veh; uint model = (uint)GetHashKey(vehModelName); float topSpeed = Map(GetVehicleModelEstimatedMaxSpeed(model), 0f, speedValues[vehClass], 0f, 1f); float acceleration = Map(GetVehicleModelAcceleration(model), 0f, accelerationValues[vehClass], 0f, 1f); float maxBraking = Map(GetVehicleModelMaxBraking(model), 0f, brakingValues[vehClass], 0f, 1f); float maxTraction = Map(GetVehicleModelMaxTraction(model), 0f, tractionValues[vehClass], 0f, 1f); // Loop through all the menu items and check each item's title/text and see if it matches the current vehicle (display) name. var duplicate = false; for (var itemIndex = 0; itemIndex < vehicleClassMenu.Size; itemIndex++) { // If it matches... if (vehicleClassMenu.GetMenuItems()[itemIndex].Text.ToString() == vehName) { // Check if the model was marked as duplicate before. if (duplicateVehNames.Keys.Contains(vehName)) { // If so, add 1 to the duplicate counter for this model name. duplicateVehNames[vehName]++; } // If this is the first duplicate, then set it to 2. else { duplicateVehNames[vehName] = 2; } // The model name is a duplicate, so get the modelname and add the duplicate amount for this model name to the end of the vehicle name. vehName += $" ({duplicateVehNames[vehName]})"; // Then create and add a new button for this vehicle. if (DoesModelExist(veh)) { var vehBtn = new MenuItem(vehName) { Enabled = true, Label = $"({vehModelName.ToLower()})", ItemData = new float[4] { topSpeed, acceleration, maxBraking, maxTraction } }; vehicleClassMenu.AddMenuItem(vehBtn); } else { var vehBtn = new MenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false, Label = $"({vehModelName.ToLower()})", ItemData = new float[4] { 0f, 0f, 0f, 0f } }; vehicleClassMenu.AddMenuItem(vehBtn); vehBtn.RightIcon = MenuItem.Icon.LOCK; } // Mark duplicate as true and break from the loop because we already found the duplicate. duplicate = true; break; } } // If it's not a duplicate, add the model name. if (!duplicate) { if (DoesModelExist(veh)) { var vehBtn = new MenuItem(vehName) { Enabled = true, Label = $"({vehModelName.ToLower()})", ItemData = new float[4] { topSpeed, acceleration, maxBraking, maxTraction } }; vehicleClassMenu.AddMenuItem(vehBtn); } else { var vehBtn = new MenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false, Label = $"({vehModelName.ToLower()})", ItemData = new float[4] { 0f, 0f, 0f, 0f } }; vehicleClassMenu.AddMenuItem(vehBtn); vehBtn.RightIcon = MenuItem.Icon.LOCK; } } } #endregion vehicleClassMenu.ShowVehicleStatsPanel = true; // Handle button presses vehicleClassMenu.OnItemSelect += (sender2, item2, index2) => { SpawnVehicle(VehicleData.Vehicles.VehicleClasses[className][index2], SpawnInVehicle, ReplaceVehicle); TriggerServerEvent("vMenu:DamonLog", $"{Game.Player.Name} Spawned {VehicleData.Vehicles.VehicleClasses[className][index2]}"); }; void HandleStatsPanel(Menu openedMenu, MenuItem currentItem) { if (currentItem != null) { if (currentItem.ItemData is float[] data) { openedMenu.ShowVehicleStatsPanel = true; openedMenu.SetVehicleStats(data[0], data[1], data[2], data[3]); openedMenu.SetVehicleUpgradeStats(0f, 0f, 0f, 0f); } else { openedMenu.ShowVehicleStatsPanel = false; } } } vehicleClassMenu.OnMenuOpen += (m) => { HandleStatsPanel(m, m.GetCurrentMenuItem()); }; vehicleClassMenu.OnIndexChange += (m, oldItem, newItem, oldIndex, newIndex) => { HandleStatsPanel(m, newItem); }; } #endregion #region handle events // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == spawnByName) { // Passing "custom" as the vehicle name, will ask the user for input. SpawnVehicle("custom", SpawnInVehicle, ReplaceVehicle); } }; // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == spawnInVeh) { SpawnInVehicle = _checked; } else if (item == replacePrev) { ReplaceVehicle = _checked; } }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Menu menu = new Menu(GetSafePlayerName(Game.Player.Name), "Personal Vehicle Options"); // menu items MenuItem setVehice = new MenuItem("Set Vehicle", "Sets your current vehicle as your personal vehicle. If you already have a personal vehicle set then this will override your selection.") { Label = "Current Vehicle: None" }; MenuItem toggleEngine = new MenuItem("Toggle Engine", "Toggles the engine on or off, even when you're not inside of the vehicle. This does not work if someone else is currently using your vehicle."); MenuListItem toggleLights = new MenuListItem("Set Vehicle Lights", new List <string>() { "Force On", "Force Off", "Reset" }, 0, "This will enable or disable your vehicle headlights, the engine of your vehicle needs to be running for this to work."); MenuItem kickAllPassengers = new MenuItem("Kick Passengers", "This will remove all passengers from your personal vehicle."); //MenuItem MenuItem lockDoors = new MenuItem("Lock Vehicle Doors", "This will lock all your vehicle doors for all players. Anyone already inside will always be able to leave the vehicle, even if the doors are locked."); MenuItem unlockDoors = new MenuItem("Unlock Vehicle Doors", "This will unlock all your vehicle doors for all players."); MenuItem doorsMenuBtn = new MenuItem("Vehicle Doors", "Open, close, remove and restore vehicle doors here.") { Label = "→→→" }; MenuItem soundHorn = new MenuItem("Sound Horn", "Sounds the horn of the vehicle."); MenuItem toggleAlarm = new MenuItem("Toggle Alarm Sound", "Toggles the vehicle alarm sound on or off. This does not set an alarm. It only toggles the current sounding status of the alarm."); MenuCheckboxItem enableBlip = new MenuCheckboxItem("Add Blip For Personal Vehicle", "Enables or disables the blip that gets added when you mark a vehicle as your personal vehicle.", EnableVehicleBlip) { Style = MenuCheckboxItem.CheckboxStyle.Cross }; MenuCheckboxItem exclusiveDriver = new MenuCheckboxItem("Exclusive Driver", "If enabled, then you will be the only one that can enter the drivers seat. Other players will not be able to drive the car. They can still be passengers.", false) { Style = MenuCheckboxItem.CheckboxStyle.Cross }; //submenu VehicleDoorsMenu = new Menu("Vehicle Doors", "Vehicle Doors Management"); MenuController.AddSubmenu(menu, VehicleDoorsMenu); MenuController.BindMenuItem(menu, VehicleDoorsMenu, doorsMenuBtn); // This is always allowed if this submenu is created/allowed. menu.AddMenuItem(setVehice); // Add conditional features. // Toggle engine. if (IsAllowed(Permission.PVToggleEngine)) { menu.AddMenuItem(toggleEngine); } // Toggle lights if (IsAllowed(Permission.PVToggleLights)) { menu.AddMenuItem(toggleLights); } // Kick vehicle passengers if (IsAllowed(Permission.PVKickPassengers)) { menu.AddMenuItem(kickAllPassengers); } // Lock and unlock vehicle doors if (IsAllowed(Permission.PVLockDoors)) { menu.AddMenuItem(lockDoors); menu.AddMenuItem(unlockDoors); } if (IsAllowed(Permission.PVDoors)) { menu.AddMenuItem(doorsMenuBtn); } // Sound horn if (IsAllowed(Permission.PVSoundHorn)) { menu.AddMenuItem(soundHorn); } // Toggle alarm sound if (IsAllowed(Permission.PVToggleAlarm)) { menu.AddMenuItem(toggleAlarm); } // Enable blip for personal vehicle if (IsAllowed(Permission.PVAddBlip)) { menu.AddMenuItem(enableBlip); } if (IsAllowed(Permission.PVExclusiveDriver)) { menu.AddMenuItem(exclusiveDriver); } // Handle list presses menu.OnListItemSelect += (sender, item, itemIndex, index) => { var veh = CurrentPersonalVehicle; if (veh != null && veh.Exists()) { if (!NetworkHasControlOfEntity(CurrentPersonalVehicle.Handle)) { if (!NetworkRequestControlOfEntity(CurrentPersonalVehicle.Handle)) { Notify.Error("You currently can't control this vehicle. Is someone else currently driving your car? Please try again after making sure other players are not controlling your vehicle."); return; } } if (item == toggleLights) { PressKeyFob(CurrentPersonalVehicle); if (itemIndex == 0) { SetVehicleLights(CurrentPersonalVehicle.Handle, 3); } else if (itemIndex == 1) { SetVehicleLights(CurrentPersonalVehicle.Handle, 1); } else { SetVehicleLights(CurrentPersonalVehicle.Handle, 0); } } } else { Notify.Error("You have not yet selected a personal vehicle, or your vehicle has been deleted. Set a personal vehicle before you can use these options."); } }; // Handle checkbox changes menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == enableBlip) { EnableVehicleBlip = _checked; if (EnableVehicleBlip) { if (CurrentPersonalVehicle != null && CurrentPersonalVehicle.Exists()) { if (CurrentPersonalVehicle.AttachedBlip == null || !CurrentPersonalVehicle.AttachedBlip.Exists()) { CurrentPersonalVehicle.AttachBlip(); } CurrentPersonalVehicle.AttachedBlip.Sprite = BlipSprite.PersonalVehicleCar; CurrentPersonalVehicle.AttachedBlip.Name = "Personal Vehicle"; } else { Notify.Error("You have not yet selected a personal vehicle, or your vehicle has been deleted. Set a personal vehicle before you can use these options."); } } else { if (CurrentPersonalVehicle != null && CurrentPersonalVehicle.Exists() && CurrentPersonalVehicle.AttachedBlip != null && CurrentPersonalVehicle.AttachedBlip.Exists()) { CurrentPersonalVehicle.AttachedBlip.Delete(); } } } else if (item == exclusiveDriver) { if (CurrentPersonalVehicle != null && CurrentPersonalVehicle.Exists()) { if (NetworkRequestControlOfEntity(CurrentPersonalVehicle.Handle)) { if (_checked) { SetVehicleExclusiveDriver(CurrentPersonalVehicle.Handle, Game.PlayerPed.Handle, 1); SetVehicleExclusiveDriver_2(CurrentPersonalVehicle.Handle, Game.PlayerPed.Handle, 1); } else { SetVehicleExclusiveDriver(CurrentPersonalVehicle.Handle, 0, 1); SetVehicleExclusiveDriver_2(CurrentPersonalVehicle.Handle, 0, 1); } } else { item.Checked = !_checked; Notify.Error("You currently can't control this vehicle. Is someone else currently driving your car? Please try again after making sure other players are not controlling your vehicle."); } } } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == setVehice) { if (Game.PlayerPed.IsInVehicle()) { var veh = GetVehicle(); if (veh != null && veh.Exists()) { if (Game.PlayerPed == veh.Driver) { CurrentPersonalVehicle = veh; veh.PreviouslyOwnedByPlayer = true; veh.IsPersistent = true; if (EnableVehicleBlip && IsAllowed(Permission.PVAddBlip)) { if (veh.AttachedBlip == null || !veh.AttachedBlip.Exists()) { veh.AttachBlip(); } veh.AttachedBlip.Sprite = BlipSprite.PersonalVehicleCar; veh.AttachedBlip.Name = "Personal Vehicle"; } var name = GetLabelText(veh.DisplayName); if (string.IsNullOrEmpty(name) || name.ToLower() == "null") { name = veh.DisplayName; } item.Label = $"Current Vehicle: {name}"; } else { Notify.Error(CommonErrors.NeedToBeTheDriver); } } else { Notify.Error(CommonErrors.NoVehicle); } } else { Notify.Error(CommonErrors.NoVehicle); } } else if (CurrentPersonalVehicle != null && CurrentPersonalVehicle.Exists()) { if (item == kickAllPassengers) { if (CurrentPersonalVehicle.Occupants.Count() > 0 && CurrentPersonalVehicle.Occupants.Any(p => p != Game.PlayerPed)) { var netId = VehToNet(CurrentPersonalVehicle.Handle); TriggerServerEvent("vMenu:GetOutOfCar", netId, Game.Player.ServerId); } else { Notify.Info("There are no other players in your vehicle that need to be kicked out."); } } else { if (!NetworkHasControlOfEntity(CurrentPersonalVehicle.Handle)) { if (!NetworkRequestControlOfEntity(CurrentPersonalVehicle.Handle)) { Notify.Error("You currently can't control this vehicle. Is someone else currently driving your car? Please try again after making sure other players are not controlling your vehicle."); return; } } if (item == toggleEngine) { PressKeyFob(CurrentPersonalVehicle); SetVehicleEngineOn(CurrentPersonalVehicle.Handle, !CurrentPersonalVehicle.IsEngineRunning, true, true); } else if (item == lockDoors || item == unlockDoors) { PressKeyFob(CurrentPersonalVehicle); bool _lock = item == lockDoors; LockOrUnlockDoors(CurrentPersonalVehicle, _lock); } else if (item == soundHorn) { PressKeyFob(CurrentPersonalVehicle); SoundHorn(CurrentPersonalVehicle); } else if (item == toggleAlarm) { PressKeyFob(CurrentPersonalVehicle); ToggleVehicleAlarm(CurrentPersonalVehicle); } } } else { Notify.Error("You have not yet selected a personal vehicle, or your vehicle has been deleted. Set a personal vehicle before you can use these options."); } }; #region Doors submenu MenuItem openAll = new MenuItem("Open All Doors", "Open all vehicle doors."); MenuItem closeAll = new MenuItem("Close All Doors", "Close all vehicle doors."); MenuItem LF = new MenuItem("Left Front Door", "Open/close the left front door."); MenuItem RF = new MenuItem("Right Front Door", "Open/close the right front door."); MenuItem LR = new MenuItem("Left Rear Door", "Open/close the left rear door."); MenuItem RR = new MenuItem("Right Rear Door", "Open/close the right rear door."); MenuItem HD = new MenuItem("Hood", "Open/close the hood."); MenuItem TR = new MenuItem("Trunk", "Open/close the trunk."); MenuItem E1 = new MenuItem("Extra 1", "Open/close the extra door (#1). Note this door is not present on most vehicles."); MenuItem E2 = new MenuItem("Extra 2", "Open/close the extra door (#2). Note this door is not present on most vehicles."); MenuItem BB = new MenuItem("Bomb Bay", "Open/close the bomb bay. Only available on some planes."); var doors = new List <string>() { "Front Left", "Front Right", "Rear Left", "Rear Right", "Hood", "Trunk", "Extra 1", "Extra 2", "Bomb Bay" }; MenuListItem removeDoorList = new MenuListItem("Remove Door", doors, 0, "Remove a specific vehicle door completely."); MenuCheckboxItem deleteDoors = new MenuCheckboxItem("Delete Removed Doors", "When enabled, doors that you remove using the list above will be deleted from the world. If disabled, then the doors will just fall on the ground.", false); VehicleDoorsMenu.AddMenuItem(LF); VehicleDoorsMenu.AddMenuItem(RF); VehicleDoorsMenu.AddMenuItem(LR); VehicleDoorsMenu.AddMenuItem(RR); VehicleDoorsMenu.AddMenuItem(HD); VehicleDoorsMenu.AddMenuItem(TR); VehicleDoorsMenu.AddMenuItem(E1); VehicleDoorsMenu.AddMenuItem(E2); VehicleDoorsMenu.AddMenuItem(BB); VehicleDoorsMenu.AddMenuItem(openAll); VehicleDoorsMenu.AddMenuItem(closeAll); VehicleDoorsMenu.AddMenuItem(removeDoorList); VehicleDoorsMenu.AddMenuItem(deleteDoors); VehicleDoorsMenu.OnListItemSelect += (sender, item, index, itemIndex) => { Vehicle veh = CurrentPersonalVehicle; if (veh != null && veh.Exists()) { if (!NetworkHasControlOfEntity(CurrentPersonalVehicle.Handle)) { if (!NetworkRequestControlOfEntity(CurrentPersonalVehicle.Handle)) { Notify.Error("You currently can't control this vehicle. Is someone else currently driving your car? Please try again after making sure other players are not controlling your vehicle."); return; } } if (item == removeDoorList) { PressKeyFob(veh); SetVehicleDoorBroken(veh.Handle, index, deleteDoors.Checked); } } }; VehicleDoorsMenu.OnItemSelect += (sender, item, index) => { Vehicle veh = CurrentPersonalVehicle; if (veh != null && veh.Exists() && !veh.IsDead) { if (!NetworkHasControlOfEntity(CurrentPersonalVehicle.Handle)) { if (!NetworkRequestControlOfEntity(CurrentPersonalVehicle.Handle)) { Notify.Error("You currently can't control this vehicle. Is someone else currently driving your car? Please try again after making sure other players are not controlling your vehicle."); return; } } if (index < 8) { bool open = GetVehicleDoorAngleRatio(veh.Handle, index) > 0.1f; PressKeyFob(veh); if (open) { SetVehicleDoorShut(veh.Handle, index, false); } else { SetVehicleDoorOpen(veh.Handle, index, false, false); } } else if (item == openAll) { PressKeyFob(veh); for (var door = 0; door < 8; door++) { SetVehicleDoorOpen(veh.Handle, door, false, false); } } else if (item == closeAll) { PressKeyFob(veh); for (var door = 0; door < 8; door++) { SetVehicleDoorShut(veh.Handle, door, false); } } else if (item == BB && veh.HasBombBay) { PressKeyFob(veh); bool bombBayOpen = AreBombBayDoorsOpen(veh.Handle); if (bombBayOpen) { veh.CloseBombBay(); } else { veh.OpenBombBay(); } } else { Notify.Error("You have not yet selected a personal vehicle, or your vehicle has been deleted. Set a personal vehicle before you can use these options."); } } }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { #region create menu and menu items // Create the menu. menu = new Menu(Game.Player.Name, "Player Options"); // Create all checkboxes. MenuCheckboxItem playerGodModeCheckbox = new MenuCheckboxItem("Godmode", "Makes you invincible.", PlayerGodMode); MenuCheckboxItem invisibleCheckbox = new MenuCheckboxItem("Invisible", "Makes you invisible to yourself and others.", PlayerInvisible); MenuCheckboxItem unlimitedStaminaCheckbox = new MenuCheckboxItem("Unlimited Stamina", "Allows you to run forever without slowing down or taking damage.", PlayerStamina); MenuCheckboxItem fastRunCheckbox = new MenuCheckboxItem("Fast Run", "Get ~g~Snail~s~ powers and run very fast!", PlayerFastRun); SetRunSprintMultiplierForPlayer(Game.Player.Handle, (PlayerFastRun ? 1.49f : 1f)); MenuCheckboxItem fastSwimCheckbox = new MenuCheckboxItem("Fast Swim", "Get ~g~Snail 2.0~s~ powers and swim super fast!", PlayerFastSwim); SetSwimMultiplierForPlayer(Game.Player.Handle, (PlayerFastSwim ? 1.49f : 1f)); MenuCheckboxItem superJumpCheckbox = new MenuCheckboxItem("Super Jump", "Get ~g~Snail 3.0~s~ powers and jump like a champ!", PlayerSuperJump); MenuCheckboxItem noRagdollCheckbox = new MenuCheckboxItem("No Ragdoll", "Disables player ragdoll, makes you not fall off your bike anymore.", PlayerNoRagdoll); MenuCheckboxItem neverWantedCheckbox = new MenuCheckboxItem("Never Wanted", "Disables all wanted levels.", PlayerNeverWanted); MenuCheckboxItem everyoneIgnoresPlayerCheckbox = new MenuCheckboxItem("Everyone Ignore Player", "Everyone will leave you alone.", PlayerIsIgnored); MenuCheckboxItem playerFrozenCheckbox = new MenuCheckboxItem("Freeze Player", "Freezes your current location.", PlayerFrozen); // Wanted level options List <string> wantedLevelList = new List <string> { "No Wanted Level", "1", "2", "3", "4", "5" }; MenuListItem setWantedLevel = new MenuListItem("Set Wanted Level", wantedLevelList, GetPlayerWantedLevel(Game.Player.Handle), "Set your wanted level by selecting a value, and pressing enter."); MenuListItem setArmorItem = new MenuListItem("Set Armor Type", new List <string> { "No Armor", GetLabelText("WT_BA_0"), GetLabelText("WT_BA_1"), GetLabelText("WT_BA_2"), GetLabelText("WT_BA_3"), GetLabelText("WT_BA_4"), }, 0, "Set the armor level/type for your player."); MenuItem healPlayerBtn = new MenuItem("Heal Player", "Give the player max health."); MenuItem cleanPlayerBtn = new MenuItem("Clean Player Clothes", "Clean your player clothes."); MenuItem dryPlayerBtn = new MenuItem("Dry Player Clothes", "Make your player clothes dry."); MenuItem wetPlayerBtn = new MenuItem("Wet Player Clothes", "Make your player clothes wet."); MenuItem suicidePlayerBtn = new MenuItem("~r~Commit Suicide", "Kill yourself by taking the pill. Or by using a pistol if you have one."); Menu vehicleAutoPilot = new Menu("Auto Pilot", "Vehicle auto pilot options."); MenuController.AddSubmenu(menu, vehicleAutoPilot); MenuItem vehicleAutoPilotBtn = new MenuItem("Vehicle Auto Pilot Menu", "Manage vehicle auto pilot options."); vehicleAutoPilotBtn.Label = "→→→"; List <string> drivingStyles = new List <string>() { "Normal", "Rushed", "Avoid highways", "Drive in reverse" }; MenuListItem drivingStyle = new MenuListItem("Driving Style", drivingStyles, 0, "Set the driving style that is used for the Drive to Waypoint and Drive Around Randomly functions."); // Scenarios (list can be found in the PedScenarios class) MenuListItem playerScenarios = new MenuListItem("Player Scenarios", PedScenarios.Scenarios, 0, "Select a scenario and hit enter to start it. Selecting another scenario will override the current scenario. If you're already playing the selected scenario, selecting it again will stop the scenario."); MenuItem stopScenario = new MenuItem("Force Stop Scenario", "This will force a playing scenario to stop immediately, without waiting for it to finish it's 'stopping' animation."); #endregion #region add items to menu based on permissions // Add all checkboxes to the menu. (keeping permissions in mind) if (IsAllowed(Permission.POGod)) { menu.AddMenuItem(playerGodModeCheckbox); } if (IsAllowed(Permission.POInvisible)) { menu.AddMenuItem(invisibleCheckbox); } if (IsAllowed(Permission.POUnlimitedStamina)) { menu.AddMenuItem(unlimitedStaminaCheckbox); } if (IsAllowed(Permission.POFastRun)) { menu.AddMenuItem(fastRunCheckbox); } if (IsAllowed(Permission.POFastSwim)) { menu.AddMenuItem(fastSwimCheckbox); } if (IsAllowed(Permission.POSuperjump)) { menu.AddMenuItem(superJumpCheckbox); } if (IsAllowed(Permission.PONoRagdoll)) { menu.AddMenuItem(noRagdollCheckbox); } if (IsAllowed(Permission.PONeverWanted)) { menu.AddMenuItem(neverWantedCheckbox); } if (IsAllowed(Permission.POSetWanted)) { menu.AddMenuItem(setWantedLevel); } if (IsAllowed(Permission.POIgnored)) { menu.AddMenuItem(everyoneIgnoresPlayerCheckbox); } if (IsAllowed(Permission.POMaxHealth)) { menu.AddMenuItem(healPlayerBtn); } if (IsAllowed(Permission.POMaxArmor)) { menu.AddMenuItem(setArmorItem); } if (IsAllowed(Permission.POCleanPlayer)) { menu.AddMenuItem(cleanPlayerBtn); } if (IsAllowed(Permission.PODryPlayer)) { menu.AddMenuItem(dryPlayerBtn); } if (IsAllowed(Permission.POWetPlayer)) { menu.AddMenuItem(wetPlayerBtn); } menu.AddMenuItem(suicidePlayerBtn); if (IsAllowed(Permission.POVehicleAutoPilotMenu)) { menu.AddMenuItem(vehicleAutoPilotBtn); MenuController.BindMenuItem(menu, vehicleAutoPilot, vehicleAutoPilotBtn); vehicleAutoPilot.AddMenuItem(drivingStyle); MenuItem startDrivingWaypoint = new MenuItem("Drive To Waypoint", "Make your player ped drive your vehicle to your waypoint."); MenuItem startDrivingRandomly = new MenuItem("Drive Around Randomly", "Make your player ped drive your vehicle randomly around the map."); MenuItem stopDriving = new MenuItem("Stop Driving", "The player ped will find a suitable place to stop the vehicle. The task will be stopped once the vehicle has reached the suitable stop location."); MenuItem forceStopDriving = new MenuItem("Force Stop Driving", "This will stop the driving task immediately without finding a suitable place to stop."); vehicleAutoPilot.AddMenuItem(startDrivingWaypoint); vehicleAutoPilot.AddMenuItem(startDrivingRandomly); vehicleAutoPilot.AddMenuItem(stopDriving); vehicleAutoPilot.AddMenuItem(forceStopDriving); vehicleAutoPilot.RefreshIndex(); vehicleAutoPilot.OnItemSelect += async(sender, item, index) => { if (Game.PlayerPed.IsInVehicle() && item != stopDriving && item != forceStopDriving) { if (Game.PlayerPed.CurrentVehicle != null && Game.PlayerPed.CurrentVehicle.Exists() && !Game.PlayerPed.CurrentVehicle.IsDead && Game.PlayerPed.CurrentVehicle.IsDriveable) { if (Game.PlayerPed.CurrentVehicle.Driver == Game.PlayerPed) { if (item == startDrivingWaypoint) { if (IsWaypointActive()) { int style = GetStyleFromIndex(drivingStyle.ListIndex); DriveToWp(style); Notify.Info("Your player ped is now driving the vehicle for you. You can cancel any time by pressing the Stop Driving button. The vehicle will stop when it has reached the destination."); } else { Notify.Error("You need a waypoint before you can drive to it!"); } } else if (item == startDrivingRandomly) { int style = GetStyleFromIndex(drivingStyle.ListIndex); DriveWander(style); Notify.Info("Your player ped is now driving the vehicle for you. You can cancel any time by pressing the Stop Driving button."); } } else { Notify.Error("You must be the driver of this vehicle!"); } } else { Notify.Error("Your vehicle is broken or it does not exist!"); } } else if (item != stopDriving && item != forceStopDriving) { Notify.Error("You need to be in a vehicle first!"); } if (item == stopDriving) { if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = GetVehicle(); if (veh != null && veh.Exists() && !veh.IsDead) { Vector3 outPos = new Vector3(); if (GetNthClosestVehicleNode(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z, 3, ref outPos, 0, 0, 0)) { Notify.Info("The player ped will find a suitable place to park the car and will then stop driving. Please wait."); ClearPedTasks(Game.PlayerPed.Handle); TaskVehiclePark(Game.PlayerPed.Handle, veh.Handle, outPos.X, outPos.Y, outPos.Z, Game.PlayerPed.Heading, 3, 60f, true); while (Game.PlayerPed.Position.DistanceToSquared2D(outPos) > 3f) { await BaseScript.Delay(0); } SetVehicleHalt(veh.Handle, 3f, 0, false); ClearPedTasks(Game.PlayerPed.Handle); Notify.Info("The player ped has stopped driving."); } } } else { ClearPedTasks(Game.PlayerPed.Handle); Notify.Alert("Your ped is not in any vehicle."); } } else if (item == forceStopDriving) { ClearPedTasks(Game.PlayerPed.Handle); Notify.Info("Driving task cancelled."); } }; vehicleAutoPilot.OnListItemSelect += (sender, item, listIndex, itemIndex) => { if (item == drivingStyle) { int style = GetStyleFromIndex(listIndex); SetDriveTaskDrivingStyle(Game.PlayerPed.Handle, style); Notify.Info($"Driving task style is now set to: ~r~{drivingStyles[listIndex]}~s~."); } }; } if (IsAllowed(Permission.POFreeze)) { menu.AddMenuItem(playerFrozenCheckbox); } if (IsAllowed(Permission.POScenarios)) { menu.AddMenuItem(playerScenarios); menu.AddMenuItem(stopScenario); } #endregion #region handle all events // Checkbox changes. menu.OnCheckboxChange += (sender, item, itemIndex, _checked) => { // God Mode toggled. if (item == playerGodModeCheckbox) { PlayerGodMode = _checked; } // Invisibility toggled. else if (item == invisibleCheckbox) { PlayerInvisible = _checked; SetEntityVisible(Game.PlayerPed.Handle, !PlayerInvisible, false); } // Unlimited Stamina toggled. else if (item == unlimitedStaminaCheckbox) { PlayerStamina = _checked; StatSetInt((uint)GetHashKey("MP0_STAMINA"), _checked ? 100 : 0, true); } // Fast run toggled. else if (item == fastRunCheckbox) { PlayerFastRun = _checked; SetRunSprintMultiplierForPlayer(Game.Player.Handle, (_checked ? 1.49f : 1f)); } // Fast swim toggled. else if (item == fastSwimCheckbox) { PlayerFastSwim = _checked; SetSwimMultiplierForPlayer(Game.Player.Handle, (_checked ? 1.49f : 1f)); } // Super jump toggled. else if (item == superJumpCheckbox) { PlayerSuperJump = _checked; } // No ragdoll toggled. else if (item == noRagdollCheckbox) { PlayerNoRagdoll = _checked; } // Never wanted toggled. else if (item == neverWantedCheckbox) { PlayerNeverWanted = _checked; } // Everyone ignores player toggled. else if (item == everyoneIgnoresPlayerCheckbox) { PlayerIsIgnored = _checked; // Manage player is ignored by everyone. SetEveryoneIgnorePlayer(Game.Player.Handle, PlayerIsIgnored); SetPoliceIgnorePlayer(Game.Player.Handle, PlayerIsIgnored); SetPlayerCanBeHassledByGangs(Game.Player.Handle, !PlayerIsIgnored); } // Freeze player toggled. else if (item == playerFrozenCheckbox) { PlayerFrozen = _checked; if (MainMenu.NoClipMenu != null && !MainMenu.NoClipEnabled) { FreezeEntityPosition(Game.PlayerPed.Handle, PlayerFrozen); } else if (!MainMenu.NoClipEnabled) { FreezeEntityPosition(Game.PlayerPed.Handle, PlayerFrozen); } } }; // List selections menu.OnListItemSelect += (sender, listItem, listIndex, itemIndex) => { // Set wanted Level if (listItem == setWantedLevel) { SetPlayerWantedLevel(Game.Player.Handle, listIndex, false); SetPlayerWantedLevelNow(Game.Player.Handle, false); } // Player Scenarios else if (listItem == playerScenarios) { PlayScenario(PedScenarios.ScenarioNames[PedScenarios.Scenarios[listIndex]]); } else if (listItem == setArmorItem) { Game.PlayerPed.Armor = (listItem.ListIndex) * 20; } }; // button presses menu.OnItemSelect += (sender, item, index) => { // Force Stop Scenario button if (item == stopScenario) { // Play a new scenario named "forcestop" (this scenario doesn't exist, but the "Play" function checks // for the string "forcestop", if that's provided as th scenario name then it will forcefully clear the player task. PlayScenario("forcestop"); } else if (item == healPlayerBtn) { Game.PlayerPed.Health = Game.PlayerPed.MaxHealth; Notify.Success("Player healed."); } else if (item == cleanPlayerBtn) { Game.PlayerPed.ClearBloodDamage(); Notify.Success("Player clothes have been cleaned."); } else if (item == dryPlayerBtn) { Game.PlayerPed.WetnessHeight = 0f; Notify.Success("Player is now dry."); } else if (item == wetPlayerBtn) { Game.PlayerPed.WetnessHeight = 2f; Notify.Success("Player is now wet."); } else if (item == suicidePlayerBtn) { CommitSuicide(); } }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Setup weapon dictionaries. weaponInfo = new Dictionary <Menu, ValidWeapon>(); weaponComponents = new Dictionary <MenuItem, string>(); #region create main weapon options menu and add items // Create the menu. menu = new Menu(Game.Player.Name, "Weapon Options"); MenuItem getAllWeapons = new MenuItem("Get All Weapons", "Get all weapons."); MenuItem removeAllWeapons = new MenuItem("Remove All Weapons", "Removes all weapons in your inventory."); MenuCheckboxItem unlimitedAmmo = new MenuCheckboxItem("Unlimited Ammo", "Unlimited ammonition supply.", UnlimitedAmmo); MenuCheckboxItem noReload = new MenuCheckboxItem("No Reload", "Never reload.", NoReload); MenuItem setAmmo = new MenuItem("Set All Ammo Count", "Set the amount of ammo in all your weapons."); MenuItem refillMaxAmmo = new MenuItem("Refill All Ammo", "Give all your weapons max ammo."); MenuItem spawnByName = new MenuItem("Spawn Weapon By Name", "Enter a weapon mode name to spawn."); // Add items based on permissions if (IsAllowed(Permission.WPGetAll)) { menu.AddMenuItem(getAllWeapons); } if (IsAllowed(Permission.WPRemoveAll)) { menu.AddMenuItem(removeAllWeapons); } if (IsAllowed(Permission.WPUnlimitedAmmo)) { menu.AddMenuItem(unlimitedAmmo); } if (IsAllowed(Permission.WPNoReload)) { menu.AddMenuItem(noReload); } if (IsAllowed(Permission.WPSetAllAmmo)) { menu.AddMenuItem(setAmmo); menu.AddMenuItem(refillMaxAmmo); } if (IsAllowed(Permission.WPSpawnByName)) { menu.AddMenuItem(spawnByName); } #endregion #region addonweapons submenu MenuItem addonWeaponsBtn = new MenuItem("Addon Weapons", "Equip / remove addon weapons available on this server."); Menu addonWeaponsMenu = new Menu("Addon Weapons", "Equip/Remove Addon Weapons"); menu.AddMenuItem(addonWeaponsBtn); #region manage creating and accessing addon weapons menu if (IsAllowed(Permission.WPSpawn) && AddonWeapons != null && AddonWeapons.Count > 0) { MenuController.BindMenuItem(menu, addonWeaponsMenu, addonWeaponsBtn); foreach (KeyValuePair <string, uint> weapon in AddonWeapons) { string name = weapon.Key.ToString(); uint model = weapon.Value; var item = new MenuItem(name, $"Click to add/remove this weapon ({name}) to/from your inventory."); addonWeaponsMenu.AddMenuItem(item); if (!IsWeaponValid(model)) { item.Enabled = false; item.LeftIcon = MenuItem.Icon.LOCK; item.Description = "This model is not available. Please ask the server owner to verify it's being streamed correctly."; } } addonWeaponsMenu.OnItemSelect += (sender, item, index) => { var weapon = AddonWeapons.ElementAt(index); if (HasPedGotWeapon(Game.PlayerPed.Handle, weapon.Value, false)) { RemoveWeaponFromPed(Game.PlayerPed.Handle, weapon.Value); } else { var maxAmmo = 200; GetMaxAmmo(Game.PlayerPed.Handle, weapon.Value, ref maxAmmo); GiveWeaponToPed(Game.PlayerPed.Handle, weapon.Value, maxAmmo, false, true); } }; addonWeaponsBtn.Label = "→→→"; } else { addonWeaponsBtn.LeftIcon = MenuItem.Icon.LOCK; addonWeaponsBtn.Enabled = false; addonWeaponsBtn.Description = "This option is not available on this server because you don't have permission to use it, or it is not setup correctly."; } #endregion addonWeaponsMenu.RefreshIndex(); #endregion #region parachute options menu if (IsAllowed(Permission.WPParachute)) { // main parachute options menu setup Menu parachuteMenu = new Menu("Parachute Options", "Parachute Options"); MenuItem parachuteBtn = new MenuItem("Parachute Options", "All parachute related options can be changed here.") { Label = "→→→" }; MenuController.AddSubmenu(menu, parachuteMenu); menu.AddMenuItem(parachuteBtn); MenuController.BindMenuItem(menu, parachuteMenu, parachuteBtn); List <string> chutes = new List <string>() { GetLabelText("PM_TINT0"), GetLabelText("PM_TINT1"), GetLabelText("PM_TINT2"), GetLabelText("PM_TINT3"), GetLabelText("PM_TINT4"), GetLabelText("PM_TINT5"), GetLabelText("PM_TINT6"), GetLabelText("PM_TINT7"), // broken in FiveM for some weird reason: GetLabelText("PS_CAN_0"), GetLabelText("PS_CAN_1"), GetLabelText("PS_CAN_2"), GetLabelText("PS_CAN_3"), GetLabelText("PS_CAN_4"), GetLabelText("PS_CAN_5") }; List <string> chuteDescriptions = new List <string>() { GetLabelText("PD_TINT0"), GetLabelText("PD_TINT1"), GetLabelText("PD_TINT2"), GetLabelText("PD_TINT3"), GetLabelText("PD_TINT4"), GetLabelText("PD_TINT5"), GetLabelText("PD_TINT6"), GetLabelText("PD_TINT7"), // broken in FiveM for some weird reason: GetLabelText("PSD_CAN_0") + " ~r~For some reason this one doesn't seem to work in FiveM.", GetLabelText("PSD_CAN_1") + " ~r~For some reason this one doesn't seem to work in FiveM.", GetLabelText("PSD_CAN_2") + " ~r~For some reason this one doesn't seem to work in FiveM.", GetLabelText("PSD_CAN_3") + " ~r~For some reason this one doesn't seem to work in FiveM.", GetLabelText("PSD_CAN_4") + " ~r~For some reason this one doesn't seem to work in FiveM.", GetLabelText("PSD_CAN_5") + " ~r~For some reason this one doesn't seem to work in FiveM." }; MenuItem togglePrimary = new MenuItem("Toggle Primary Parachute", "Equip or remove the primary parachute"); MenuItem toggleReserve = new MenuItem("Enable Reserve Parachute", "Enables the reserve parachute. Only works if you enabled the primary parachute first. Reserve parachute can not be removed from the player once it's activated."); MenuListItem primaryChutes = new MenuListItem("Primary Chute Style", chutes, 0, $"Primary chute: {chuteDescriptions[0]}"); MenuListItem secondaryChutes = new MenuListItem("Reserve Chute Style", chutes, 0, $"Reserve chute: {chuteDescriptions[0]}"); MenuCheckboxItem unlimitedParachutes = new MenuCheckboxItem("Unlimited Parachutes", "Enable unlimited parachutes and reserve parachutes.", UnlimitedParachutes); MenuCheckboxItem autoEquipParachutes = new MenuCheckboxItem("Auto Equip Parachutes", "Automatically equip a parachute and reserve parachute when entering planes/helicopters.", AutoEquipChute); // smoke color list List <string> smokeColorsList = new List <string>() { GetLabelText("PM_TINT8"), // no smoke GetLabelText("PM_TINT9"), // red GetLabelText("PM_TINT10"), // orange GetLabelText("PM_TINT11"), // yellow GetLabelText("PM_TINT12"), // blue GetLabelText("PM_TINT13"), // black }; List <int[]> colors = new List <int[]>() { new int[3] { 255, 255, 255 }, new int[3] { 255, 0, 0 }, new int[3] { 255, 165, 0 }, new int[3] { 255, 255, 0 }, new int[3] { 0, 0, 255 }, new int[3] { 20, 20, 20 }, }; MenuListItem smokeColors = new MenuListItem("Smoke Trail Color", smokeColorsList, 0, "Choose a smoke trail color, then press select to change it. Changing colors takes 4 seconds, you can not use your smoke while the color is being changed."); parachuteMenu.AddMenuItem(togglePrimary); parachuteMenu.AddMenuItem(toggleReserve); parachuteMenu.AddMenuItem(autoEquipParachutes); parachuteMenu.AddMenuItem(unlimitedParachutes); parachuteMenu.AddMenuItem(smokeColors); parachuteMenu.AddMenuItem(primaryChutes); parachuteMenu.AddMenuItem(secondaryChutes); parachuteMenu.OnItemSelect += (sender, item, index) => { if (item == togglePrimary) { if (HasPedGotWeapon(Game.PlayerPed.Handle, (uint)GetHashKey("gadget_parachute"), false)) { Subtitle.Custom("Primary parachute removed."); RemoveWeaponFromPed(Game.PlayerPed.Handle, (uint)GetHashKey("gadget_parachute")); } else { Subtitle.Custom("Primary parachute added."); GiveWeaponToPed(Game.PlayerPed.Handle, (uint)GetHashKey("gadget_parachute"), 0, false, false); } } else if (item == toggleReserve) { SetPlayerHasReserveParachute(Game.Player.Handle); Subtitle.Custom("Reserve parachute has been added."); } }; parachuteMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == unlimitedParachutes) { UnlimitedParachutes = _checked; } else if (item == autoEquipParachutes) { AutoEquipChute = _checked; } }; bool switching = false; async void IndexChangedEventHandler(Menu sender, MenuListItem item, int oldIndex, int newIndex, int itemIndex) { if (item == smokeColors && oldIndex == -1) { if (!switching) { switching = true; SetPlayerCanLeaveParachuteSmokeTrail(Game.Player.Handle, false); await Delay(4000); int[] color = colors[newIndex]; SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, color[0], color[1], color[2]); SetPlayerCanLeaveParachuteSmokeTrail(Game.Player.Handle, newIndex != 0); switching = false; } } else if (item == primaryChutes) { item.Description = $"Primary chute: {chuteDescriptions[newIndex]}"; SetPlayerParachuteTintIndex(Game.Player.Handle, newIndex); } else if (item == secondaryChutes) { item.Description = $"Reserve chute: {chuteDescriptions[newIndex]}"; SetPlayerReserveParachuteTintIndex(Game.Player.Handle, newIndex); } } parachuteMenu.OnListItemSelect += (sender, item, index, itemIndex) => IndexChangedEventHandler(sender, item, -1, index, itemIndex); parachuteMenu.OnListIndexChange += IndexChangedEventHandler; } #endregion #region Create Weapon Category Submenus MenuItem spacer = GetSpacerMenuItem("↓ Weapon Categories ↓"); menu.AddMenuItem(spacer); Menu handGuns = new Menu("Weapons", "Handguns"); MenuItem handGunsBtn = new MenuItem("Handguns"); Menu rifles = new Menu("Weapons", "Assault Rifles"); MenuItem riflesBtn = new MenuItem("Assault Rifles"); Menu shotguns = new Menu("Weapons", "Shotguns"); MenuItem shotgunsBtn = new MenuItem("Shotguns"); Menu smgs = new Menu("Weapons", "Sub-/Light Machine Guns"); MenuItem smgsBtn = new MenuItem("Sub-/Light Machine Guns"); Menu throwables = new Menu("Weapons", "Throwables"); MenuItem throwablesBtn = new MenuItem("Throwables"); Menu melee = new Menu("Weapons", "Melee"); MenuItem meleeBtn = new MenuItem("Melee"); Menu heavy = new Menu("Weapons", "Heavy Weapons"); MenuItem heavyBtn = new MenuItem("Heavy Weapons"); Menu snipers = new Menu("Weapons", "Sniper Rifles"); MenuItem snipersBtn = new MenuItem("Sniper Rifles"); MenuController.AddSubmenu(menu, handGuns); MenuController.AddSubmenu(menu, rifles); MenuController.AddSubmenu(menu, shotguns); MenuController.AddSubmenu(menu, smgs); MenuController.AddSubmenu(menu, throwables); MenuController.AddSubmenu(menu, melee); MenuController.AddSubmenu(menu, heavy); MenuController.AddSubmenu(menu, snipers); #endregion #region Setup weapon category buttons and submenus. handGunsBtn.Label = "→→→"; menu.AddMenuItem(handGunsBtn); MenuController.BindMenuItem(menu, handGuns, handGunsBtn); riflesBtn.Label = "→→→"; menu.AddMenuItem(riflesBtn); MenuController.BindMenuItem(menu, rifles, riflesBtn); shotgunsBtn.Label = "→→→"; menu.AddMenuItem(shotgunsBtn); MenuController.BindMenuItem(menu, shotguns, shotgunsBtn); smgsBtn.Label = "→→→"; menu.AddMenuItem(smgsBtn); MenuController.BindMenuItem(menu, smgs, smgsBtn); throwablesBtn.Label = "→→→"; menu.AddMenuItem(throwablesBtn); MenuController.BindMenuItem(menu, throwables, throwablesBtn); meleeBtn.Label = "→→→"; menu.AddMenuItem(meleeBtn); MenuController.BindMenuItem(menu, melee, meleeBtn); heavyBtn.Label = "→→→"; menu.AddMenuItem(heavyBtn); MenuController.BindMenuItem(menu, heavy, heavyBtn); snipersBtn.Label = "→→→"; menu.AddMenuItem(snipersBtn); MenuController.BindMenuItem(menu, snipers, snipersBtn); #endregion #region Loop through all weapons, create menus for them and add all menu items and handle events. foreach (ValidWeapon weapon in ValidWeapons.WeaponList) { uint cat = (uint)GetWeapontypeGroup(weapon.Hash); if (!string.IsNullOrEmpty(weapon.Name) && IsAllowed(weapon.Perm)) { //Log($"[DEBUG LOG] [WEAPON-BUG] {weapon.Name} - {weapon.Perm} = {IsAllowed(weapon.Perm)} & All = {IsAllowed(Permission.WPGetAll)}"); #region Create menu for this weapon and add buttons Menu weaponMenu = new Menu("Weapon Options", weapon.Name) { ShowWeaponStatsPanel = true }; var stats = new Game.WeaponHudStats(); Game.GetWeaponHudStats(weapon.Hash, ref stats); weaponMenu.SetWeaponStats((float)stats.hudDamage / 100f, (float)stats.hudSpeed / 100f, (float)stats.hudAccuracy / 100f, (float)stats.hudRange / 100f); MenuItem weaponItem = new MenuItem(weapon.Name, $"Open the options for ~y~{weapon.Name.ToString()}~s~.") { Label = "→→→", LeftIcon = MenuItem.Icon.GUN, ItemData = stats }; weaponInfo.Add(weaponMenu, weapon); MenuItem getOrRemoveWeapon = new MenuItem("Equip/Remove Weapon", "Add or remove this weapon to/form your inventory.") { LeftIcon = MenuItem.Icon.GUN }; weaponMenu.AddMenuItem(getOrRemoveWeapon); if (!IsAllowed(Permission.WPSpawn)) { getOrRemoveWeapon.Enabled = false; getOrRemoveWeapon.Description = "You do not have permission to use this option."; getOrRemoveWeapon.LeftIcon = MenuItem.Icon.LOCK; } MenuItem fillAmmo = new MenuItem("Re-fill Ammo", "Get max ammo for this weapon.") { LeftIcon = MenuItem.Icon.AMMO }; weaponMenu.AddMenuItem(fillAmmo); List <string> tints = new List <string>(); if (weapon.Name.Contains(" Mk II")) { foreach (var tint in ValidWeapons.WeaponTintsMkII) { tints.Add(tint.Key); } } else { foreach (var tint in ValidWeapons.WeaponTints) { tints.Add(tint.Key); } } MenuListItem weaponTints = new MenuListItem("Tints", tints, 0, "Select a tint for your weapon."); weaponMenu.AddMenuItem(weaponTints); #endregion #region Handle weapon specific list changes weaponMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == weaponTints) { if (HasPedGotWeapon(Game.PlayerPed.Handle, weaponInfo[sender].Hash, false)) { SetPedWeaponTintIndex(Game.PlayerPed.Handle, weaponInfo[sender].Hash, newIndex); } else { Notify.Error("You need to get the weapon first!"); } } }; #endregion #region Handle weapon specific button presses weaponMenu.OnItemSelect += (sender, item, index) => { var info = weaponInfo[sender]; uint hash = info.Hash; SetCurrentPedWeapon(Game.PlayerPed.Handle, hash, true); if (item == getOrRemoveWeapon) { if (HasPedGotWeapon(Game.PlayerPed.Handle, hash, false)) { RemoveWeaponFromPed(Game.PlayerPed.Handle, hash); Subtitle.Custom("Weapon removed."); } else { var ammo = 255; GetMaxAmmo(Game.PlayerPed.Handle, hash, ref ammo); GiveWeaponToPed(Game.PlayerPed.Handle, hash, ammo, false, true); Subtitle.Custom("Weapon added."); } } else if (item == fillAmmo) { if (HasPedGotWeapon(Game.PlayerPed.Handle, hash, false)) { var ammo = 900; GetMaxAmmo(Game.PlayerPed.Handle, hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, hash, ammo); } else { Notify.Error("You need to get the weapon first before re-filling ammo!"); } } }; #endregion #region load components if (weapon.Components != null) { if (weapon.Components.Count > 0) { foreach (var comp in weapon.Components) { //Log($"{weapon.Name} : {comp.Key}"); MenuItem compItem = new MenuItem(comp.Key, "Click to equip or remove this component."); weaponComponents.Add(compItem, comp.Key); weaponMenu.AddMenuItem(compItem); #region Handle component button presses weaponMenu.OnItemSelect += (sender, item, index) => { if (item == compItem) { var Weapon = weaponInfo[sender]; var componentHash = Weapon.Components[weaponComponents[item]]; if (HasPedGotWeapon(Game.PlayerPed.Handle, Weapon.Hash, false)) { SetCurrentPedWeapon(Game.PlayerPed.Handle, Weapon.Hash, true); if (HasPedGotWeaponComponent(Game.PlayerPed.Handle, Weapon.Hash, componentHash)) { RemoveWeaponComponentFromPed(Game.PlayerPed.Handle, Weapon.Hash, componentHash); Subtitle.Custom("Component removed."); } else { int ammo = GetAmmoInPedWeapon(Game.PlayerPed.Handle, Weapon.Hash); int clipAmmo = GetMaxAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, false); GetAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, ref clipAmmo); GiveWeaponComponentToPed(Game.PlayerPed.Handle, Weapon.Hash, componentHash); SetAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, clipAmmo); SetPedAmmo(Game.PlayerPed.Handle, Weapon.Hash, ammo); Subtitle.Custom("Component equiped."); } } else { Notify.Error("You need to get the weapon first before you can modify it."); } } }; #endregion } } } #endregion // refresh and add to menu. weaponMenu.RefreshIndex(); if (cat == 970310034) // 970310034 rifles { MenuController.AddSubmenu(rifles, weaponMenu); MenuController.BindMenuItem(rifles, weaponMenu, weaponItem); rifles.AddMenuItem(weaponItem); } else if (cat == 416676503 || cat == 690389602) // 416676503 hand guns // 690389602 stun gun { MenuController.AddSubmenu(handGuns, weaponMenu); MenuController.BindMenuItem(handGuns, weaponMenu, weaponItem); handGuns.AddMenuItem(weaponItem); } else if (cat == 860033945) // 860033945 shotguns { MenuController.AddSubmenu(shotguns, weaponMenu); MenuController.BindMenuItem(shotguns, weaponMenu, weaponItem); shotguns.AddMenuItem(weaponItem); } else if (cat == 3337201093 || cat == 1159398588) // 3337201093 sub machine guns // 1159398588 light machine guns { MenuController.AddSubmenu(smgs, weaponMenu); MenuController.BindMenuItem(smgs, weaponMenu, weaponItem); smgs.AddMenuItem(weaponItem); } else if (cat == 1548507267 || cat == 4257178988 || cat == 1595662460) // 1548507267 throwables // 4257178988 fire extinghuiser // jerry can { MenuController.AddSubmenu(throwables, weaponMenu); MenuController.BindMenuItem(throwables, weaponMenu, weaponItem); throwables.AddMenuItem(weaponItem); } else if (cat == 3566412244 || cat == 2685387236) // 3566412244 melee weapons // 2685387236 knuckle duster { MenuController.AddSubmenu(melee, weaponMenu); MenuController.BindMenuItem(melee, weaponMenu, weaponItem); melee.AddMenuItem(weaponItem); } else if (cat == 2725924767) // 2725924767 heavy weapons { MenuController.AddSubmenu(heavy, weaponMenu); MenuController.BindMenuItem(heavy, weaponMenu, weaponItem); heavy.AddMenuItem(weaponItem); } else if (cat == 3082541095) // 3082541095 sniper rifles { MenuController.AddSubmenu(snipers, weaponMenu); MenuController.BindMenuItem(snipers, weaponMenu, weaponItem); snipers.AddMenuItem(weaponItem); } } } #endregion #region Disable submenus if no weapons in that category are allowed. if (handGuns.Size == 0) { handGunsBtn.LeftIcon = MenuItem.Icon.LOCK; handGunsBtn.Description = "The server owner removed the permissions for all weapons in this category."; handGunsBtn.Enabled = false; } if (rifles.Size == 0) { riflesBtn.LeftIcon = MenuItem.Icon.LOCK; riflesBtn.Description = "The server owner removed the permissions for all weapons in this category."; riflesBtn.Enabled = false; } if (shotguns.Size == 0) { shotgunsBtn.LeftIcon = MenuItem.Icon.LOCK; shotgunsBtn.Description = "The server owner removed the permissions for all weapons in this category."; shotgunsBtn.Enabled = false; } if (smgs.Size == 0) { smgsBtn.LeftIcon = MenuItem.Icon.LOCK; smgsBtn.Description = "The server owner removed the permissions for all weapons in this category."; smgsBtn.Enabled = false; } if (throwables.Size == 0) { throwablesBtn.LeftIcon = MenuItem.Icon.LOCK; throwablesBtn.Description = "The server owner removed the permissions for all weapons in this category."; throwablesBtn.Enabled = false; } if (melee.Size == 0) { meleeBtn.LeftIcon = MenuItem.Icon.LOCK; meleeBtn.Description = "The server owner removed the permissions for all weapons in this category."; meleeBtn.Enabled = false; } if (heavy.Size == 0) { heavyBtn.LeftIcon = MenuItem.Icon.LOCK; heavyBtn.Description = "The server owner removed the permissions for all weapons in this category."; heavyBtn.Enabled = false; } if (snipers.Size == 0) { snipersBtn.LeftIcon = MenuItem.Icon.LOCK; snipersBtn.Description = "The server owner removed the permissions for all weapons in this category."; snipersBtn.Enabled = false; } #endregion #region Handle button presses menu.OnItemSelect += (sender, item, index) => { Ped ped = new Ped(Game.PlayerPed.Handle); if (item == getAllWeapons) { foreach (ValidWeapon vw in ValidWeapons.WeaponList) { if (IsAllowed(vw.Perm)) { GiveWeaponToPed(Game.PlayerPed.Handle, vw.Hash, vw.GetMaxAmmo, false, true); int ammoInClip = GetMaxAmmoInClip(Game.PlayerPed.Handle, vw.Hash, false); SetAmmoInClip(Game.PlayerPed.Handle, vw.Hash, ammoInClip); int ammo = 0; GetMaxAmmo(Game.PlayerPed.Handle, vw.Hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, vw.Hash, ammo); } } SetCurrentPedWeapon(Game.PlayerPed.Handle, (uint)GetHashKey("weapon_unarmed"), true); } else if (item == removeAllWeapons) { ped.Weapons.RemoveAll(); } else if (item == setAmmo) { SetAllWeaponsAmmo(); } else if (item == refillMaxAmmo) { foreach (ValidWeapon vw in ValidWeapons.WeaponList) { if (HasPedGotWeapon(Game.PlayerPed.Handle, vw.Hash, false)) { int ammoInClip = GetMaxAmmoInClip(Game.PlayerPed.Handle, vw.Hash, false); SetAmmoInClip(Game.PlayerPed.Handle, vw.Hash, ammoInClip); int ammo = 0; GetMaxAmmo(Game.PlayerPed.Handle, vw.Hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, vw.Hash, ammo); } } } else if (item == spawnByName) { SpawnCustomWeapon(); } }; #endregion #region Handle checkbox changes menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == noReload) { NoReload = _checked; Subtitle.Custom($"No reload is now {(_checked ? "enabled" : "disabled")}."); } else if (item == unlimitedAmmo) { UnlimitedAmmo = _checked; Subtitle.Custom($"Unlimited ammo is now {(_checked ? "enabled" : "disabled")}."); } }; #endregion void OnIndexChange(Menu m, MenuItem i) { if (i.ItemData is Game.WeaponHudStats stats) { m.SetWeaponStats((float)stats.hudDamage / 100f, (float)stats.hudSpeed / 100f, (float)stats.hudAccuracy / 100f, (float)stats.hudRange / 100f); m.ShowWeaponStatsPanel = true; } else { m.ShowWeaponStatsPanel = false; } } handGuns.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; rifles.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; shotguns.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; smgs.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; throwables.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; melee.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; heavy.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; snipers.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { OnIndexChange(sender, newItem); }; handGuns.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; rifles.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; shotguns.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; smgs.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; throwables.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; melee.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; heavy.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; snipers.OnMenuOpen += (sender) => { OnIndexChange(sender, sender.GetCurrentMenuItem()); }; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(playersListMenu); playersListMenu.OnMenuOpen += (_menu) => { playersListMenu.ClearMenuItems(); idPlayers.Clear(); foreach (var i in API.GetActivePlayers()) { string name = API.GetPlayerName(i).ToString(); string id = API.GetPlayerServerId(i).ToString(); idPlayers.Add(i); MenuController.AddSubmenu(playersListMenu, playersOptionsMenu); MenuItem playerNameButton = new MenuItem(name, $"{name},{id}") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; playersListMenu.AddMenuItem(playerNameButton); MenuController.BindMenuItem(playersListMenu, playersOptionsMenu, playerNameButton); } }; playersListMenu.OnItemSelect += (_menu, _item, _index) => { indexPlayer = _index; playersOptionsMenu.MenuTitle = API.GetPlayerName(idPlayers.ElementAt(indexPlayer)) + "," + API.GetPlayerServerId((idPlayers.ElementAt(indexPlayer))); }; playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitle"], GetConfig.Langs["SpectateDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitleOff"], GetConfig.Langs["SpectateDescOff"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["ReviveTitle"], GetConfig.Langs["ReviveDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["HealTitle"], GetConfig.Langs["HealDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["TpToPlayerTitle"], GetConfig.Langs["TpToPlayerDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["BringPlayerTitle"], GetConfig.Langs["BringPlayerDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FreezeTitle"], GetConfig.Langs["FreezeDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["KickPlayerTitle"], GetConfig.Langs["KickPlayerDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerDesc"]) { Enabled = true, }); if (GetUserInfo.userGroup.Contains("admin")) { playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SlapTitle"], GetConfig.Langs["SlapDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["LightningTitle"], GetConfig.Langs["LightningDesc"]) { Enabled = true, }); playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FireTitle"], GetConfig.Langs["FireDesc"]) { Enabled = true, }); } playersOptionsMenu.OnItemSelect += async(_menu, _item, _index) => { if (_index == 0) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.Spectate(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 1) { AdministrationFunctions.SpectateOff(MainMenu.args); } else if (_index == 2) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.Revive(MainMenu.args); } else if (_index == 3) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.Heal(MainMenu.args); } else if (_index == 4) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); TeleportsFunctions.TpToPlayer(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 5) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); TeleportsFunctions.TpBring(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 6) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.StopPlayer(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 7) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.Kick(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 8) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); dynamic time = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerTime"]); MainMenu.args.Add(time); dynamic reason = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerReason"]); MainMenu.args.Add(reason); AdministrationFunctions.Ban(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 9) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.Slap(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 10) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.ThorToId(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 11) { MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer))); AdministrationFunctions.FireToId(MainMenu.args); MainMenu.args.Clear(); } }; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(buyCompsMenu); MenuController.EnableMenuToggleKeyOnController = false; MenuController.MenuToggleKey = (Control)0; MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseMantas); MenuItem buttonBuyComplementsCatMantas = new MenuItem(GetConfig.CompsLists.ElementAt(0).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatMantas); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseMantas, buttonBuyComplementsCatMantas); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseCuernos); MenuItem buttonBuyComplementsCatCuernos = new MenuItem(GetConfig.CompsLists.ElementAt(1).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatCuernos); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseCuernos, buttonBuyComplementsCatCuernos); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseAlforjas); MenuItem buttonBuyComplementsCatAlforjas = new MenuItem(GetConfig.CompsLists.ElementAt(2).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatAlforjas); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseAlforjas, buttonBuyComplementsCatAlforjas); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseColas); MenuItem buttonBuyComplementsCatColas = new MenuItem(GetConfig.CompsLists.ElementAt(3).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatColas); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseColas, buttonBuyComplementsCatColas); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseCrines); MenuItem buttonBuyComplementsCatCrines = new MenuItem(GetConfig.CompsLists.ElementAt(4).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatCrines); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseCrines, buttonBuyComplementsCatCrines); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseMonturas); MenuItem buttonBuyComplementsCatMonturas = new MenuItem(GetConfig.CompsLists.ElementAt(5).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatMonturas); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseMonturas, buttonBuyComplementsCatMonturas); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseEstribos); MenuItem buttonBuyComplementsCatEstribos = new MenuItem(GetConfig.CompsLists.ElementAt(6).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatEstribos); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseEstribos, buttonBuyComplementsCatEstribos); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorsePetates); MenuItem buttonBuyComplementsCatPetates = new MenuItem(GetConfig.CompsLists.ElementAt(7).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatPetates); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorsePetates, buttonBuyComplementsCatPetates); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseLantern); MenuItem buttonBuyComplementsCatLantern = new MenuItem(GetConfig.CompsLists.ElementAt(8).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatLantern); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseLantern, buttonBuyComplementsCatLantern); MenuController.AddSubmenu(buyCompsMenu, subMenuCatComplementsHorseMask); MenuItem buttonBuyComplementsCatMask = new MenuItem(GetConfig.CompsLists.ElementAt(9).Key, "") { RightIcon = MenuItem.Icon.SADDLE }; buyCompsMenu.AddMenuItem(buttonBuyComplementsCatMask); MenuController.BindMenuItem(buyCompsMenu, subMenuCatComplementsHorseMask, buttonBuyComplementsCatMask); buyCompsMenu.AddMenuItem(confirmBuy); //Events buyCompsMenu.OnItemSelect += (_menu, _item, _index) => { if (_index == 10) { StablesShop.BuyComp(); } else { StablesShop.indexCategory = _index; } }; subMenuCatComplementsHorseMantas.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseMantas.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseCuernos.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseCuernos.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseAlforjas.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseAlforjas.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseColas.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseColas.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseCrines.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseCrines.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseMonturas.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseMonturas.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseEstribos.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseEstribos.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorsePetates.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorsePetates.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseLantern.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseLantern.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; subMenuCatComplementsHorseMask.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); foreach (MenuListItem algo in subMenuCatComplementsHorseMask.GetMenuItems()) { if (algo.Index != _itemIndex) { algo.ListIndex = 0; } } await StablesShop.LoadHorseCompsPreview(StablesShop.indexCategory, _itemIndex, _newIndex); }; buyCompsMenu.OnMenuOpen += (_menu) => { StablesShop.CalcPrice(); }; buyCompsMenu.OnMenuClose += (_menu) => { StablesShop.MyhorseIsLoaded = false; }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { // Create the menu. menu = new Menu(Game.Player.Name, "Online Players") { }; menu.CounterPreText = "Players: "; MenuController.AddSubmenu(menu, playerMenu); MenuItem sendMessage = new MenuItem("Send Private Message", "Sends a private message to this player. ~r~Note: staff may be able to see all PM's."); MenuItem teleport = new MenuItem("Teleport To Player", "Teleport to this player."); MenuItem teleportVeh = new MenuItem("Teleport Into Player Vehicle", "Teleport into the vehicle of the player."); MenuItem summon = new MenuItem("Summon Player", "Teleport the player to you."); MenuItem toggleGPS = new MenuItem("Toggle GPS", "Enables or disables the GPS route on your radar to this player."); MenuItem spectate = new MenuItem("Spectate Player", "Spectate this player. Click this button again to stop spectating."); MenuItem printIdentifiers = new MenuItem("Print Identifiers", "This will print the player's identifiers to the client console (F8). And also save it to the CitizenFX.log file."); MenuItem kill = new MenuItem("~r~Kill Player", "Kill this player, note they will receive a notification saying that you killed them. It will also be logged in the Staff Actions log."); MenuItem kick = new MenuItem("~r~Kick Player", "Kick the player from the server."); MenuItem ban = new MenuItem("~r~Ban Player Permanently", "Ban this player permanently from the server. Are you sure you want to do this? You can specify the ban reason after clicking this button."); MenuItem tempban = new MenuItem("~r~Ban Player Temporarily", "Give this player a tempban of up to 30 days (max). You can specify duration and ban reason after clicking this button."); // always allowed playerMenu.AddMenuItem(sendMessage); // permissions specific if (IsAllowed(Permission.OPTeleport)) { playerMenu.AddMenuItem(teleport); playerMenu.AddMenuItem(teleportVeh); } if (IsAllowed(Permission.OPSummon)) { playerMenu.AddMenuItem(summon); } if (IsAllowed(Permission.OPSpectate)) { playerMenu.AddMenuItem(spectate); } if (IsAllowed(Permission.OPWaypoint)) { playerMenu.AddMenuItem(toggleGPS); } if (IsAllowed(Permission.OPIdentifiers)) { playerMenu.AddMenuItem(printIdentifiers); } if (IsAllowed(Permission.OPKill)) { playerMenu.AddMenuItem(kill); } if (IsAllowed(Permission.OPKick)) { playerMenu.AddMenuItem(kick); } if (IsAllowed(Permission.OPTempBan)) { playerMenu.AddMenuItem(tempban); } if (IsAllowed(Permission.OPPermBan)) { playerMenu.AddMenuItem(ban); ban.LeftIcon = MenuItem.Icon.WARNING; } playerMenu.OnMenuClose += (sender) => { playerMenu.RefreshIndex(); ban.Label = ""; }; playerMenu.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { ban.Label = ""; }; // handle button presses for the specific player's menu. playerMenu.OnItemSelect += async(sender, item, index) => { // send message if (item == sendMessage) { if (MainMenu.MiscSettingsMenu != null && !MainMenu.MiscSettingsMenu.MiscDisablePrivateMessages) { string message = await GetUserInput($"Private Message To {currentPlayer.Name}", 200); if (string.IsNullOrEmpty(message)) { Notify.Error(CommonErrors.InvalidInput); } else { TriggerServerEvent("vMenu:SendMessageToPlayer", currentPlayer.ServerId, message); PrivateMessage(currentPlayer.ServerId.ToString(), message, true); } } else { Notify.Error("You can't send a private message if you have private messages disabled yourself. Enable them in the Misc Settings menu and try again."); } } // teleport (in vehicle) button else if (item == teleport || item == teleportVeh) { if (!currentPlayer.IsLocal) { _ = TeleportToPlayer(currentPlayer, item == teleportVeh); // teleport to the player. optionally in the player's vehicle if that button was pressed. } else { Notify.Error("You can not teleport to yourself!"); } } // summon button else if (item == summon) { if (Game.Player.Handle != currentPlayer.Handle) { SummonPlayer(currentPlayer); } else { Notify.Error("You can't summon yourself."); } } // spectating else if (item == spectate) { SpectatePlayer(currentPlayer); } // kill button else if (item == kill) { KillPlayer(currentPlayer); TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat die Kill-Funktion auf " + currentPlayer.Name + " angewendet."); } // manage the gps route being clicked. else if (item == toggleGPS) { bool selectedPedRouteAlreadyActive = false; if (PlayersWaypointList.Count > 0) { if (PlayersWaypointList.Contains(currentPlayer.Handle)) { selectedPedRouteAlreadyActive = true; } foreach (int playerId in PlayersWaypointList) { int playerPed = GetPlayerPed(playerId); if (DoesEntityExist(playerPed) && DoesBlipExist(GetBlipFromEntity(playerPed))) { int oldBlip = GetBlipFromEntity(playerPed); SetBlipRoute(oldBlip, false); RemoveBlip(ref oldBlip); Notify.Custom($"~g~GPS route to ~s~<C>{GetSafePlayerName(currentPlayer.Name)}</C>~g~ is now disabled."); } } PlayersWaypointList.Clear(); } if (!selectedPedRouteAlreadyActive) { if (currentPlayer.Handle != Game.Player.Handle) { int ped = GetPlayerPed(currentPlayer.Handle); int blip = GetBlipFromEntity(ped); if (DoesBlipExist(blip)) { SetBlipColour(blip, 58); SetBlipRouteColour(blip, 58); SetBlipRoute(blip, true); } else { blip = AddBlipForEntity(ped); SetBlipColour(blip, 58); SetBlipRouteColour(blip, 58); SetBlipRoute(blip, true); } PlayersWaypointList.Add(currentPlayer.Handle); Notify.Custom($"~g~GPS route to ~s~<C>{GetSafePlayerName(currentPlayer.Name)}</C>~g~ is now active, press the ~s~Toggle GPS Route~g~ button again to disable the route."); } else { Notify.Error("You can not set a waypoint to yourself."); } } } else if (item == printIdentifiers) { Func <string, string> CallbackFunction = (data) => { Debug.WriteLine(data); string ids = "~s~"; foreach (string s in JsonConvert.DeserializeObject <string[]>(data)) { ids += "~n~" + s; } Notify.Custom($"~y~<C>{GetSafePlayerName(currentPlayer.Name)}</C>~g~'s Identifiers: {ids}", false); return(data); }; BaseScript.TriggerServerEvent("vMenu:GetPlayerIdentifiers", currentPlayer.ServerId, CallbackFunction); } // kick button else if (item == kick) { if (currentPlayer.Handle != Game.Player.Handle) { KickPlayer(currentPlayer, true); TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat " + currentPlayer.Name + " gekickt."); } else { Notify.Error("You cannot kick yourself!"); } } // temp ban else if (item == tempban) { BanPlayer(currentPlayer, false); } // perm ban else if (item == ban) { if (ban.Label == "Are you sure?") { ban.Label = ""; _ = UpdatePlayerlist(); playerMenu.GoBack(); BanPlayer(currentPlayer, true); TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat " + currentPlayer.Name + " gebannt. (vMenu)"); } else { ban.Label = "Are you sure?"; } } }; // handle button presses in the player list. menu.OnItemSelect += (sender, item, index) => { var baseId = int.Parse(item.Label.Replace(" →→→", "").Replace("Server #", "")); var player = MainMenu.PlayersList.FirstOrDefault(p => p.ServerId == baseId); if (player != null) { currentPlayer = player; playerMenu.MenuSubtitle = $"~s~Player: ~y~{GetSafePlayerName(currentPlayer.Name)}"; playerMenu.CounterPreText = $"[Server ID: ~y~{currentPlayer.ServerId}~s~] "; } else { playerMenu.GoBack(); } }; }
public DispatchMenu() { /////////////////////////////////////////////////////////////// ////////////////////// [ First Screen ] ////////////////////// /////////////////////////////////////////////////////////////// // Align the menu to the left side of the screen MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; // MenuController.MenuToggleKey = Control.VehicleBikeWings; // Create the first screen of the menu then add it to the menu controller Menu mainDispatchMenu = new Menu("Emergency Services", "What emergency service do you require?"); MenuController.AddMenu(mainDispatchMenu); // Create the options for the first screen // View Logged Calls mainDispatchMenu.AddMenuItem(new MenuItem("View Call Log", "Shows a list of all previously made calls") { Enabled = true }); // Events EventHandlers["EDS:OpenDispatchMenu"] += new Action(mainDispatchMenu.OpenMenu); mainDispatchMenu.OnItemSelect += (_menu, _item, _index) => { switch (_index) { case 0: break; } }; /////////////////////////////////////////////////////////////// //////////////// [ Dispatch Call Log Screen ] //////////////// /////////////////////////////////////////////////////////////// // Create the menu Menu callLogMenu = new Menu("Dispatch Call Log"); MenuController.AddSubmenu(mainDispatchMenu, callLogMenu); // Bind first item of previous menu screen to open this sub menu MenuController.BindMenuItem(mainDispatchMenu, callLogMenu, mainDispatchMenu.GetMenuItems()[0]); // Events callLogMenu.OnMenuOpen += (_menu) => { callLogMenu.ClearMenuItems(); foreach (EmergencyCall ec in CallHelper.GetAllCalls()) { // Create the menu item, add it to the call log menu MenuItem currCallItem = new MenuItem("[" + ec.GetTime() + "] [" + MessageHelper.ConvertNotificationTypeToString(ec.GetServiceType()) + "] ~w~" + ec.GetMessage()); callLogMenu.AddMenuItem(currCallItem); // Create a sub menu for the current call Menu currentCallMenu = new Menu("Dispatch Call at " + ec.GetTime()); MenuController.AddSubmenu(callLogMenu, currentCallMenu); // Set up items for current call menu currentCallMenu.AddMenuItem(new MenuItem("Set waypoint to location")); // Bind current call sub menu to the dispatch menu to allow it to be opened MenuController.BindMenuItem(callLogMenu, currentCallMenu, currCallItem); // Event handlers for the call menu's items currentCallMenu.OnItemSelect += (_submenu, _item, _index) => { SetNewWaypoint(ec.GetLocation().X, ec.GetLocation().Y); }; } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { #region create main weapon options menu and add items // Create the menu. menu = new Menu(Game.Player.Name, "Weapon Options"); MenuItem getAllWeapons = new MenuItem("Get All Weapons", "Get all weapons."); MenuItem removeAllWeapons = new MenuItem("Remove All Weapons", "Removes all weapons in your inventory."); MenuCheckboxItem unlimitedAmmo = new MenuCheckboxItem("Unlimited Ammo", "Unlimited ammonition supply.", UnlimitedAmmo); MenuCheckboxItem noReload = new MenuCheckboxItem("No Reload", "Never reload.", NoReload); MenuItem setAmmo = new MenuItem("Set All Ammo Count", "Set the amount of ammo in all your weapons."); MenuItem refillMaxAmmo = new MenuItem("Refill All Ammo", "Give all your weapons max ammo."); MenuItem spawnByName = new MenuItem("Spawn Weapon By Name", "Enter a weapon mode name to spawn."); // Add items based on permissions if (IsAllowed(Permission.WPGetAll)) { menu.AddMenuItem(getAllWeapons); } if (IsAllowed(Permission.WPRemoveAll)) { menu.AddMenuItem(removeAllWeapons); } if (IsAllowed(Permission.WPUnlimitedAmmo)) { menu.AddMenuItem(unlimitedAmmo); } if (IsAllowed(Permission.WPNoReload)) { menu.AddMenuItem(noReload); } if (IsAllowed(Permission.WPSetAllAmmo)) { menu.AddMenuItem(setAmmo); menu.AddMenuItem(refillMaxAmmo); } if (IsAllowed(Permission.WPSpawnByName)) { menu.AddMenuItem(spawnByName); } #endregion #region addonweapons submenu MenuItem addonWeaponsBtn = new MenuItem("Addon Weapons", "Equip / remove addon weapons available on this server."); Menu addonWeaponsMenu = new Menu("Addon Weapons", "Equip/Remove Addon Weapons"); menu.AddMenuItem(addonWeaponsBtn); #region manage creating and accessing addon weapons menu if (IsAllowed(Permission.WPSpawn) && AddonWeapons != null && AddonWeapons.Count > 0) { MenuController.BindMenuItem(menu, addonWeaponsMenu, addonWeaponsBtn); foreach (KeyValuePair <string, uint> weapon in AddonWeapons) { string name = weapon.Key.ToString(); uint model = weapon.Value; var item = new MenuItem(name, $"Click to add/remove this weapon ({name}) to/from your inventory."); addonWeaponsMenu.AddMenuItem(item); if (!IsWeaponValid(model)) { item.Enabled = false; item.LeftIcon = MenuItem.Icon.LOCK; item.Description = "This model is not available. Please ask the server owner to verify it's being streamed correctly."; } } addonWeaponsMenu.OnItemSelect += (sender, item, index) => { var weapon = AddonWeapons.ElementAt(index); if (HasPedGotWeapon(Game.PlayerPed.Handle, weapon.Value, false)) { RemoveWeaponFromPed(Game.PlayerPed.Handle, weapon.Value); } else { var maxAmmo = 200; GetMaxAmmo(Game.PlayerPed.Handle, weapon.Value, ref maxAmmo); GiveWeaponToPed(Game.PlayerPed.Handle, weapon.Value, maxAmmo, false, true); } }; addonWeaponsBtn.Label = "→→→"; } else { addonWeaponsBtn.LeftIcon = MenuItem.Icon.LOCK; addonWeaponsBtn.Enabled = false; addonWeaponsBtn.Description = "This option is not available on this server because you don't have permission to use it, or it is not setup correctly."; } #endregion //addonWeaponsMenu. addonWeaponsMenu.RefreshIndex(); //addonWeaponsMenu.UpdateScaleform(); #endregion #region parachute options menu #region parachute buttons and submenus MenuItem parachuteBtn = new MenuItem("Parachute Options", "All parachute related options can be changed here."); Menu parachuteMenu = new Menu("Parachute Options", "Parachute Options"); Menu primaryChute = new Menu("Parachute Options", "Select A Primary Parachute"); Menu secondaryChute = new Menu("Parachute Options", "Select A Reserve Parachute"); MenuItem chute = new MenuItem("No Style", "Default parachute."); MenuItem chute0 = new MenuItem(GetLabelText("PM_TINT0"), GetLabelText("PD_TINT0")); // Rainbow Chute MenuItem chute1 = new MenuItem(GetLabelText("PM_TINT1"), GetLabelText("PD_TINT1")); // Red Chute MenuItem chute2 = new MenuItem(GetLabelText("PM_TINT2"), GetLabelText("PD_TINT2")); // Seaside Stripes Chute MenuItem chute3 = new MenuItem(GetLabelText("PM_TINT3"), GetLabelText("PD_TINT3")); // Window Maker Chute MenuItem chute4 = new MenuItem(GetLabelText("PM_TINT4"), GetLabelText("PD_TINT4")); // Patriot Chute MenuItem chute5 = new MenuItem(GetLabelText("PM_TINT5"), GetLabelText("PD_TINT5")); // Blue Chute MenuItem chute6 = new MenuItem(GetLabelText("PM_TINT6"), GetLabelText("PD_TINT6")); // Black Chute MenuItem chute7 = new MenuItem(GetLabelText("PM_TINT7"), GetLabelText("PD_TINT7")); // Hornet Chute MenuItem chute8 = new MenuItem(GetLabelText("PS_CAN_0"), "Air Force parachute."); // Air Force Chute MenuItem chute9 = new MenuItem(GetLabelText("PM_TINT0"), "Desert parachute."); // Desert Chute MenuItem chute10 = new MenuItem("Shadow Chute", "Shadow parachute."); // Shadow Chute MenuItem chute11 = new MenuItem(GetLabelText("UNLOCK_NAME_PSRWD"), "High altitude parachute."); // High Altitude Chute MenuItem chute12 = new MenuItem("Airborne Chute", "Airborne parachute."); // Airborne Chute MenuItem chute13 = new MenuItem("Sunrise Chute", "Sunrise parachute."); // Sunrise Chute MenuItem rchute = new MenuItem("No Style", "Default parachute."); MenuItem rchute0 = new MenuItem(GetLabelText("PM_TINT0"), GetLabelText("PD_TINT0")); // Rainbow Chute MenuItem rchute1 = new MenuItem(GetLabelText("PM_TINT1"), GetLabelText("PD_TINT1")); // Red Chute MenuItem rchute2 = new MenuItem(GetLabelText("PM_TINT2"), GetLabelText("PD_TINT2")); // Seaside Stripes Chute MenuItem rchute3 = new MenuItem(GetLabelText("PM_TINT3"), GetLabelText("PD_TINT3")); // Window Maker Chute MenuItem rchute4 = new MenuItem(GetLabelText("PM_TINT4"), GetLabelText("PD_TINT4")); // Patriot Chute MenuItem rchute5 = new MenuItem(GetLabelText("PM_TINT5"), GetLabelText("PD_TINT5")); // Blue Chute MenuItem rchute6 = new MenuItem(GetLabelText("PM_TINT6"), GetLabelText("PD_TINT6")); // Black Chute MenuItem rchute7 = new MenuItem(GetLabelText("PM_TINT7"), GetLabelText("PD_TINT7")); // Hornet Chute MenuItem rchute8 = new MenuItem(GetLabelText("PS_CAN_0"), "Air Force parachute."); // Air Force Chute MenuItem rchute9 = new MenuItem(GetLabelText("PM_TINT0"), "Desert parachute."); // Desert Chute MenuItem rchute10 = new MenuItem("Shadow Chute", "Shadow parachute."); // Shadow Chute MenuItem rchute11 = new MenuItem(GetLabelText("UNLOCK_NAME_PSRWD"), "High altitude parachute."); // High Altitude Chute MenuItem rchute12 = new MenuItem("Airborne Chute", "Airborne parachute."); // Airborne Chute MenuItem rchute13 = new MenuItem("Sunrise Chute", "Sunrise parachute."); // Sunrise Chute primaryChute.AddMenuItem(chute); primaryChute.AddMenuItem(chute0); primaryChute.AddMenuItem(chute1); primaryChute.AddMenuItem(chute2); primaryChute.AddMenuItem(chute3); primaryChute.AddMenuItem(chute4); primaryChute.AddMenuItem(chute5); primaryChute.AddMenuItem(chute6); primaryChute.AddMenuItem(chute7); primaryChute.AddMenuItem(chute8); primaryChute.AddMenuItem(chute9); primaryChute.AddMenuItem(chute10); primaryChute.AddMenuItem(chute11); primaryChute.AddMenuItem(chute12); primaryChute.AddMenuItem(chute13); secondaryChute.AddMenuItem(rchute); secondaryChute.AddMenuItem(rchute0); secondaryChute.AddMenuItem(rchute1); secondaryChute.AddMenuItem(rchute2); secondaryChute.AddMenuItem(rchute3); secondaryChute.AddMenuItem(rchute4); secondaryChute.AddMenuItem(rchute5); secondaryChute.AddMenuItem(rchute6); secondaryChute.AddMenuItem(rchute7); secondaryChute.AddMenuItem(rchute8); secondaryChute.AddMenuItem(rchute9); secondaryChute.AddMenuItem(rchute10); secondaryChute.AddMenuItem(rchute11); secondaryChute.AddMenuItem(rchute12); secondaryChute.AddMenuItem(rchute13); #endregion #region handle events primaryChute.OnItemSelect += (sender, item, index) => { SetPedParachuteTintIndex(Game.PlayerPed.Handle, index - 1); Subtitle.Custom($"Primary parachute style selected: ~r~{item.Text}~s~."); }; secondaryChute.OnItemSelect += (sender, item, index) => { SetPlayerReserveParachuteTintIndex(Game.Player.Handle, index - 1); Subtitle.Custom($"Reserve parachute style selected: ~r~{item.Text}~s~."); }; #endregion #region create more buttons MenuItem primaryChuteBtn = new MenuItem("Primary Parachute Style", "Select a primary parachute."); MenuItem secondaryChuteBtn = new MenuItem("Reserve Parachute Style", "Select a reserve parachute."); parachuteMenu.AddMenuItem(primaryChuteBtn); primaryChuteBtn.Label = "→→→"; parachuteMenu.AddMenuItem(secondaryChuteBtn); secondaryChuteBtn.Label = "→→→"; MenuController.BindMenuItem(parachuteMenu, primaryChute, primaryChuteBtn); MenuController.BindMenuItem(parachuteMenu, secondaryChute, secondaryChuteBtn); MenuCheckboxItem autoEquipParachute = new MenuCheckboxItem("Auto Equip Parachute", "Automatically equip a parachute whenever you enter a plane/helicopter.", AutoEquipChute); parachuteMenu.AddMenuItem(autoEquipParachute); MenuItem togglePrimary = new MenuItem("Get / Remove Primary Parachute", "Equip a primary parachute."); MenuItem toggleSecondary = new MenuItem("Get Reserve Parachute", "Equip a reserve parachute, you need to get a primary parachute first before equipping a reserve parachute."); parachuteMenu.AddMenuItem(togglePrimary); parachuteMenu.AddMenuItem(toggleSecondary); #endregion #region handle parachute menu events parachuteMenu.OnItemSelect += (sender, item, index) => { if (item == togglePrimary) { if (HasPedGotWeapon(Game.PlayerPed.Handle, (uint)WeaponHash.Parachute, false)) { RemoveWeaponFromPed(Game.PlayerPed.Handle, (uint)WeaponHash.Parachute); Notify.Success("Primary parachute ~r~removed~s~.", true); } else { GiveWeaponToPed(Game.PlayerPed.Handle, (uint)WeaponHash.Parachute, 1, false, false); Notify.Success("Primary parachute ~g~equippped~s~.", true); } } else if (item == toggleSecondary) { SetPlayerHasReserveParachute(Game.Player.Handle); Notify.Success("Reserve parachute ~g~equippped~s~.", true); } }; parachuteMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == autoEquipParachute) { AutoEquipChute = _checked; } }; #endregion #region parachute smoke trail colors List <string> smokeColor = new List <string>() { "White", "Yellow", "Red", "Green", "Blue", "Dark Gray", }; MenuListItem smokeColors = new MenuListItem("Smoke Trail Color", smokeColor, 0, "Select a parachute smoke trail color."); parachuteMenu.AddMenuItem(smokeColors); parachuteMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == smokeColors) { SetPlayerCanLeaveParachuteSmokeTrail(Game.Player.Handle, false); if (newIndex == 0) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 255, 255, 255); } else if (newIndex == 1) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 255, 255, 0); } else if (newIndex == 2) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 255, 0, 0); } else if (newIndex == 3) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 0, 255, 0); } else if (newIndex == 4) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 0, 0, 255); } else if (newIndex == 5) { SetPlayerParachuteSmokeTrailColor(Game.Player.Handle, 1, 1, 1); } SetPlayerCanLeaveParachuteSmokeTrail(Game.Player.Handle, true); } }; #endregion #region misc parachute menu setup menu.AddMenuItem(parachuteBtn); parachuteBtn.Label = "→→→"; MenuController.BindMenuItem(menu, parachuteMenu, parachuteBtn); parachuteMenu.RefreshIndex(); //parachuteMenu.UpdateScaleform(); primaryChute.RefreshIndex(); //primaryChute.UpdateScaleform(); secondaryChute.RefreshIndex(); //secondaryChute.UpdateScaleform(); MenuController.AddSubmenu(menu, addonWeaponsMenu); MenuController.AddSubmenu(menu, parachuteMenu); MenuController.AddSubmenu(menu, primaryChute); MenuController.AddSubmenu(menu, secondaryChute); #endregion #endregion #region Create Weapon Category Submenus MenuItem spacer = GetSpacerMenuItem("↓ Weapon Categories ↓"); menu.AddMenuItem(spacer); Menu handGuns = new Menu("Weapons", "Handguns"); MenuItem handGunsBtn = new MenuItem("Handguns"); Menu rifles = new Menu("Weapons", "Assault Rifles"); MenuItem riflesBtn = new MenuItem("Assault Rifles"); Menu shotguns = new Menu("Weapons", "Shotguns"); MenuItem shotgunsBtn = new MenuItem("Shotguns"); Menu smgs = new Menu("Weapons", "Sub-/Light Machine Guns"); MenuItem smgsBtn = new MenuItem("Sub-/Light Machine Guns"); Menu throwables = new Menu("Weapons", "Throwables"); MenuItem throwablesBtn = new MenuItem("Throwables"); Menu melee = new Menu("Weapons", "Melee"); MenuItem meleeBtn = new MenuItem("Melee"); Menu heavy = new Menu("Weapons", "Heavy Weapons"); MenuItem heavyBtn = new MenuItem("Heavy Weapons"); Menu snipers = new Menu("Weapons", "Sniper Rifles"); MenuItem snipersBtn = new MenuItem("Sniper Rifles"); MenuController.AddSubmenu(menu, handGuns); MenuController.AddSubmenu(menu, rifles); MenuController.AddSubmenu(menu, shotguns); MenuController.AddSubmenu(menu, smgs); MenuController.AddSubmenu(menu, throwables); MenuController.AddSubmenu(menu, melee); MenuController.AddSubmenu(menu, heavy); MenuController.AddSubmenu(menu, snipers); #endregion #region Setup weapon category buttons and submenus. handGunsBtn.Label = "→→→"; menu.AddMenuItem(handGunsBtn); MenuController.BindMenuItem(menu, handGuns, handGunsBtn); riflesBtn.Label = "→→→"; menu.AddMenuItem(riflesBtn); MenuController.BindMenuItem(menu, rifles, riflesBtn); shotgunsBtn.Label = "→→→"; menu.AddMenuItem(shotgunsBtn); MenuController.BindMenuItem(menu, shotguns, shotgunsBtn); smgsBtn.Label = "→→→"; menu.AddMenuItem(smgsBtn); MenuController.BindMenuItem(menu, smgs, smgsBtn); throwablesBtn.Label = "→→→"; menu.AddMenuItem(throwablesBtn); MenuController.BindMenuItem(menu, throwables, throwablesBtn); meleeBtn.Label = "→→→"; menu.AddMenuItem(meleeBtn); MenuController.BindMenuItem(menu, melee, meleeBtn); heavyBtn.Label = "→→→"; menu.AddMenuItem(heavyBtn); MenuController.BindMenuItem(menu, heavy, heavyBtn); snipersBtn.Label = "→→→"; menu.AddMenuItem(snipersBtn); MenuController.BindMenuItem(menu, snipers, snipersBtn); #endregion #region Loop through all weapons, create menus for them and add all menu items and handle events. foreach (ValidWeapon weapon in ValidWeapons.WeaponList) { uint cat = (uint)GetWeapontypeGroup(weapon.Hash); if (!string.IsNullOrEmpty(weapon.Name) && (IsAllowed(weapon.Perm) || IsAllowed(Permission.WPGetAll))) { //Log($"[DEBUG LOG] [WEAPON-BUG] {weapon.Name} - {weapon.Perm} = {IsAllowed(weapon.Perm)} & All = {IsAllowed(Permission.WPGetAll)}"); #region Create menu for this weapon and add buttons Menu weaponMenu = new Menu("Weapon Options", weapon.Name); MenuItem weaponItem = new MenuItem(weapon.Name, $"Open the options for ~y~{weapon.Name.ToString()}~s~."); weaponItem.Label = "→→→"; weaponItem.LeftIcon = MenuItem.Icon.GUN; weaponInfo.Add(weaponMenu, weapon); MenuItem getOrRemoveWeapon = new MenuItem("Equip/Remove Weapon", "Add or remove this weapon to/form your inventory."); getOrRemoveWeapon.LeftIcon = MenuItem.Icon.GUN; weaponMenu.AddMenuItem(getOrRemoveWeapon); if (!IsAllowed(Permission.WPSpawn)) { getOrRemoveWeapon.Enabled = false; getOrRemoveWeapon.Description = "You do not have permission to use this option."; getOrRemoveWeapon.LeftIcon = MenuItem.Icon.LOCK; } MenuItem fillAmmo = new MenuItem("Re-fill Ammo", "Get max ammo for this weapon."); fillAmmo.LeftIcon = MenuItem.Icon.AMMO; weaponMenu.AddMenuItem(fillAmmo); List <string> tints = new List <string>(); if (weapon.Name.Contains(" Mk II")) { foreach (var tint in ValidWeapons.WeaponTintsMkII) { tints.Add(tint.Key); } } else { foreach (var tint in ValidWeapons.WeaponTints) { tints.Add(tint.Key); } } MenuListItem weaponTints = new MenuListItem("Tints", tints, 0, "Select a tint for your weapon."); weaponMenu.AddMenuItem(weaponTints); #endregion #region Handle weapon specific list changes weaponMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == weaponTints) { if (HasPedGotWeapon(Game.PlayerPed.Handle, weaponInfo[sender].Hash, false)) { SetPedWeaponTintIndex(Game.PlayerPed.Handle, weaponInfo[sender].Hash, newIndex); } else { Notify.Error("You need to get the weapon first!"); } } }; #endregion #region Handle weapon specific button presses weaponMenu.OnItemSelect += (sender, item, index) => { var info = weaponInfo[sender]; uint hash = info.Hash; SetCurrentPedWeapon(Game.PlayerPed.Handle, hash, true); if (item == getOrRemoveWeapon) { if (HasPedGotWeapon(Game.PlayerPed.Handle, hash, false)) { RemoveWeaponFromPed(Game.PlayerPed.Handle, hash); Subtitle.Custom("Weapon removed."); } else { var ammo = 255; GetMaxAmmo(Game.PlayerPed.Handle, hash, ref ammo); GiveWeaponToPed(Game.PlayerPed.Handle, hash, ammo, false, true); Subtitle.Custom("Weapon added."); } } else if (item == fillAmmo) { if (HasPedGotWeapon(Game.PlayerPed.Handle, hash, false)) { var ammo = 900; GetMaxAmmo(Game.PlayerPed.Handle, hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, hash, ammo); } else { Notify.Error("You need to get the weapon first before re-filling ammo!"); } } }; #endregion #region load components if (weapon.Components != null) { if (weapon.Components.Count > 0) { foreach (var comp in weapon.Components) { //Log($"{weapon.Name} : {comp.Key}"); MenuItem compItem = new MenuItem(comp.Key, "Click to equip or remove this component."); weaponComponents.Add(compItem, comp.Key); weaponMenu.AddMenuItem(compItem); #region Handle component button presses weaponMenu.OnItemSelect += (sender, item, index) => { if (item == compItem) { var Weapon = weaponInfo[sender]; var componentHash = Weapon.Components[weaponComponents[item]]; if (HasPedGotWeapon(Game.PlayerPed.Handle, Weapon.Hash, false)) { SetCurrentPedWeapon(Game.PlayerPed.Handle, Weapon.Hash, true); if (HasPedGotWeaponComponent(Game.PlayerPed.Handle, Weapon.Hash, componentHash)) { RemoveWeaponComponentFromPed(Game.PlayerPed.Handle, Weapon.Hash, componentHash); Subtitle.Custom("Component removed."); } else { int ammo = GetAmmoInPedWeapon(Game.PlayerPed.Handle, Weapon.Hash); int clipAmmo = GetMaxAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, false); GetAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, ref clipAmmo); GiveWeaponComponentToPed(Game.PlayerPed.Handle, Weapon.Hash, componentHash); SetAmmoInClip(Game.PlayerPed.Handle, Weapon.Hash, clipAmmo); SetPedAmmo(Game.PlayerPed.Handle, Weapon.Hash, ammo); Subtitle.Custom("Component equiped."); } } else { Notify.Error("You need to get the weapon first before you can modify it."); } } }; #endregion } } } #endregion // refresh and add to menu. weaponMenu.RefreshIndex(); if (cat == 970310034) // 970310034 rifles { MenuController.AddSubmenu(rifles, weaponMenu); MenuController.BindMenuItem(rifles, weaponMenu, weaponItem); rifles.AddMenuItem(weaponItem); } else if (cat == 416676503 || cat == 690389602) // 416676503 hand guns // 690389602 stun gun { MenuController.AddSubmenu(handGuns, weaponMenu); MenuController.BindMenuItem(handGuns, weaponMenu, weaponItem); handGuns.AddMenuItem(weaponItem); } else if (cat == 860033945) // 860033945 shotguns { MenuController.AddSubmenu(shotguns, weaponMenu); MenuController.BindMenuItem(shotguns, weaponMenu, weaponItem); shotguns.AddMenuItem(weaponItem); } else if (cat == 3337201093 || cat == 1159398588) // 3337201093 sub machine guns // 1159398588 light machine guns { MenuController.AddSubmenu(smgs, weaponMenu); MenuController.BindMenuItem(smgs, weaponMenu, weaponItem); smgs.AddMenuItem(weaponItem); } else if (cat == 1548507267 || cat == 4257178988 || cat == 1595662460) // 1548507267 throwables // 4257178988 fire extinghuiser // jerry can { MenuController.AddSubmenu(throwables, weaponMenu); MenuController.BindMenuItem(throwables, weaponMenu, weaponItem); throwables.AddMenuItem(weaponItem); } else if (cat == 3566412244 || cat == 2685387236) // 3566412244 melee weapons // 2685387236 knuckle duster { MenuController.AddSubmenu(melee, weaponMenu); MenuController.BindMenuItem(melee, weaponMenu, weaponItem); melee.AddMenuItem(weaponItem); } else if (cat == 2725924767) // 2725924767 heavy weapons { MenuController.AddSubmenu(heavy, weaponMenu); MenuController.BindMenuItem(heavy, weaponMenu, weaponItem); heavy.AddMenuItem(weaponItem); } else if (cat == 3082541095) // 3082541095 sniper rifles { MenuController.AddSubmenu(snipers, weaponMenu); MenuController.BindMenuItem(snipers, weaponMenu, weaponItem); snipers.AddMenuItem(weaponItem); } } } #endregion #region Disable submenus if no weapons in that category are allowed. if (handGuns.Size == 0) { handGunsBtn.LeftIcon = MenuItem.Icon.LOCK; handGunsBtn.Description = "The server owner removed the permissions for all weapons in this category."; handGunsBtn.Enabled = false; } if (rifles.Size == 0) { riflesBtn.LeftIcon = MenuItem.Icon.LOCK; riflesBtn.Description = "The server owner removed the permissions for all weapons in this category."; riflesBtn.Enabled = false; } if (shotguns.Size == 0) { shotgunsBtn.LeftIcon = MenuItem.Icon.LOCK; shotgunsBtn.Description = "The server owner removed the permissions for all weapons in this category."; shotgunsBtn.Enabled = false; } if (smgs.Size == 0) { smgsBtn.LeftIcon = MenuItem.Icon.LOCK; smgsBtn.Description = "The server owner removed the permissions for all weapons in this category."; smgsBtn.Enabled = false; } if (throwables.Size == 0) { throwablesBtn.LeftIcon = MenuItem.Icon.LOCK; throwablesBtn.Description = "The server owner removed the permissions for all weapons in this category."; throwablesBtn.Enabled = false; } if (melee.Size == 0) { meleeBtn.LeftIcon = MenuItem.Icon.LOCK; meleeBtn.Description = "The server owner removed the permissions for all weapons in this category."; meleeBtn.Enabled = false; } if (heavy.Size == 0) { heavyBtn.LeftIcon = MenuItem.Icon.LOCK; heavyBtn.Description = "The server owner removed the permissions for all weapons in this category."; heavyBtn.Enabled = false; } if (snipers.Size == 0) { snipersBtn.LeftIcon = MenuItem.Icon.LOCK; snipersBtn.Description = "The server owner removed the permissions for all weapons in this category."; snipersBtn.Enabled = false; } #endregion #region Handle button presses menu.OnItemSelect += (sender, item, index) => { Ped ped = new Ped(Game.PlayerPed.Handle); if (item == getAllWeapons) { foreach (ValidWeapon vw in ValidWeapons.WeaponList) { if (IsAllowed(vw.Perm)) { GiveWeaponToPed(Game.PlayerPed.Handle, vw.Hash, vw.GetMaxAmmo, false, true); int ammoInClip = GetMaxAmmoInClip(Game.PlayerPed.Handle, vw.Hash, false); SetAmmoInClip(Game.PlayerPed.Handle, vw.Hash, ammoInClip); int ammo = 0; GetMaxAmmo(Game.PlayerPed.Handle, vw.Hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, vw.Hash, ammo); } } SetCurrentPedWeapon(Game.PlayerPed.Handle, (uint)GetHashKey("weapon_unarmed"), true); } else if (item == removeAllWeapons) { ped.Weapons.RemoveAll(); } else if (item == setAmmo) { SetAllWeaponsAmmo(); } else if (item == refillMaxAmmo) { foreach (ValidWeapon vw in ValidWeapons.WeaponList) { if (HasPedGotWeapon(Game.PlayerPed.Handle, vw.Hash, false)) { int ammoInClip = GetMaxAmmoInClip(Game.PlayerPed.Handle, vw.Hash, false); SetAmmoInClip(Game.PlayerPed.Handle, vw.Hash, ammoInClip); int ammo = 0; GetMaxAmmo(Game.PlayerPed.Handle, vw.Hash, ref ammo); SetPedAmmo(Game.PlayerPed.Handle, vw.Hash, ammo); } } } else if (item == spawnByName) { SpawnCustomWeapon(); } }; #endregion #region Handle checkbox changes menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == noReload) { NoReload = _checked; Subtitle.Custom($"No reload is now {(_checked ? "enabled" : "disabled")}."); } else if (item == unlimitedAmmo) { UnlimitedAmmo = _checked; Subtitle.Custom($"Unlimited ammo is now {(_checked ? "enabled" : "disabled")}."); } }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { MenuController.MenuAlignment = MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; if (MenuController.MenuAlignment != (MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } // Create the menu. menu = new Menu(Game.Player.Name, "Misc Settings"); teleportOptionsMenu = new Menu(Game.Player.Name, "Teleport Options"); developerToolsMenu = new Menu(Game.Player.Name, "Development Tools"); // teleport menu Menu teleportMenu = new Menu(Game.Player.Name, "Teleport Locations"); MenuItem teleportMenuBtn = new MenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner."); MenuController.AddSubmenu(menu, teleportMenu); MenuController.BindMenuItem(menu, teleportMenu, teleportMenuBtn); // keybind settings menu Menu keybindMenu = new Menu(Game.Player.Name, "Keybind Settings"); MenuItem keybindMenuBtn = new MenuItem("Keybind Settings", "Enable or disable keybinds for some options."); MenuController.AddSubmenu(menu, keybindMenu); MenuController.BindMenuItem(menu, keybindMenu, keybindMenuBtn); // keybind settings menu items MenuCheckboxItem kbTpToWaypoint = new MenuCheckboxItem("Teleport To Waypoint", "Teleport to your waypoint when pressing the keybind. By default, this keybind is set to ~r~F7~s~, server owners are able to change this however so ask them if you don't know what it is.", KbTpToWaypoint); MenuCheckboxItem kbDriftMode = new MenuCheckboxItem("Drift Mode", "Makes your vehicle have almost no traction while holding left shift on keyboard, or X on controller.", KbDriftMode); MenuCheckboxItem kbRecordKeys = new MenuCheckboxItem("Recording Controls", "Enables or disables the recording (gameplay recording for the Rockstar editor) hotkeys on both keyboard and controller.", KbRecordKeys); MenuCheckboxItem kbRadarKeys = new MenuCheckboxItem("Minimap Controls", "Press the Multiplayer Info (z on keyboard, down arrow on controller) key to switch between expanded radar and normal radar.", KbRadarKeys); MenuCheckboxItem kbPointKeysCheckbox = new MenuCheckboxItem("Finger Point Controls", "Enables the finger point toggle key. The default QWERTY keyboard mapping for this is 'B', or for controller quickly double tap the right analog stick.", KbPointKeys); MenuItem backBtn = new MenuItem("Back"); // Create the menu items. MenuCheckboxItem rightAlignMenu = new MenuCheckboxItem("Right Align Menu", "If you want vMenu to appear on the left side of your screen, disable this option. This option will be saved immediately. You don't need to click save preferences.", MiscRightAlignMenu); MenuCheckboxItem disablePms = new MenuCheckboxItem("Disable Private Messages", "Prevent others from sending you a private message via the Online Players menu. This also prevents you from sending messages to other players.", MiscDisablePrivateMessages); MenuCheckboxItem disableControllerKey = new MenuCheckboxItem("Disable Controller Support", "This disables the controller menu toggle key. This does NOT disable the navigation buttons.", MiscDisableControllerSupport); MenuCheckboxItem speedKmh = new MenuCheckboxItem("Show Speed KM/H", "Show a speedometer on your screen indicating your speed in KM/h.", ShowSpeedoKmh); MenuCheckboxItem speedMph = new MenuCheckboxItem("Show Speed MPH", "Show a speedometer on your screen indicating your speed in MPH.", ShowSpeedoMph); MenuCheckboxItem coords = new MenuCheckboxItem("Show Coordinates", "Show your current coordinates at the top of your screen.", ShowCoordinates); MenuCheckboxItem hideRadar = new MenuCheckboxItem("Hide Radar", "Hide the radar/minimap.", HideRadar); MenuCheckboxItem hideHud = new MenuCheckboxItem("Hide Hud", "Hide all hud elements.", HideHud); MenuCheckboxItem showLocation = new MenuCheckboxItem("Location Display", "Shows your current location and heading, as well as the nearest cross road. Similar like PLD. ~r~Warning: This feature (can) take(s) up to -4.6 FPS when running at 60 Hz.", ShowLocation) { LeftIcon = MenuItem.Icon.WARNING }; MenuCheckboxItem drawTime = new MenuCheckboxItem("Show Time On Screen", "Shows you the current time on screen.", DrawTimeOnScreen); MenuItem saveSettings = new MenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu.") { RightIcon = MenuItem.Icon.TICK }; MenuItem exportData = new MenuItem("Export/Import Data", "Coming soon (TM): the ability to import and export your saved data."); MenuCheckboxItem joinQuitNotifs = new MenuCheckboxItem("Join / Quit Notifications", "Receive notifications when someone joins or leaves the server.", JoinQuitNotifications); MenuCheckboxItem deathNotifs = new MenuCheckboxItem("Death Notifications", "Receive notifications when someone dies or gets killed.", DeathNotifications); MenuCheckboxItem nightVision = new MenuCheckboxItem("Toggle Night Vision", "Enable or disable night vision.", false); MenuCheckboxItem thermalVision = new MenuCheckboxItem("Toggle Thermal Vision", "Enable or disable thermal vision.", false); MenuCheckboxItem vehModelDimensions = new MenuCheckboxItem("Show Vehicle Dimensions", "Draws the model outlines for every vehicle that's currently close to you.", ShowVehicleModelDimensions); MenuCheckboxItem propModelDimensions = new MenuCheckboxItem("Show Prop Dimensions", "Draws the model outlines for every prop that's currently close to you.", ShowPropModelDimensions); MenuCheckboxItem pedModelDimensions = new MenuCheckboxItem("Show Ped Dimensions", "Draws the model outlines for every ped that's currently close to you.", ShowPedModelDimensions); MenuCheckboxItem showEntityHandles = new MenuCheckboxItem("Show Entity Handles", "Draws the the entity handles for all close entities (you must enable the outline functions above for this to work).", ShowEntityHandles); MenuCheckboxItem showEntityModels = new MenuCheckboxItem("Show Entity Models", "Draws the the entity models for all close entities (you must enable the outline functions above for this to work).", ShowEntityModels); MenuCheckboxItem showEntityNetOwners = new MenuCheckboxItem("Show Network Owners", "Draws the the entity net owner for all close entities (you must enable the outline functions above for this to work).", ShowEntityNetOwners); MenuSliderItem dimensionsDistanceSlider = new MenuSliderItem("Show Dimensions Radius", "Show entity model/handle/dimension draw range.", 0, 20, 20, false); MenuItem clearArea = new MenuItem("Clear Area", "Clears the area around your player (100 meters). Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up, fixed and reset to the default world state."); MenuCheckboxItem lockCamX = new MenuCheckboxItem("Lock Camera Horizontal Rotation", "Locks your camera horizontal rotation. Could be useful in helicopters I guess.", false); MenuCheckboxItem lockCamY = new MenuCheckboxItem("Lock Camera Vertical Rotation", "Locks your camera vertical rotation. Could be useful in helicopters I guess.", false); Menu connectionSubmenu = new Menu(Game.Player.Name, "Connection Options"); MenuItem connectionSubmenuBtn = new MenuItem("Connection Options", "Server connection/game quit options."); MenuItem quitSession = new MenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. ~r~Can not be used when you are the host."); MenuItem rejoinSession = new MenuItem("Re-join Session", "This may not work in all cases, but you can try to use this if you want to re-join the previous session after clicking 'Quit Session'."); MenuItem quitGame = new MenuItem("Quit Game", "Exits the game after 5 seconds."); MenuItem disconnectFromServer = new MenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. ~r~This feature is not recommended, quit the game completely instead and restart it for a better experience."); connectionSubmenu.AddMenuItem(quitSession); connectionSubmenu.AddMenuItem(rejoinSession); connectionSubmenu.AddMenuItem(quitGame); connectionSubmenu.AddMenuItem(disconnectFromServer); MenuCheckboxItem enableTimeCycle = new MenuCheckboxItem("Enable Timecycle Modifier", "Enable or disable the timecycle modifier from the list below.", TimecycleEnabled); List <string> timeCycleModifiersListData = TimeCycles.Timecycles.ToList(); for (var i = 0; i < timeCycleModifiersListData.Count; i++) { timeCycleModifiersListData[i] += $" ({i + 1}/{timeCycleModifiersListData.Count})"; } MenuListItem timeCycles = new MenuListItem("TM", timeCycleModifiersListData, MathUtil.Clamp(LastTimeCycleModifierIndex, 0, Math.Max(0, timeCycleModifiersListData.Count - 1)), "Select a timecycle modifier and enable the checkbox above."); MenuSliderItem timeCycleIntensity = new MenuSliderItem("Timecycle Modifier Intensity", "Set the timecycle modifier intensity.", 0, 20, LastTimeCycleModifierStrength, true); MenuCheckboxItem locationBlips = new MenuCheckboxItem("Location Blips", "Shows blips on the map for some common locations.", ShowLocationBlips); MenuCheckboxItem playerBlips = new MenuCheckboxItem("Show Player Blips", "Shows blips on the map for all players.", ShowPlayerBlips); MenuCheckboxItem playerNames = new MenuCheckboxItem("Show Player Names", "Enables or disables player overhead names.", MiscShowOverheadNames); MenuCheckboxItem respawnDefaultCharacter = new MenuCheckboxItem("Respawn As Default MP Character", "If you enable this, then you will (re)spawn as your default saved MP character. Note the server owner can globally disable this option. To set your default character, go to one of your saved MP Characters and click the 'Set As Default Character' button.", MiscRespawnDefaultCharacter); MenuCheckboxItem restorePlayerAppearance = new MenuCheckboxItem("Restore Player Appearance", "Restore your player's skin whenever you respawn after being dead. Re-joining a server will not restore your previous skin.", RestorePlayerAppearance); MenuCheckboxItem restorePlayerWeapons = new MenuCheckboxItem("Restore Player Weapons", "Restore your weapons whenever you respawn after being dead. Re-joining a server will not restore your previous weapons.", RestorePlayerWeapons); MenuController.AddSubmenu(menu, connectionSubmenu); MenuController.BindMenuItem(menu, connectionSubmenu, connectionSubmenuBtn); keybindMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == kbTpToWaypoint) { KbTpToWaypoint = _checked; } else if (item == kbDriftMode) { KbDriftMode = _checked; TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat den Driftmode " + (_checked ? "aktiviert" : "deaktiviert")); } else if (item == kbRecordKeys) { KbRecordKeys = _checked; } else if (item == kbRadarKeys) { KbRadarKeys = _checked; } else if (item == kbPointKeysCheckbox) { KbPointKeys = _checked; } }; keybindMenu.OnItemSelect += (sender, item, index) => { if (item == backBtn) { keybindMenu.GoBack(); } }; connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { QuitGame(); } else if (item == quitSession) { if (NetworkIsSessionActive()) { if (NetworkIsHost()) { Notify.Error("Sorry, you cannot leave the session when you are the host. This would prevent other players from joining/staying on the server."); } else { QuitSession(); } } else { Notify.Error("You are currently not in any session."); } } else if (item == rejoinSession) { if (NetworkIsSessionActive()) { Notify.Error("You are already connected to a session."); } else { Notify.Info("Attempting to re-join the session."); NetworkSessionHost(-1, 32, false); } } else if (item == disconnectFromServer) { RegisterCommand("disconnect", new Action <dynamic, dynamic, dynamic>((a, b, c) => { }), false); ExecuteCommand("disconnect"); } }; // Teleportation options if (IsAllowed(Permission.MSTeleportToWp) || IsAllowed(Permission.MSTeleportLocations) || IsAllowed(Permission.MSTeleportToCoord)) { MenuItem teleportOptionsMenuBtn = new MenuItem("Teleport Options", "Various teleport options.") { Label = "→→→" }; menu.AddMenuItem(teleportOptionsMenuBtn); MenuController.BindMenuItem(menu, teleportOptionsMenu, teleportOptionsMenuBtn); MenuItem tptowp = new MenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); MenuItem tpToCoord = new MenuItem("Teleport To Coords", "Enter x, y, z coordinates and you will be teleported to that location."); MenuItem saveLocationBtn = new MenuItem("Save Teleport Location", "Adds your current location to the teleport locations menu and saves it on the server."); teleportOptionsMenu.OnItemSelect += async(sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { TeleportToWp(); } else if (item == tpToCoord) { string x = await GetUserInput("Enter X coordinate."); if (string.IsNullOrEmpty(x)) { Notify.Error(CommonErrors.InvalidInput); return; } string y = await GetUserInput("Enter Y coordinate."); if (string.IsNullOrEmpty(y)) { Notify.Error(CommonErrors.InvalidInput); return; } string z = await GetUserInput("Enter Z coordinate."); if (string.IsNullOrEmpty(z)) { Notify.Error(CommonErrors.InvalidInput); return; } float posX = 0f; float posY = 0f; float posZ = 0f; if (!float.TryParse(x, out posX)) { if (int.TryParse(x, out int intX)) { posX = (float)intX; } else { Notify.Error("You did not enter a valid X coordinate."); return; } } if (!float.TryParse(y, out posY)) { if (int.TryParse(y, out int intY)) { posY = (float)intY; } else { Notify.Error("You did not enter a valid Y coordinate."); return; } } if (!float.TryParse(z, out posZ)) { if (int.TryParse(z, out int intZ)) { posZ = (float)intZ; } else { Notify.Error("You did not enter a valid Z coordinate."); return; } } await TeleportToCoords(new Vector3(posX, posY, posZ), true); } else if (item == saveLocationBtn) { SavePlayerLocationToLocationsFile(); } }; if (IsAllowed(Permission.MSTeleportToWp)) { teleportOptionsMenu.AddMenuItem(tptowp); keybindMenu.AddMenuItem(kbTpToWaypoint); } if (IsAllowed(Permission.MSTeleportToCoord)) { teleportOptionsMenu.AddMenuItem(tpToCoord); } if (IsAllowed(Permission.MSTeleportLocations)) { teleportOptionsMenu.AddMenuItem(teleportMenuBtn); MenuController.AddSubmenu(teleportOptionsMenu, teleportMenu); MenuController.BindMenuItem(teleportOptionsMenu, teleportMenu, teleportMenuBtn); teleportMenuBtn.Label = "→→→"; teleportMenu.OnMenuOpen += (sender) => { if (teleportMenu.Size != TpLocations.Count()) { teleportMenu.ClearMenuItems(); foreach (var location in TpLocations) { var x = Math.Round(location.coordinates.X, 2); var y = Math.Round(location.coordinates.Y, 2); var z = Math.Round(location.coordinates.Z, 2); var heading = Math.Round(location.heading, 2); MenuItem tpBtn = new MenuItem(location.name, $"Teleport to ~y~{location.name}~n~~s~x: ~y~{x}~n~~s~y: ~y~{y}~n~~s~z: ~y~{z}~n~~s~heading: ~y~{heading}") { ItemData = location }; teleportMenu.AddMenuItem(tpBtn); } } }; teleportMenu.OnItemSelect += async(sender, item, index) => { if (item.ItemData is vMenuShared.ConfigManager.TeleportLocation tl) { await TeleportToCoords(tl.coordinates, true); SetEntityHeading(Game.PlayerPed.Handle, tl.heading); SetGameplayCamRelativeHeading(0f); } }; if (IsAllowed(Permission.MSTeleportSaveLocation)) { teleportOptionsMenu.AddMenuItem(saveLocationBtn); } } } #region dev tools menu MenuItem devToolsBtn = new MenuItem("Developer Tools", "Various development/debug tools.") { Label = "→→→" }; menu.AddMenuItem(devToolsBtn); MenuController.AddSubmenu(menu, developerToolsMenu); MenuController.BindMenuItem(menu, developerToolsMenu, devToolsBtn); // clear area and coordinates if (IsAllowed(Permission.MSClearArea)) { developerToolsMenu.AddMenuItem(clearArea); } if (IsAllowed(Permission.MSShowCoordinates)) { developerToolsMenu.AddMenuItem(coords); } // model outlines if (!vMenuShared.ConfigManager.GetSettingsBool(vMenuShared.ConfigManager.Setting.vmenu_disable_entity_outlines_tool)) { developerToolsMenu.AddMenuItem(vehModelDimensions); developerToolsMenu.AddMenuItem(propModelDimensions); developerToolsMenu.AddMenuItem(pedModelDimensions); developerToolsMenu.AddMenuItem(showEntityHandles); developerToolsMenu.AddMenuItem(showEntityModels); developerToolsMenu.AddMenuItem(showEntityNetOwners); developerToolsMenu.AddMenuItem(dimensionsDistanceSlider); } // timecycle modifiers developerToolsMenu.AddMenuItem(timeCycles); developerToolsMenu.AddMenuItem(enableTimeCycle); developerToolsMenu.AddMenuItem(timeCycleIntensity); developerToolsMenu.OnSliderPositionChange += (sender, item, oldPos, newPos, itemIndex) => { if (item == timeCycleIntensity) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)newPos / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } else if (item == dimensionsDistanceSlider) { FunctionsController.entityRange = ((float)newPos / 20f) * 2000f; // max radius = 2000f; } }; developerToolsMenu.OnListIndexChange += (sender, item, oldIndex, newIndex, itemIndex) => { if (item == timeCycles) { ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } UserDefaults.MiscLastTimeCycleModifierIndex = timeCycles.ListIndex; UserDefaults.MiscLastTimeCycleModifierStrength = timeCycleIntensity.Position; } }; developerToolsMenu.OnItemSelect += (sender, item, index) => { if (item == clearArea) { var pos = Game.PlayerPed.Position; BaseScript.TriggerServerEvent("vMenu:ClearArea", pos.X, pos.Y, pos.Z); } }; developerToolsMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == vehModelDimensions) { ShowVehicleModelDimensions = _checked; } else if (item == propModelDimensions) { ShowPropModelDimensions = _checked; } else if (item == pedModelDimensions) { ShowPedModelDimensions = _checked; } else if (item == showEntityHandles) { ShowEntityHandles = _checked; } else if (item == showEntityModels) { ShowEntityModels = _checked; } else if (item == showEntityNetOwners) { ShowEntityNetOwners = _checked; } else if (item == enableTimeCycle) { TimecycleEnabled = _checked; ClearTimecycleModifier(); if (TimecycleEnabled) { SetTimecycleModifier(TimeCycles.Timecycles[timeCycles.ListIndex]); float intensity = ((float)timeCycleIntensity.Position / 20f); SetTimecycleModifierStrength(intensity); } } else if (item == coords) { ShowCoordinates = _checked; } }; #endregion // Keybind options if (IsAllowed(Permission.MSDriftMode)) { keybindMenu.AddMenuItem(kbDriftMode); } // always allowed keybind menu options keybindMenu.AddMenuItem(kbRecordKeys); keybindMenu.AddMenuItem(kbRadarKeys); keybindMenu.AddMenuItem(kbPointKeysCheckbox); keybindMenu.AddMenuItem(backBtn); // Always allowed menu.AddMenuItem(rightAlignMenu); menu.AddMenuItem(disablePms); menu.AddMenuItem(disableControllerKey); menu.AddMenuItem(speedKmh); menu.AddMenuItem(speedMph); menu.AddMenuItem(keybindMenuBtn); keybindMenuBtn.Label = "→→→"; if (IsAllowed(Permission.MSConnectionMenu)) { menu.AddMenuItem(connectionSubmenuBtn); connectionSubmenuBtn.Label = "→→→"; } if (IsAllowed(Permission.MSShowLocation)) { menu.AddMenuItem(showLocation); } menu.AddMenuItem(drawTime); // always allowed if (IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddMenuItem(deathNotifs); } if (IsAllowed(Permission.MSDeathNotifs)) { menu.AddMenuItem(joinQuitNotifs); } if (IsAllowed(Permission.MSNightVision)) { menu.AddMenuItem(nightVision); } if (IsAllowed(Permission.MSThermalVision)) { menu.AddMenuItem(thermalVision); } if (IsAllowed(Permission.MSLocationBlips)) { menu.AddMenuItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (IsAllowed(Permission.MSPlayerBlips)) { menu.AddMenuItem(playerBlips); } if (IsAllowed(Permission.MSOverheadNames)) { menu.AddMenuItem(playerNames); } // always allowed, it just won't do anything if the server owner disabled the feature, but players can still toggle it. menu.AddMenuItem(respawnDefaultCharacter); if (IsAllowed(Permission.MSRestoreAppearance)) { menu.AddMenuItem(restorePlayerAppearance); } if (IsAllowed(Permission.MSRestoreWeapons)) { menu.AddMenuItem(restorePlayerWeapons); } // Always allowed menu.AddMenuItem(hideRadar); menu.AddMenuItem(hideHud); menu.AddMenuItem(lockCamX); menu.AddMenuItem(lockCamY); if (MainMenu.EnableExperimentalFeatures) { menu.AddMenuItem(exportData); } menu.AddMenuItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == rightAlignMenu) { MenuController.MenuAlignment = _checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = _checked; UserDefaults.MiscRightAlignMenu = MiscRightAlignMenu; if (MenuController.MenuAlignment != (_checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left)) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } } else if (item == disablePms) { MiscDisablePrivateMessages = _checked; } else if (item == disableControllerKey) { MiscDisableControllerSupport = _checked; MenuController.EnableMenuToggleKeyOnController = !_checked; } else if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == hideHud) { HideHud = _checked; DisplayHud(!_checked); } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == drawTime) { DrawTimeOnScreen = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } else if (item == nightVision) { SetNightvision(_checked); } else if (item == thermalVision) { SetSeethrough(_checked); } else if (item == lockCamX) { LockCameraX = _checked; } else if (item == lockCamY) { LockCameraY = _checked; } else if (item == locationBlips) { ToggleBlips(_checked); ShowLocationBlips = _checked; } else if (item == playerBlips) { ShowPlayerBlips = _checked; TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat PlayerBlips " + (_checked ? "aktiviert" : "deaktiviert")); } else if (item == playerNames) { MiscShowOverheadNames = _checked; TriggerServerEvent("tallerik:logMessage", GetPlayerName(PlayerId()) + " hat Playernames " + (_checked ? "aktiviert" : "deaktiviert")); } else if (item == respawnDefaultCharacter) { MiscRespawnDefaultCharacter = _checked; } else if (item == restorePlayerAppearance) { RestorePlayerAppearance = _checked; } else if (item == restorePlayerWeapons) { RestorePlayerWeapons = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // export data if (item == exportData) { MenuController.CloseAllMenus(); var vehicles = GetSavedVehicles(); var normalPeds = StorageManager.GetSavedPeds(); var mpPeds = StorageManager.GetSavedMpPeds(); var weaponLoadouts = WeaponLoadouts.GetSavedWeapons(); var data = JsonConvert.SerializeObject(new { saved_vehicles = vehicles, normal_peds = normalPeds, mp_characters = mpPeds, weapon_loadouts = weaponLoadouts }); SendNuiMessage(data); SetNuiFocus(true, true); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettings(); } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { #region create menu and menu items // Create the menu. menu = new Menu(Game.Player.Name, "Player Options"); // Create all checkboxes. MenuCheckboxItem playerGodModeCheckbox = new MenuCheckboxItem("Godmode", "Makes you invincible.", PlayerGodMode); MenuCheckboxItem invisibleCheckbox = new MenuCheckboxItem("Invisible", "Makes you invisible to yourself and others.", PlayerInvisible); MenuCheckboxItem unlimitedStaminaCheckbox = new MenuCheckboxItem("Unlimited Stamina", "Allows you to run forever without slowing down or taking damage.", PlayerStamina); MenuCheckboxItem fastRunCheckbox = new MenuCheckboxItem("Fast Run", "Get ~g~Snail~s~ powers and run very fast!", PlayerFastRun); SetRunSprintMultiplierForPlayer(Game.Player.Handle, (PlayerFastRun && IsAllowed(Permission.POFastRun) ? 1.49f : 1f)); MenuCheckboxItem fastSwimCheckbox = new MenuCheckboxItem("Fast Swim", "Get ~g~Snail 2.0~s~ powers and swim super fast!", PlayerFastSwim); SetSwimMultiplierForPlayer(Game.Player.Handle, (PlayerFastSwim && IsAllowed(Permission.POFastSwim) ? 1.49f : 1f)); MenuCheckboxItem superJumpCheckbox = new MenuCheckboxItem("Super Jump", "Get ~g~Snail 3.0~s~ powers and jump like a champ!", PlayerSuperJump); MenuCheckboxItem noRagdollCheckbox = new MenuCheckboxItem("No Ragdoll", "Disables player ragdoll, makes you not fall off your bike anymore.", PlayerNoRagdoll); MenuCheckboxItem neverWantedCheckbox = new MenuCheckboxItem("Never Wanted", "Disables all wanted levels.", PlayerNeverWanted); MenuCheckboxItem everyoneIgnoresPlayerCheckbox = new MenuCheckboxItem("Everyone Ignore Player", "Everyone will leave you alone.", PlayerIsIgnored); MenuCheckboxItem playerStayInVehicleCheckbox = new MenuCheckboxItem("Stay In Vehicle", "When this is enabled, NPCs will not be able to drag you out of your vehicle if they get angry at you.", PlayerStayInVehicle); MenuCheckboxItem playerFrozenCheckbox = new MenuCheckboxItem("Freeze Player", "Freezes your current location.", PlayerFrozen); // Wanted level options List <string> wantedLevelList = new List <string> { "No Wanted Level", "1", "2", "3", "4", "5" }; MenuListItem setWantedLevel = new MenuListItem("Set Wanted Level", wantedLevelList, GetPlayerWantedLevel(Game.Player.Handle), "Set your wanted level by selecting a value, and pressing enter."); MenuListItem setArmorItem = new MenuListItem("Set Armor Type", new List <string> { "No Armor", GetLabelText("WT_BA_0"), GetLabelText("WT_BA_1"), GetLabelText("WT_BA_2"), GetLabelText("WT_BA_3"), GetLabelText("WT_BA_4"), }, 0, "Set the armor level/type for your player."); MenuItem healPlayerBtn = new MenuItem("Heal Player", "Give the player max health."); MenuItem cleanPlayerBtn = new MenuItem("Clean Player Clothes", "Clean your player clothes."); MenuItem dryPlayerBtn = new MenuItem("Dry Player Clothes", "Make your player clothes dry."); MenuItem wetPlayerBtn = new MenuItem("Wet Player Clothes", "Make your player clothes wet."); MenuItem suicidePlayerBtn = new MenuItem("~r~Commit Suicide", "Kill yourself by taking the pill. Or by using a pistol if you have one."); Menu vehicleAutoPilot = new Menu("Auto Pilot", "Vehicle auto pilot options."); MenuController.AddSubmenu(menu, vehicleAutoPilot); MenuItem vehicleAutoPilotBtn = new MenuItem("Vehicle Auto Pilot Menu", "Manage vehicle auto pilot options.") { Label = "→→→" }; List <string> drivingStyles = new List <string>() { "Normal", "Rushed", "Avoid highways", "Drive in reverse", "Custom" }; MenuListItem drivingStyle = new MenuListItem("Driving Style", drivingStyles, 0, "Set the driving style that is used for the Drive to Waypoint and Drive Around Randomly functions."); // Scenarios (list can be found in the PedScenarios class) MenuListItem playerScenarios = new MenuListItem("Player Scenarios", PedScenarios.Scenarios, 0, "Select a scenario and hit enter to start it. Selecting another scenario will override the current scenario. If you're already playing the selected scenario, selecting it again will stop the scenario."); MenuItem stopScenario = new MenuItem("Force Stop Scenario", "This will force a playing scenario to stop immediately, without waiting for it to finish it's 'stopping' animation."); #endregion #region add items to menu based on permissions // Add all checkboxes to the menu. (keeping permissions in mind) if (IsAllowed(Permission.POGod)) { menu.AddMenuItem(playerGodModeCheckbox); } if (IsAllowed(Permission.POInvisible)) { menu.AddMenuItem(invisibleCheckbox); } if (IsAllowed(Permission.POUnlimitedStamina)) { menu.AddMenuItem(unlimitedStaminaCheckbox); } if (IsAllowed(Permission.POFastRun)) { menu.AddMenuItem(fastRunCheckbox); } if (IsAllowed(Permission.POFastSwim)) { menu.AddMenuItem(fastSwimCheckbox); } if (IsAllowed(Permission.POSuperjump)) { menu.AddMenuItem(superJumpCheckbox); } if (IsAllowed(Permission.PONoRagdoll)) { menu.AddMenuItem(noRagdollCheckbox); } if (IsAllowed(Permission.PONeverWanted)) { menu.AddMenuItem(neverWantedCheckbox); } if (IsAllowed(Permission.POSetWanted)) { menu.AddMenuItem(setWantedLevel); } if (IsAllowed(Permission.POIgnored)) { menu.AddMenuItem(everyoneIgnoresPlayerCheckbox); } if (IsAllowed(Permission.POStayInVehicle)) { menu.AddMenuItem(playerStayInVehicleCheckbox); } if (IsAllowed(Permission.POMaxHealth)) { menu.AddMenuItem(healPlayerBtn); } if (IsAllowed(Permission.POMaxArmor)) { menu.AddMenuItem(setArmorItem); } if (IsAllowed(Permission.POCleanPlayer)) { menu.AddMenuItem(cleanPlayerBtn); } if (IsAllowed(Permission.PODryPlayer)) { menu.AddMenuItem(dryPlayerBtn); } if (IsAllowed(Permission.POWetPlayer)) { menu.AddMenuItem(wetPlayerBtn); } menu.AddMenuItem(suicidePlayerBtn); if (IsAllowed(Permission.POVehicleAutoPilotMenu)) { menu.AddMenuItem(vehicleAutoPilotBtn); MenuController.BindMenuItem(menu, vehicleAutoPilot, vehicleAutoPilotBtn); vehicleAutoPilot.AddMenuItem(drivingStyle); MenuItem startDrivingWaypoint = new MenuItem("Drive To Waypoint", "Make your player ped drive your vehicle to your waypoint."); MenuItem startDrivingRandomly = new MenuItem("Drive Around Randomly", "Make your player ped drive your vehicle randomly around the map."); MenuItem stopDriving = new MenuItem("Stop Driving", "The player ped will find a suitable place to stop the vehicle. The task will be stopped once the vehicle has reached the suitable stop location."); MenuItem forceStopDriving = new MenuItem("Force Stop Driving", "This will stop the driving task immediately without finding a suitable place to stop."); MenuItem customDrivingStyle = new MenuItem("Custom Driving Style", "Select a custom driving style. Make sure to also enable it by selecting the 'Custom' driving style in the driving styles list.") { Label = "→→→" }; MenuController.AddSubmenu(vehicleAutoPilot, CustomDrivingStyleMenu); vehicleAutoPilot.AddMenuItem(customDrivingStyle); MenuController.BindMenuItem(vehicleAutoPilot, CustomDrivingStyleMenu, customDrivingStyle); Dictionary <int, string> knownNames = new Dictionary <int, string>() { { 0, "Stop before vehicles" }, { 1, "Stop before peds" }, { 2, "Avoid vehicles" }, { 3, "Avoid empty vehicles" }, { 4, "Avoid peds" }, { 5, "Avoid objects" }, { 7, "Stop at traffic lights" }, { 8, "Use blinkers" }, { 9, "Allow going wrong way" }, { 10, "Go in reverse gear" }, { 18, "Use shortest path" }, { 22, "Ignore roads" }, { 24, "Ignore all pathing" }, { 29, "Avoid highways (if possible)" }, }; for (var i = 0; i < 31; i++) { string name = "~r~Unknown Flag"; if (knownNames.ContainsKey(i)) { name = knownNames[i]; } MenuCheckboxItem checkbox = new MenuCheckboxItem(name, "Toggle this driving style flag.", false); CustomDrivingStyleMenu.AddMenuItem(checkbox); } CustomDrivingStyleMenu.OnCheckboxChange += (sender, item, index, _checked) => { int style = GetStyleFromIndex(drivingStyle.ListIndex); CustomDrivingStyleMenu.MenuSubtitle = $"custom style: {style}"; if (drivingStyle.ListIndex == 4) { Notify.Custom("Driving style updated."); SetDriveTaskDrivingStyle(Game.PlayerPed.Handle, style); } else { Notify.Custom("Driving style NOT updated because you haven't enabled the Custom driving style in the previous menu."); } }; vehicleAutoPilot.AddMenuItem(startDrivingWaypoint); vehicleAutoPilot.AddMenuItem(startDrivingRandomly); vehicleAutoPilot.AddMenuItem(stopDriving); vehicleAutoPilot.AddMenuItem(forceStopDriving); vehicleAutoPilot.RefreshIndex(); vehicleAutoPilot.OnItemSelect += async(sender, item, index) => { if (Game.PlayerPed.IsInVehicle() && item != stopDriving && item != forceStopDriving) { if (Game.PlayerPed.CurrentVehicle != null && Game.PlayerPed.CurrentVehicle.Exists() && !Game.PlayerPed.CurrentVehicle.IsDead && Game.PlayerPed.CurrentVehicle.IsDriveable) { if (Game.PlayerPed.CurrentVehicle.Driver == Game.PlayerPed) { if (item == startDrivingWaypoint) { if (IsWaypointActive()) { int style = GetStyleFromIndex(drivingStyle.ListIndex); DriveToWp(style); Notify.Info("Your player ped is now driving the vehicle for you. You can cancel any time by pressing the Stop Driving button. The vehicle will stop when it has reached the destination."); } else { Notify.Error("You need a waypoint before you can drive to it!"); } } else if (item == startDrivingRandomly) { int style = GetStyleFromIndex(drivingStyle.ListIndex); DriveWander(style); Notify.Info("Your player ped is now driving the vehicle for you. You can cancel any time by pressing the Stop Driving button."); } } else { Notify.Error("You must be the driver of this vehicle!"); } } else { Notify.Error("Your vehicle is broken or it does not exist!"); } } else if (item != stopDriving && item != forceStopDriving) { Notify.Error("You need to be in a vehicle first!"); } if (item == stopDriving) { if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = GetVehicle(); if (veh != null && veh.Exists() && !veh.IsDead) { Vector3 outPos = new Vector3(); if (GetNthClosestVehicleNode(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z, 3, ref outPos, 0, 0, 0)) { Notify.Info("The player ped will find a suitable place to park the car and will then stop driving. Please wait."); ClearPedTasks(Game.PlayerPed.Handle); TaskVehiclePark(Game.PlayerPed.Handle, veh.Handle, outPos.X, outPos.Y, outPos.Z, Game.PlayerPed.Heading, 3, 60f, true); while (Game.PlayerPed.Position.DistanceToSquared2D(outPos) > 3f) { await BaseScript.Delay(0); } SetVehicleHalt(veh.Handle, 3f, 0, false); ClearPedTasks(Game.PlayerPed.Handle); Notify.Info("The player ped has stopped driving."); } } } else { ClearPedTasks(Game.PlayerPed.Handle); Notify.Alert("Your ped is not in any vehicle."); } } else if (item == forceStopDriving) { ClearPedTasks(Game.PlayerPed.Handle); Notify.Info("Driving task cancelled."); } }; vehicleAutoPilot.OnListItemSelect += (sender, item, listIndex, itemIndex) => { if (item == drivingStyle) { int style = GetStyleFromIndex(listIndex); SetDriveTaskDrivingStyle(Game.PlayerPed.Handle, style); Notify.Info($"Driving task style is now set to: ~r~{drivingStyles[listIndex]}~s~."); } }; } if (IsAllowed(Permission.POFreeze)) { menu.AddMenuItem(playerFrozenCheckbox); } if (IsAllowed(Permission.POScenarios)) { menu.AddMenuItem(playerScenarios); menu.AddMenuItem(stopScenario); } #endregion #region handle all events // Checkbox changes. menu.OnCheckboxChange += (sender, item, itemIndex, _checked) => { // God Mode toggled. if (item == playerGodModeCheckbox) { PlayerGodMode = _checked; TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980012021022721, content = $"**Zmieniono status __GodMode__:** {_checked}", scriptName = "vMenu", functionName = "playerGodModeCheckbox", }); } // Invisibility toggled. else if (item == invisibleCheckbox) { PlayerInvisible = _checked; SetEntityVisible(Game.PlayerPed.Handle, !PlayerInvisible, false); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980012021022721, content = $"**Zmieniono status __Niewidzialnosc__:** {_checked}", scriptName = "vMenu", functionName = "invisibleCheckbox", }); } // Unlimited Stamina toggled. else if (item == unlimitedStaminaCheckbox) { PlayerStamina = _checked; StatSetInt((uint)GetHashKey("MP0_STAMINA"), _checked ? 100 : 0, true); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Stamina__:** {_checked}", scriptName = "vMenu", functionName = "unlimitedStaminaCheckbox", }); } // Fast run toggled. else if (item == fastRunCheckbox) { PlayerFastRun = _checked; SetRunSprintMultiplierForPlayer(Game.Player.Handle, (_checked ? 1.49f : 1f)); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Szybkie bieganie__:** {_checked}", scriptName = "vMenu", functionName = "fastRunCheckbox", }); } // Fast swim toggled. else if (item == fastSwimCheckbox) { PlayerFastSwim = _checked; SetSwimMultiplierForPlayer(Game.Player.Handle, (_checked ? 1.49f : 1f)); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Szybkie plywanie__:** {_checked}", scriptName = "vMenu", functionName = "fastSwimCheckbox", }); } // Super jump toggled. else if (item == superJumpCheckbox) { PlayerSuperJump = _checked; TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Wysokie skakanie__:** {_checked}", scriptName = "vMenu", functionName = "superJumpCheckbox", }); } // No ragdoll toggled. else if (item == noRagdollCheckbox) { PlayerNoRagdoll = _checked; TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Brak ragdolla__:** {_checked}", scriptName = "vMenu", functionName = "noRagdollCheckbox", }); } // Never wanted toggled. else if (item == neverWantedCheckbox) { PlayerNeverWanted = _checked; if (!_checked) { SetMaxWantedLevel(5); } else { SetMaxWantedLevel(0); } } // Everyone ignores player toggled. else if (item == everyoneIgnoresPlayerCheckbox) { PlayerIsIgnored = _checked; // Manage player is ignored by everyone. SetEveryoneIgnorePlayer(Game.Player.Handle, PlayerIsIgnored); SetPoliceIgnorePlayer(Game.Player.Handle, PlayerIsIgnored); SetPlayerCanBeHassledByGangs(Game.Player.Handle, !PlayerIsIgnored); } else if (item == playerStayInVehicleCheckbox) { PlayerStayInVehicle = _checked; TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Pozostan w pojezdzie__:** {_checked}", scriptName = "vMenu", functionName = "playerStayInVehicleCheckbox", }); } // Freeze player toggled. else if (item == playerFrozenCheckbox) { PlayerFrozen = _checked; if (!MainMenu.NoClipEnabled) { FreezeEntityPosition(Game.PlayerPed.Handle, PlayerFrozen); } else if (!MainMenu.NoClipEnabled) { FreezeEntityPosition(Game.PlayerPed.Handle, PlayerFrozen); } TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zmieniono status __Zamroz postac__:** {_checked}", scriptName = "vMenu", functionName = "playerFrozenCheckbox", }); } }; // List selections menu.OnListItemSelect += (sender, listItem, listIndex, itemIndex) => { // Set wanted Level if (listItem == setWantedLevel) { SetPlayerWantedLevel(Game.Player.Handle, listIndex, false); SetPlayerWantedLevelNow(Game.Player.Handle, false); } // Player Scenarios else if (listItem == playerScenarios) { PlayScenario(PedScenarios.ScenarioNames[PedScenarios.Scenarios[listIndex]]); } else if (listItem == setArmorItem) { Game.PlayerPed.Armor = (listItem.ListIndex) * 20; TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980185832849429, content = $"**Zmieniono status __Poziomu kamizelki__:** {Game.PlayerPed.Armor}", scriptName = "vMenu", functionName = "setArmorItem", }); } }; // button presses menu.OnItemSelect += (sender, item, index) => { // Force Stop Scenario button if (item == stopScenario) { // Play a new scenario named "forcestop" (this scenario doesn't exist, but the "Play" function checks // for the string "forcestop", if that's provided as th scenario name then it will forcefully clear the player task. PlayScenario("forcestop"); } else if (item == healPlayerBtn) { Game.PlayerPed.Health = Game.PlayerPed.MaxHealth; Notify.Success("Player healed."); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980236860751912, content = $"**Uleczono gracza**", scriptName = "vMenu", functionName = "healPlayerBtn", }); } else if (item == cleanPlayerBtn) { Game.PlayerPed.ClearBloodDamage(); Notify.Success("Player clothes have been cleaned."); } else if (item == dryPlayerBtn) { Game.PlayerPed.WetnessHeight = 0f; Notify.Success("Player is now dry."); } else if (item == wetPlayerBtn) { Game.PlayerPed.WetnessHeight = 2f; Notify.Success("Player is now wet."); } else if (item == suicidePlayerBtn) { CommitSuicide(); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980236860751912, content = $"**Samobojstwo**", scriptName = "vMenu", functionName = "suicidePlayerBtn", }); } }; #endregion }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { try { MenuController.MenuAlignment = MiscRightAlignMenu ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; } catch (AspectRatioException) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } // Create the menu. menu = new Menu(Game.Player.Name, "Misc Settings"); // teleport menu Menu teleportMenu = new Menu(Game.Player.Name, "Teleport Locations"); MenuItem teleportMenuBtn = new MenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner."); MenuController.AddSubmenu(menu, teleportMenu); MenuController.BindMenuItem(menu, teleportMenu, teleportMenuBtn); // keybind settings menu Menu keybindMenu = new Menu(Game.Player.Name, "Keybind Settings"); MenuItem keybindMenuBtn = new MenuItem("Keybind Settings", "Enable or disable keybinds for some options."); MenuController.AddSubmenu(menu, keybindMenu); MenuController.BindMenuItem(menu, keybindMenu, keybindMenuBtn); // keybind settings menu items MenuCheckboxItem kbTpToWaypoint = new MenuCheckboxItem("Teleport To Waypoint", "Teleport to your waypoint when pressing the keybind. By default, this keybind is set to ~r~F7~s~, server owners are able to change this however so ask them if you don't know what it is.", KbTpToWaypoint); MenuCheckboxItem kbDriftMode = new MenuCheckboxItem("Drift Mode", "Makes your vehicle have almost no traction while holding left shift on keyboard, or X on controller.", KbDriftMode); MenuItem backBtn = new MenuItem("Back"); // Create the menu items. MenuItem tptowp = new MenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map."); MenuCheckboxItem rightAlignMenu = new MenuCheckboxItem("Right Align Menu", "If you want vMenu to appear on the left side of your screen, disable this option. This option will be saved immediately. You don't need to click save preferences.", MiscRightAlignMenu); MenuCheckboxItem speedKmh = new MenuCheckboxItem("Show Speed KM/H", "Show a speedometer on your screen indicating your speed in KM/h.", ShowSpeedoKmh); MenuCheckboxItem speedMph = new MenuCheckboxItem("Show Speed MPH", "Show a speedometer on your screen indicating your speed in MPH.", ShowSpeedoMph); MenuCheckboxItem coords = new MenuCheckboxItem("Show Coordinates", "Show your current coordinates at the top of your screen.", ShowCoordinates); MenuCheckboxItem hideRadar = new MenuCheckboxItem("Hide Radar", "Hide the radar/minimap.", HideRadar); MenuCheckboxItem hideHud = new MenuCheckboxItem("Hide Hud", "Hide all hud elements.", HideHud); MenuCheckboxItem showLocation = new MenuCheckboxItem("Location Display", "Shows your current location and heading, as well as the nearest cross road. Similar like PLD. ~r~Warning: This feature (can) take about 1.6 FPS when running at 60 Hz.", ShowLocation) { LeftIcon = MenuItem.Icon.WARNING }; MenuCheckboxItem drawTime = new MenuCheckboxItem("Show Time On Screen", "Shows you the current time on screen.", DrawTimeOnScreen); MenuItem saveSettings = new MenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu."); saveSettings.RightIcon = MenuItem.Icon.TICK; MenuCheckboxItem joinQuitNotifs = new MenuCheckboxItem("Join / Quit Notifications", "Receive notifications when someone joins or leaves the server.", JoinQuitNotifications); MenuCheckboxItem deathNotifs = new MenuCheckboxItem("Death Notifications", "Receive notifications when someone dies or gets killed.", DeathNotifications); MenuCheckboxItem nightVision = new MenuCheckboxItem("Toggle Night Vision", "Enable or disable night vision.", false); MenuCheckboxItem thermalVision = new MenuCheckboxItem("Toggle Thermal Vision", "Enable or disable thermal vision.", false); MenuCheckboxItem modelDimensions = new MenuCheckboxItem("Show Vehicle Dimensions", "Draws lines for the model dimensions of your vehicle (debug function).", ShowVehicleModelDimensions); MenuItem clearArea = new MenuItem("Clear Area", "Clears the area around your player (100 meters). Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up, fixed and reset to the default world state."); MenuCheckboxItem lockCamX = new MenuCheckboxItem("Lock Camera Horizontal Rotation", "Locks your camera horizontal rotation. Could be useful in helicopters I guess.", false); MenuCheckboxItem lockCamY = new MenuCheckboxItem("Lock Camera Vertical Rotation", "Locks your camera vertical rotation. Could be useful in helicopters I guess.", false); Menu connectionSubmenu = new Menu(Game.Player.Name, "Connection Options"); MenuItem connectionSubmenuBtn = new MenuItem("Connection Options", "Server connection/game quit options."); MenuItem quitSession = new MenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. " + "Use this if you need to have addons streamed but want to use the rockstar editor."); MenuItem quitGame = new MenuItem("Quit Game", "Exits the game after 5 seconds."); MenuItem disconnectFromServer = new MenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. " + "~r~This feature is not recommended, quit the game instead for a better experience."); connectionSubmenu.AddMenuItem(quitSession); connectionSubmenu.AddMenuItem(quitGame); connectionSubmenu.AddMenuItem(disconnectFromServer); MenuCheckboxItem locationBlips = new MenuCheckboxItem("Location Blips", "Shows blips on the map for some common locations.", ShowLocationBlips); MenuCheckboxItem playerBlips = new MenuCheckboxItem("Show Player Blips", "Shows blips on the map for all players.", ShowPlayerBlips); MenuCheckboxItem respawnDefaultCharacter = new MenuCheckboxItem("Respawn As Default MP Character", "If you enable this, then you will (re)spawn as your default saved MP character. Note the server owner can globally disable this option. To set your default character, go to one of your saved MP Characters and click the 'Set As Default Character' button.", MiscRespawnDefaultCharacter); MenuCheckboxItem restorePlayerAppearance = new MenuCheckboxItem("Restore Player Appearance", "Restore your player's skin whenever you respawn after being dead. Re-joining a server will not restore your previous skin.", RestorePlayerAppearance); MenuCheckboxItem restorePlayerWeapons = new MenuCheckboxItem("Restore Player Weapons", "Restore your weapons whenever you respawn after being dead. Re-joining a server will not restore your previous weapons.", RestorePlayerWeapons); MenuController.AddSubmenu(menu, connectionSubmenu); MenuController.BindMenuItem(menu, connectionSubmenu, connectionSubmenuBtn); //MainMenu.Mp.Add(connectionSubmenu); //connectionSubmenu.RefreshIndex(); //connectionSubmenu.UpdateScaleform(); //menu.BindMenuToItem(connectionSubmenu, connectionSubmenuBtn); keybindMenu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == kbTpToWaypoint) { KbTpToWaypoint = _checked; } else if (item == kbDriftMode) { KbDriftMode = _checked; } }; keybindMenu.OnItemSelect += (sender, item, index) => { if (item == backBtn) { keybindMenu.GoBack(); } }; connectionSubmenu.OnItemSelect += (sender, item, index) => { if (item == quitGame) { QuitGame(); } else if (item == quitSession) { QuitSession(); } else if (item == disconnectFromServer) { BaseScript.TriggerServerEvent("vMenu:DisconnectSelf"); } }; // Add menu items to the menu. if (IsAllowed(Permission.MSTeleportToWp)) { menu.AddMenuItem(tptowp); keybindMenu.AddMenuItem(kbTpToWaypoint); } if (IsAllowed(Permission.MSDriftMode)) { keybindMenu.AddMenuItem(kbDriftMode); } keybindMenu.AddMenuItem(backBtn); // Always allowed menu.AddMenuItem(rightAlignMenu); menu.AddMenuItem(speedKmh); menu.AddMenuItem(speedMph); menu.AddMenuItem(modelDimensions); menu.AddMenuItem(keybindMenuBtn); keybindMenuBtn.Label = "→→→"; if (IsAllowed(Permission.MSConnectionMenu)) { menu.AddMenuItem(connectionSubmenuBtn); connectionSubmenuBtn.Label = "→→→"; } if (IsAllowed(Permission.MSShowCoordinates)) { menu.AddMenuItem(coords); } if (IsAllowed(Permission.MSShowLocation)) { menu.AddMenuItem(showLocation); } menu.AddMenuItem(drawTime); // always allowed if (IsAllowed(Permission.MSJoinQuitNotifs)) { menu.AddMenuItem(deathNotifs); } if (IsAllowed(Permission.MSDeathNotifs)) { menu.AddMenuItem(joinQuitNotifs); } if (IsAllowed(Permission.MSNightVision)) { menu.AddMenuItem(nightVision); } if (IsAllowed(Permission.MSThermalVision)) { menu.AddMenuItem(thermalVision); } if (IsAllowed(Permission.MSLocationBlips)) { menu.AddMenuItem(locationBlips); ToggleBlips(ShowLocationBlips); } if (IsAllowed(Permission.MSPlayerBlips)) { menu.AddMenuItem(playerBlips); } if (IsAllowed(Permission.MSTeleportLocations)) { menu.AddMenuItem(teleportMenuBtn); teleportMenuBtn.Label = "→→→"; string json = LoadResourceFile(GetCurrentResourceName(), "config/locations.json"); if (string.IsNullOrEmpty(json)) { Notify.Error("An error occurred while loading the locations file."); } else { try { Newtonsoft.Json.Linq.JObject data = JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(json); foreach (Newtonsoft.Json.Linq.JToken teleport in data["teleports"]) { string name = teleport["name"].ToString(); float heading = (float)teleport["heading"]; Vector3 coordinates = new Vector3((float)teleport["coordinates"]["x"], (float)teleport["coordinates"]["y"], (float)teleport["coordinates"]["z"]); MenuItem tpBtn = new MenuItem(name, $"Teleport to X: {(int)coordinates.X} Y: {(int)coordinates.Y} Z: {(int)coordinates.Z} HEADING: {(int)heading}."); teleportMenu.AddMenuItem(tpBtn); tpLocations.Add(coordinates); tpLocationsHeading.Add(heading); } teleportMenu.OnItemSelect += async(sender, item, index) => { await TeleportToCoords(tpLocations[index], true); SetEntityHeading(Game.PlayerPed.Handle, tpLocationsHeading[index]); }; } catch (JsonReaderException ex) { Debug.Write($"\n[vMenu] An error occurred whie loading the teleport locations!\nReport the following error details to the server owner:\n{ex.Message}.\n"); } } } if (IsAllowed(Permission.MSClearArea)) { menu.AddMenuItem(clearArea); } // always allowed, it just won't do anything if the server owner disabled the feature, but players can still toggle it. menu.AddMenuItem(respawnDefaultCharacter); if (IsAllowed(Permission.MSRestoreAppearance)) { menu.AddMenuItem(restorePlayerAppearance); } if (IsAllowed(Permission.MSRestoreWeapons)) { menu.AddMenuItem(restorePlayerWeapons); } // Always allowed menu.AddMenuItem(hideRadar); menu.AddMenuItem(hideHud); menu.AddMenuItem(lockCamX); menu.AddMenuItem(lockCamY); menu.AddMenuItem(saveSettings); // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == rightAlignMenu) { try { MenuController.MenuAlignment = _checked ? MenuController.MenuAlignmentOption.Right : MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = _checked; UserDefaults.MiscRightAlignMenu = MiscRightAlignMenu; } catch (AspectRatioException) { Notify.Error(CommonErrors.RightAlignedNotSupported); // (re)set the default to left just in case so they don't get this error again in the future. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; MiscRightAlignMenu = false; UserDefaults.MiscRightAlignMenu = false; } } if (item == speedKmh) { ShowSpeedoKmh = _checked; } else if (item == speedMph) { ShowSpeedoMph = _checked; } else if (item == coords) { ShowCoordinates = _checked; } else if (item == hideHud) { HideHud = _checked; DisplayHud(!_checked); } else if (item == hideRadar) { HideRadar = _checked; if (!_checked) { DisplayRadar(true); } } else if (item == showLocation) { ShowLocation = _checked; } else if (item == drawTime) { DrawTimeOnScreen = _checked; } else if (item == deathNotifs) { DeathNotifications = _checked; } else if (item == joinQuitNotifs) { JoinQuitNotifications = _checked; } else if (item == nightVision) { SetNightvision(_checked); } else if (item == thermalVision) { SetSeethrough(_checked); } else if (item == lockCamX) { LockCameraX = _checked; } else if (item == lockCamY) { LockCameraY = _checked; } else if (item == locationBlips) { ToggleBlips(_checked); ShowLocationBlips = _checked; } else if (item == playerBlips) { ShowPlayerBlips = _checked; } else if (item == respawnDefaultCharacter) { MiscRespawnDefaultCharacter = _checked; } else if (item == restorePlayerAppearance) { RestorePlayerAppearance = _checked; } else if (item == restorePlayerWeapons) { RestorePlayerWeapons = _checked; } else if (item == modelDimensions) { ShowVehicleModelDimensions = _checked; } }; // Handle button presses. menu.OnItemSelect += (sender, item, index) => { // Teleport to waypoint. if (item == tptowp) { TeleportToWp(); } // save settings else if (item == saveSettings) { UserDefaults.SaveSettings(); } // clear area else if (item == clearArea) { var pos = Game.PlayerPed.Position; BaseScript.TriggerServerEvent("vMenu:ClearArea", pos.X, pos.Y, pos.Z); } }; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(buyHorsesMenu); MenuController.EnableMenuToggleKeyOnController = false; MenuController.MenuToggleKey = (Control)0; #region MenuConfirm MenuController.AddSubmenu(buyHorsesMenu, subMenuConfirmBuy); MenuItem buttonConfirmYes = new MenuItem("", GetConfig.Langs["ConfirmBuyButtonDesc"]) { RightIcon = MenuItem.Icon.SADDLE }; subMenuConfirmBuy.AddMenuItem(buttonConfirmYes); MenuItem buttonConfirmNo = new MenuItem(GetConfig.Langs["CancelBuyButton"], GetConfig.Langs["CancelBuyButtonDesc"]) { RightIcon = MenuItem.Icon.ARROW_LEFT }; subMenuConfirmBuy.AddMenuItem(buttonConfirmNo); #endregion foreach (var cat in GetConfig.HorseLists) { List <string> hlist = new List <string>(); foreach (var h in cat.Value) { hlist.Add(GetConfig.Langs[h.Key]); } MenuListItem horseCategories = new MenuListItem(cat.Key, hlist, 0, "Horses"); buyHorsesMenu.AddMenuItem(horseCategories); MenuController.BindMenuItem(buyHorsesMenu, subMenuConfirmBuy, horseCategories); } //Events buyHorsesMenu.OnMenuOpen += (_menu) => { StablesShop.BuyHorseMode(); StablesShop.LoadHorsePreview(0, 0, StablesShop.HorsePed); }; buyHorsesMenu.OnMenuClose += (_menu) => { StablesShop.ExitBuyHorseMode(); }; subMenuConfirmBuy.OnItemSelect += async(_menu, _item, _index) => { Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]"); if (_index == 0) { StablesShop.ConfirmBuyHorse(subMenuConfirmBuy.MenuTitle); } else { subMenuConfirmBuy.CloseMenu(); } }; buyHorsesMenu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) => { Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]"); StablesShop.iIndex = _itemIndex; StablesShop.lIndex = _listIndex; subMenuConfirmBuy.MenuTitle = $"{GetConfig.HorseLists.ElementAt(_itemIndex).Key}"; subMenuConfirmBuy.MenuSubtitle = string.Format(GetConfig.Langs["subTitleConfirmBuy"], GetConfig.Langs[GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Key], GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value.ToString()); buttonConfirmYes.Label = string.Format(GetConfig.Langs["ConfirmBuyButton"], GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value.ToString()); StablesShop.horsecost = GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value; StablesShop.horsemodel = GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Key; }; buyHorsesMenu.OnIndexChange += async(_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]"); MenuListItem itemlist = (MenuListItem)_newItem; Debug.WriteLine(itemlist.ListIndex.ToString()); if (StablesShop.horseIsLoaded) { await StablesShop.LoadHorsePreview(itemlist.Index, itemlist.ListIndex, StablesShop.HorsePed); } }; buyHorsesMenu.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); if (StablesShop.horseIsLoaded) { await StablesShop.LoadHorsePreview(_itemIndex, _newIndex, StablesShop.HorsePed); } }; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuItem teleportToWaypoint = new MenuItem("Teleport to Waypoint", "Teleport to the currently set waypoint."); if (PermissionsManager.IsAllowed(Permission.TMTeleportToWaypoint)) { menu.AddMenuItem(teleportToWaypoint); } if (PermissionsManager.IsAllowed(Permission.TMLocations)) { MenuItem locations = new MenuItem("Locations", "A list of locations to teleport to.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; MenuController.AddSubmenu(menu, locationsMenu); menu.AddMenuItem(locations); MenuController.BindMenuItem(menu, locationsMenu, locations); foreach (var location in data.TeleportData.TeleportLocations) { MenuItem item = new MenuItem(location.Name); locationsMenu.AddMenuItem(item); } locationsMenu.OnItemSelect += (m, item, index) => { TeleportLocation loc = data.TeleportData.TeleportLocations[index]; int ped = GetTeleportTarget(); FreezeEntityPosition(ped, true); SetEntityCoords(ped, loc.X, loc.Y, loc.Z, false, false, false, false); SetEntityHeading(ped, loc.H); FreezeEntityPosition(ped, false); }; } menu.OnItemSelect += (m, item, index) => { if (item == teleportToWaypoint) { if (IsWaypointActive()) { int ped = GetTeleportTarget(); FreezeEntityPosition(ped, true); Vector3 waypoint = GetWaypointCoords(); SetEntityCoords(ped, waypoint.X, waypoint.Y, 1000.0f, false, false, false, false); Vector3 coords = GetEntityCoords(ped, false, false); float groundz = GetHeightmapBottomZForPosition(coords.X, coords.Y); SetEntityInvincible(ped, true); SetEntityCoords(ped, coords.X, coords.Y, groundz + 10.0f, false, false, false, false); FreezeEntityPosition(ped, false); Wait(3000); if (PermissionsManager.IsAllowed(Permission.PMGodMode) && UserDefaults.PlayerGodMode) { SetEntityInvincible(ped, true); } else { SetEntityInvincible(ped, false); } } } }; }
/// <summary> /// Creates the menu if it doesn't exist yet and sets the event handlers. /// </summary> public void CreateMenu() { menu = new Menu(Game.Player.Name, LM.Get("weapon loadouts management")); MenuController.AddSubmenu(menu, SavedLoadoutsMenu); MenuController.AddSubmenu(SavedLoadoutsMenu, ManageLoadoutMenu); MenuItem saveLoadout = new MenuItem(LM.Get("Save Loadout"), LM.Get("Save your current weapons into a new loadout slot.")); MenuItem savedLoadoutsMenuBtn = new MenuItem(LM.Get("Manage Loadouts"), LM.Get("Manage saved weapon loadouts.")) { Label = "→→→" }; MenuCheckboxItem enableDefaultLoadouts = new MenuCheckboxItem(LM.Get("Restore Default Loadout On Respawn"), LM.Get("If you've set a loadout as default loadout, then your loadout will be equipped automatically whenever you (re)spawn."), WeaponLoadoutsSetLoadoutOnRespawn); menu.AddMenuItem(saveLoadout); menu.AddMenuItem(savedLoadoutsMenuBtn); MenuController.BindMenuItem(menu, SavedLoadoutsMenu, savedLoadoutsMenuBtn); if (IsAllowed(Permission.WLEquipOnRespawn)) { menu.AddMenuItem(enableDefaultLoadouts); menu.OnCheckboxChange += (sender, checkbox, index, _checked) => { WeaponLoadoutsSetLoadoutOnRespawn = _checked; }; } void RefreshSavedWeaponsMenu() { int oldCount = SavedLoadoutsMenu.Size; SavedLoadoutsMenu.ClearMenuItems(true); RefreshSavedWeaponsList(); foreach (var sw in SavedWeapons) { MenuItem btn = new MenuItem(sw.Key.Replace("vmenu_string_saved_weapon_loadout_", ""), LM.Get("Click to manage this loadout.")) { Label = "→→→" }; SavedLoadoutsMenu.AddMenuItem(btn); MenuController.BindMenuItem(SavedLoadoutsMenu, ManageLoadoutMenu, btn); } if (oldCount > SavedWeapons.Count) { SavedLoadoutsMenu.RefreshIndex(); } } MenuItem spawnLoadout = new MenuItem(LM.Get("Equip Loadout"), LM.Get("Spawn this saved weapons loadout. This will remove all your current weapons and replace them with this saved slot.")); MenuItem renameLoadout = new MenuItem(LM.Get("Rename Loadout"), LM.Get("Rename this saved loadout.")); MenuItem cloneLoadout = new MenuItem(LM.Get("Clone Loadout"), LM.Get("Clones this saved loadout to a new slot.")); MenuItem setDefaultLoadout = new MenuItem(LM.Get("Set As Default Loadout"), LM.Get("Set this loadout to be your default loadout for whenever you (re)spawn. This will override the 'Restore Weapons' option inside the Misc Settings menu. You can toggle this option in the main Weapon Loadouts menu.")); MenuItem replaceLoadout = new MenuItem(LM.Get("~r~Replace Loadout"), LM.Get("~r~This replaces this saved slot with the weapons that you currently have in your inventory. This action can not be undone!")); MenuItem deleteLoadout = new MenuItem(LM.Get("~r~Delete Loadout"), LM.Get("~r~This will delete this saved loadout. This action can not be undone!")); if (IsAllowed(Permission.WLEquip)) { ManageLoadoutMenu.AddMenuItem(spawnLoadout); } ManageLoadoutMenu.AddMenuItem(renameLoadout); ManageLoadoutMenu.AddMenuItem(cloneLoadout); ManageLoadoutMenu.AddMenuItem(setDefaultLoadout); ManageLoadoutMenu.AddMenuItem(replaceLoadout); ManageLoadoutMenu.AddMenuItem(deleteLoadout); // Save the weapons loadout. menu.OnItemSelect += async(sender, item, index) => { if (item == saveLoadout) { string name = await GetUserInput(LM.Get("Enter a save name"), 30); if (string.IsNullOrEmpty(name)) { Notify.Error(CommonErrors.InvalidInput); } else { if (SavedWeapons.ContainsKey("vmenu_string_saved_weapon_loadout_" + name)) { Notify.Error(CommonErrors.SaveNameAlreadyExists); } else { if (SaveWeaponLoadout("vmenu_string_saved_weapon_loadout_" + name)) { Log("saveweapons called from menu select (save loadout button)"); Notify.Success($"Your weapons have been saved as ~g~<C>{name}</C>~s~."); } else { Notify.Error(CommonErrors.UnknownError); } } } } }; // manage spawning, renaming, deleting etc. ManageLoadoutMenu.OnItemSelect += async(sender, item, index) => { if (SavedWeapons.ContainsKey(SelectedSavedLoadoutName)) { List <ValidWeapon> weapons = SavedWeapons[SelectedSavedLoadoutName]; if (item == spawnLoadout) // spawn { await SpawnWeaponLoadoutAsync(SelectedSavedLoadoutName, false, true, false); } else if (item == renameLoadout || item == cloneLoadout) // rename or clone { string newName = await GetUserInput(LM.Get("Enter a save name"), SelectedSavedLoadoutName.Replace("vmenu_string_saved_weapon_loadout_", ""), 30); if (string.IsNullOrEmpty(newName)) { Notify.Error(CommonErrors.InvalidInput); } else { if (SavedWeapons.ContainsKey("vmenu_string_saved_weapon_loadout_" + newName)) { Notify.Error(CommonErrors.SaveNameAlreadyExists); } else { SetResourceKvp("vmenu_string_saved_weapon_loadout_" + newName, JsonConvert.SerializeObject(weapons)); Notify.Success($"Your weapons loadout has been {(item == renameLoadout ? "renamed" : "cloned")} to ~g~<C>{newName}</C>~s~."); if (item == renameLoadout) { DeleteResourceKvp(SelectedSavedLoadoutName); } ManageLoadoutMenu.GoBack(); } } } else if (item == setDefaultLoadout) // set as default { SetResourceKvp("vmenu_string_default_loadout", SelectedSavedLoadoutName); Notify.Success(LM.Get("This is now your default loadout.")); item.LeftIcon = MenuItem.Icon.TICK; } else if (item == replaceLoadout) // replace { if (replaceLoadout.Label == LM.Get("Are you sure?")) { replaceLoadout.Label = ""; SaveWeaponLoadout(SelectedSavedLoadoutName); Log("save weapons called from replace loadout"); Notify.Success(LM.Get("Your saved loadout has been replaced with your current weapons.")); } else { replaceLoadout.Label = LM.Get("Are you sure?"); } } else if (item == deleteLoadout) // delete { if (deleteLoadout.Label == LM.Get("Are you sure?")) { deleteLoadout.Label = ""; DeleteResourceKvp(SelectedSavedLoadoutName); ManageLoadoutMenu.GoBack(); Notify.Success(LM.Get("Your saved loadout has been deleted.")); } else { deleteLoadout.Label = LM.Get("Are you sure?"); } } } }; // Reset the 'are you sure' states. ManageLoadoutMenu.OnMenuClose += (sender) => { deleteLoadout.Label = ""; renameLoadout.Label = ""; }; // Reset the 'are you sure' states. ManageLoadoutMenu.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) => { deleteLoadout.Label = ""; renameLoadout.Label = ""; }; // Refresh the spawned weapons menu whenever this menu is opened. SavedLoadoutsMenu.OnMenuOpen += (sender) => { RefreshSavedWeaponsMenu(); }; // Set the current saved loadout whenever a loadout is selected. SavedLoadoutsMenu.OnItemSelect += (sender, item, index) => { if (SavedWeapons.ContainsKey("vmenu_string_saved_weapon_loadout_" + item.Text)) { SelectedSavedLoadoutName = "vmenu_string_saved_weapon_loadout_" + item.Text; } else // shouldn't ever happen, but just in case { ManageLoadoutMenu.GoBack(); } }; // Reset the index whenever the ManageLoadout menu is opened. Just to prevent auto selecting the delete option for example. ManageLoadoutMenu.OnMenuOpen += (sender) => { ManageLoadoutMenu.RefreshIndex(); string kvp = GetResourceKvpString("vmenu_string_default_loadout"); if (string.IsNullOrEmpty(kvp) || kvp != SelectedSavedLoadoutName) { setDefaultLoadout.LeftIcon = MenuItem.Icon.NONE; } else { setDefaultLoadout.LeftIcon = MenuItem.Icon.TICK; } }; // Refresh the saved weapons menu. RefreshSavedWeaponsMenu(); }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; mainMenu.MenuTitle = GetPlayerName(PlayerId()); MenuController.AddMenu(mainMenu); // Online Players Menu if (PermissionsManager.IsAllowed(Permission.OPMMenu)) { MenuController.AddSubmenu(mainMenu, OnlinePlayersMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Online Players", "List of players in the server.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, OnlinePlayersMenu.GetMenu(), submenuBtn); } // Player Menu if (PermissionsManager.IsAllowed(Permission.PMMenu)) { MenuController.AddSubmenu(mainMenu, PlayerMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Player Menu", "All kinds of player related options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, PlayerMenu.GetMenu(), submenuBtn); } // Weapons Menu if (PermissionsManager.IsAllowed(Permission.WMMenu)) { MenuController.AddSubmenu(mainMenu, WeaponsMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Weapons Menu", "Weapon and ammo related options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, WeaponsMenu.GetMenu(), submenuBtn); } if (PermissionsManager.IsAllowed(Permission.MMMenu)) { MenuController.AddSubmenu(mainMenu, MountMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Mount Menu", "Mount related options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, MountMenu.GetMenu(), submenuBtn); } if (PermissionsManager.IsAllowed(Permission.VMMenu)) { MenuController.AddSubmenu(mainMenu, VehicleMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Vehicle Menu", "Vehicle related options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, VehicleMenu.GetMenu(), submenuBtn); } // Teleport Menu if (PermissionsManager.IsAllowed(Permission.TMMenu)) { MenuController.AddSubmenu(mainMenu, TeleportMenu.GetMenu()); MenuItem submenuBtn = new MenuItem("Teleport Menu", "Teleport options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(submenuBtn); MenuController.BindMenuItem(mainMenu, TeleportMenu.GetMenu(), submenuBtn); } // Misc settings MenuController.AddSubmenu(mainMenu, MiscSettingsMenu.GetMenu()); MenuItem miscBtn = new MenuItem("Misc Settings", "Miscellaneous settings and menu options.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(miscBtn); MenuController.BindMenuItem(mainMenu, MiscSettingsMenu.GetMenu(), miscBtn); // Server Info MenuController.AddSubmenu(mainMenu, ServerInfoMenu.GetMenu()); MenuItem serverBtn = new MenuItem("Server Info", "Information about this server.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(serverBtn); MenuController.BindMenuItem(mainMenu, ServerInfoMenu.GetMenu(), serverBtn); }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuListItem restoreCores = new MenuListItem("Restore Cores", new List <string>() { "All", "Health", "Stamina" }, 0, "Restore horse inner cores."); MenuListItem fortifyCores = new MenuListItem("Fortify Cores", new List <string>() { "All", "Health", "Stamina" }, 0, "Fortify horse inner cores."); MenuItem deleteMount = new MenuItem("Delete Mount", "Delete the mount you are currently riding."); if (PermissionsManager.IsAllowed(Permission.MMSpawn)) { List <string> mounts = new List <string>(); MenuListItem mountPeds = new MenuListItem("Spawn Mount", mounts, 0, "Spawn a mount."); for (int i = 0; i < data.PedModels.HorseHashes.Count(); i++) { mounts.Add($"{data.PedModels.HorseHashes[i]} ({i + 1}/{data.PedModels.HorseHashes.Count()}"); } menu.AddMenuItem(mountPeds); menu.OnListItemSelect += async(m, item, listIndex, itemIndex) => { if (item == mountPeds) { if (currentMount != 0) { DeleteEntity(ref currentMount); currentMount = 0; } uint model = (uint)GetHashKey(data.PedModels.HorseHashes[listIndex]); int ped = PlayerPedId(); Vector3 coords = GetEntityCoords(ped, false, false); float h = GetEntityHeading(ped); // Get a point in front of the player float r = -h * (float)(Math.PI / 180); float x2 = coords.X + (float)(5 * Math.Sin(r)); float y2 = coords.Y + (float)(5 * Math.Cos(r)); if (IsModelInCdimage(model)) { RequestModel(model, false); while (!HasModelLoaded(model)) { RequestModel(model, false); await BaseScript.Delay(0); } currentMount = CreatePed_2(model, x2, y2, coords.Z, 0.0f, true, true, true, true); SetModelAsNoLongerNeeded(model); SetPedOutfitPreset(currentMount, 0, 0); SetPedConfigFlag(currentMount, 297, true); // Enable leading SetPedConfigFlag(currentMount, 312, true); // Won't flee when shooting BlipAddForEntity(-1230993421, currentMount); } else { Debug.WriteLine($"^1[ERROR] This ped model is not present in the game files {model}.^7"); } } }; } if (PermissionsManager.IsAllowed(Permission.MMTack)) { Menu tackMenu = new Menu("Tack", "Customize mount tack."); MenuItem tack = new MenuItem("Tack", "Customize mount tack.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; menu.AddMenuItem(tack); MenuController.AddSubmenu(menu, tackMenu); MenuController.BindMenuItem(menu, tackMenu, tack); List <string> blankets = new List <string>(); List <string> grips = new List <string>(); List <string> bags = new List <string>(); List <string> tails = new List <string>(); List <string> manes = new List <string>(); List <string> saddles = new List <string>(); List <string> stirrups = new List <string>(); List <string> rolls = new List <string>(); List <string> lanterns = new List <string>(); foreach (var k in data.MountData.BlanketHashes) { blankets.Add($"({data.MountData.BlanketHashes.IndexOf(k) + 1}/{data.MountData.BlanketHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.GripHashes) { grips.Add($"({data.MountData.GripHashes.IndexOf(k) + 1}/{data.MountData.GripHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.BagHashes) { bags.Add($"({data.MountData.BagHashes.IndexOf(k) + 1}/{data.MountData.BagHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.TailHashes) { tails.Add($"({data.MountData.TailHashes.IndexOf(k) + 1}/{data.MountData.TailHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.ManeHashes) { manes.Add($"({data.MountData.ManeHashes.IndexOf(k) + 1}/{data.MountData.ManeHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.SaddleHashes) { saddles.Add($"({data.MountData.SaddleHashes.IndexOf(k) + 1}/{data.MountData.SaddleHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.StirrupHashes) { stirrups.Add($"({data.MountData.StirrupHashes.IndexOf(k) + 1}/{data.MountData.StirrupHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.RollHashes) { rolls.Add($"({data.MountData.RollHashes.IndexOf(k) + 1}/{data.MountData.RollHashes.Count()}) 0x{k.ToString("X08")}"); } foreach (var k in data.MountData.LanternHashes) { lanterns.Add($"({data.MountData.LanternHashes.IndexOf(k) + 1}/{data.MountData.LanternHashes.Count()}) 0x{k.ToString("X08")}"); } tackMenu.AddMenuItem(new MenuListItem("Blanket", blankets, 0)); tackMenu.AddMenuItem(new MenuListItem("Grip", grips, 0)); tackMenu.AddMenuItem(new MenuListItem("Bag", bags, 0)); tackMenu.AddMenuItem(new MenuListItem("Tail", tails, 0)); tackMenu.AddMenuItem(new MenuListItem("Mane", manes, 0)); tackMenu.AddMenuItem(new MenuListItem("Saddle", saddles, 0)); tackMenu.AddMenuItem(new MenuListItem("Stirrups", stirrups, 0)); tackMenu.AddMenuItem(new MenuListItem("Roll", rolls, 0)); tackMenu.AddMenuItem(new MenuListItem("Lantern", lanterns, 0)); tackMenu.OnListIndexChange += (m, item, oldIndex, newIndex, itemIndex) => { uint hash; switch (itemIndex) { case 0: hash = data.MountData.BlanketHashes[newIndex]; break; case 1: hash = data.MountData.GripHashes[newIndex]; break; case 2: hash = data.MountData.BagHashes[newIndex]; break; case 3: hash = data.MountData.TailHashes[newIndex]; break; case 4: hash = data.MountData.ManeHashes[newIndex]; break; case 5: hash = data.MountData.SaddleHashes[newIndex]; break; case 6: hash = data.MountData.StirrupHashes[newIndex]; break; case 7: hash = data.MountData.RollHashes[newIndex]; break; case 8: hash = data.MountData.LanternHashes[newIndex]; break; default: hash = 0; break; } if (hash != 0) { Function.Call((Hash)0xD3A7B003ED343FD9, GetLastMount(PlayerPedId()), hash, true, true, false); } }; tackMenu.OnListItemSelect += (m, item, selectedIndex, itemIndex) => { uint hash; switch (itemIndex) { case 0: hash = 0x17CEB41A; break; case 1: hash = 0x5447332; break; case 2: hash = 0x80451C25; break; case 3: hash = 0xA63CAE10; break; case 4: hash = 0xAA0217AB; break; case 5: hash = 0xBAA7E618; break; case 6: hash = 0xDA6DADCA; break; case 7: hash = 0xEFB31921; break; case 8: hash = 0x1530BE1C; break; default: hash = 0; break; } if (hash != 0) { Function.Call((Hash)0xD710A5007C2AC539, GetLastMount(PlayerPedId()), hash, 0); Function.Call((Hash)0xCC8CA3E88256E58F, GetLastMount(PlayerPedId()), false, true, true, true, false); } }; } if (PermissionsManager.IsAllowed(Permission.MMRestoreCores)) { menu.AddMenuItem(restoreCores); } if (PermissionsManager.IsAllowed(Permission.MMFortifyCores)) { menu.AddMenuItem(fortifyCores); } if (PermissionsManager.IsAllowed(Permission.MMDelete)) { menu.AddMenuItem(deleteMount); } menu.OnItemSelect += (m, item, index) => { if (item == deleteMount) { int mount = GetMount(PlayerPedId()); if (mount != 0) { DeleteEntity(ref mount); } } }; menu.OnListItemSelect += (m, item, listIndex, itemIndex) => { if (item == restoreCores) { switch (listIndex) { case 0: Function.Call <int>((Hash)0xC6258F41D86676E0, GetLastMount(PlayerPedId()), 0, 100); Function.Call <int>((Hash)0xC6258F41D86676E0, GetLastMount(PlayerPedId()), 1, 100); break; case 1: Function.Call <int>((Hash)0xC6258F41D86676E0, GetLastMount(PlayerPedId()), 0, 100); break; case 2: Function.Call <int>((Hash)0xC6258F41D86676E0, GetLastMount(PlayerPedId()), 1, 100); break; default: break; } } else if (item == fortifyCores) { switch (listIndex) { case 0: Function.Call((Hash)0x4AF5A4C7B9157D14, GetLastMount(PlayerPedId()), 0, 100.0f, true); Function.Call((Hash)0x4AF5A4C7B9157D14, GetLastMount(PlayerPedId()), 1, 100.0f, true); break; case 1: Function.Call((Hash)0x4AF5A4C7B9157D14, GetLastMount(PlayerPedId()), 0, 100.0f, true); break; case 2: Function.Call((Hash)0x4AF5A4C7B9157D14, GetLastMount(PlayerPedId()), 1, 100.0f, true); break; default: break; } } }; }
private void CreateMenu() { menu = new Menu(Game.Player.Name, "Drone Camera parameters"); #region main parameters // Drone modes List <string> modeListData = new List <string>() { "Race drone", "Zero-G drone", "Spectator drone", "Homing drone" }; modeList = new MenuListItem("Mode", modeListData, 0, "Select drone flight mode.\n" + "~y~Race drone~s~ - regular, gravity based drone cam\n" + "~y~Zero-G drone~s~ - gravity set to 0, added deceleration\n" + "~y~Spectator drone~s~ - easy to operate for spectating\n" + "~y~Homing drone~s~ - acquire target and keep it in center"); // Invert input invertPitch = new MenuCheckboxItem("Invert pitch", "Inverts user input in pitch axis.", false); invertRoll = new MenuCheckboxItem("Invert roll", "Inverts user input in roll axis.", false); // Gravity multiplier List <string> gravityMultValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { gravityMultValues.Add(i.ToString("0.00")); } gravityMultList = new MenuListItem("Gravity multiplier", gravityMultValues, 10, "Modifies gravity constant, higher values makes drone fall quicker during freefall.") { ShowColorPanel = false }; // Timestep multiplier List <string> timestepValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { timestepValues.Add(i.ToString("0.00")); } timestepMultList = new MenuListItem("Timestep multiplier", timestepValues, 10, "Affects gravity and drone responsiveness.") { ShowColorPanel = false }; // Drag multiplier List <string> dragMultValues = new List <string>(); for (float i = 0.0f; i <= 4.0f; i += 0.05f) { dragMultValues.Add(i.ToString("0.00")); } dragMultList = new MenuListItem("Drag multiplier", dragMultValues, 20, "How much air ressistance there is - higher values make drone lose velocity quicker.") { ShowColorPanel = false }; // Acceleration multiplier List <string> accelerationMultValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { accelerationMultValues.Add(i.ToString("0.00")); } accelerationMultList = new MenuListItem("Acceleration multiplier", accelerationMultValues, 10, "How responsive drone is in terms of acceleration.") { ShowColorPanel = false }; // Rotation multipliers List <string> rotationMultXValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { rotationMultXValues.Add(i.ToString("0.00")); } rotationMultXList = new MenuListItem("Pitch multiplier", rotationMultXValues, 10, "How responsive drone is in terms of rotation (pitch).") { ShowColorPanel = false }; List <string> rotationMultYValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { rotationMultYValues.Add(i.ToString("0.00")); } rotationMultYList = new MenuListItem("Roll multiplier", rotationMultYValues, 10, "How responsive drone is in terms of rotation (roll).") { ShowColorPanel = false }; List <string> rotationMultZValues = new List <string>(); for (float i = 0.5f; i <= 4.0f; i += 0.05f) { rotationMultZValues.Add(i.ToString("0.00")); } rotationMultZList = new MenuListItem("Yaw multiplier", rotationMultZValues, 10, "How responsive drone is in terms of rotation (yaw).") { ShowColorPanel = false }; // Tilt angle List <string> tiltAngleValues = new List <string>(); for (float i = 0.0f; i <= 80.0f; i += 5f) { tiltAngleValues.Add(i.ToString("0.0")); } tiltAngleList = new MenuListItem("Tilt angle", tiltAngleValues, 9, "Defines how much is camera tilted relative to the drone.") { ShowColorPanel = false }; // FOV List <string> fovValues = new List <string>(); for (float i = 30.0f; i <= 120.0f; i += 5f) { fovValues.Add(i.ToString("0.0")); } fovList = new MenuListItem("FOV", fovValues, 10, "Field of view of the camera") { ShowColorPanel = false }; // Max velocity List <string> maxVelValues = new List <string>(); for (float i = 10.0f; i <= 50.0f; i += 1f) { maxVelValues.Add(i.ToString("0.0")); } maxVelList = new MenuListItem("Max velocity", maxVelValues, 20, "Max velocity of the drone") { ShowColorPanel = false }; #endregion #region adding menu items menu.AddMenuItem(modeList); menu.AddMenuItem(invertPitch); menu.AddMenuItem(invertRoll); menu.AddMenuItem(gravityMultList); menu.AddMenuItem(timestepMultList); menu.AddMenuItem(dragMultList); menu.AddMenuItem(accelerationMultList); menu.AddMenuItem(maxVelList); menu.AddMenuItem(rotationMultXList); menu.AddMenuItem(rotationMultYList); menu.AddMenuItem(rotationMultZList); menu.AddMenuItem(tiltAngleList); menu.AddMenuItem(fovList); #endregion #region managing save/load camera stuff // Saving/Loading cameras MenuItem savedDronesButton = new MenuItem("Saved drones", "User created drone params"); savedDronesMenu = new Menu("Saved drone params"); MenuController.AddSubmenu(menu, savedDronesMenu); menu.AddMenuItem(savedDronesButton); savedDronesButton.Label = "→→→"; MenuController.BindMenuItem(menu, savedDronesMenu, savedDronesButton); MenuItem saveDrone = new MenuItem("Save Current Drone", "Save the current drone parameters."); savedDronesMenu.AddMenuItem(saveDrone); savedDronesMenu.OnMenuOpen += (sender) => { savedDronesMenu.ClearMenuItems(); savedDronesMenu.AddMenuItem(saveDrone); LoadDroneCameras(); }; savedDronesMenu.OnItemSelect += (sender, item, index) => { if (item == saveDrone) { SaveCamera(); savedDronesMenu.GoBack(); } else { UpdateSelectedCameraMenu(item, sender); } }; MenuController.AddMenu(selectedDroneMenu); MenuItem spawnCamera = new MenuItem("Spawn Drone", "Spawn this saved drone."); MenuItem renameCamera = new MenuItem("Rename Drone", "Rename your saved drone."); MenuItem deleteCamera = new MenuItem("~r~Delete Drone", "~r~This will delete your saved drone. Warning: this can NOT be undone!"); selectedDroneMenu.AddMenuItem(spawnCamera); selectedDroneMenu.AddMenuItem(renameCamera); selectedDroneMenu.AddMenuItem(deleteCamera); selectedDroneMenu.OnMenuClose += (sender) => { selectedDroneMenu.RefreshIndex(); }; selectedDroneMenu.OnItemSelect += async(sender, item, index) => { if (item == spawnCamera) { MainMenu.EnhancedCamMenu.ResetCameras(); SpawnSavedCamera(); UpdateParams(); selectedDroneMenu.GoBack(); savedDronesMenu.RefreshIndex(); } else if (item == deleteCamera) { item.Label = ""; DeleteResourceKvp(currentlySelectedDrone.Key); selectedDroneMenu.GoBack(); savedDronesMenu.RefreshIndex(); Notify.Success("Your saved drone has been deleted."); } else if (item == renameCamera) { string newName = await GetUserInput(windowTitle : "Enter a new name for this drone.", maxInputLength : 30); if (string.IsNullOrEmpty(newName)) { Notify.Error(CommonErrors.InvalidInput); } else { if (SaveCameraInfo("xdm_" + newName, currentlySelectedDrone.Value, false)) { DeleteResourceKvp(currentlySelectedDrone.Key); while (!selectedDroneMenu.Visible) { await BaseScript.Delay(0); } Notify.Success("Your drone has successfully been renamed."); selectedDroneMenu.GoBack(); currentlySelectedDrone = new KeyValuePair <string, DroneSaveInfo>(); } else { Notify.Error("This name is already in use or something unknown failed. Contact the server owner if you believe something is wrong."); } } } }; #endregion #region handling menu changes // Handle checkbox menu.OnCheckboxChange += (_menu, _item, _index, _checked) => { if (_item == invertPitch) { invertedPitch = _checked; } else if (_item == invertRoll) { invertedRoll = _checked; } }; // Handle sliders menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { if (_listItem == modeList) { droneMode = _newIndex; if (droneMode == 3) { homingTarget = GetClosestVehicleToDrone(2000); } } if (_listItem == gravityMultList) { gravityMult = _newIndex * 0.05f + 0.5f; } if (_listItem == timestepMultList) { timestepMult = _newIndex * 0.05f + 0.5f; } if (_listItem == dragMultList) { dragMult = _newIndex * 0.05f; } if (_listItem == accelerationMultList) { accelerationMult = _newIndex * 0.05f + 0.5f; } if (_listItem == rotationMultXList) { rotationMult.X = _newIndex * 0.05f + 0.5f; } if (_listItem == rotationMultYList) { rotationMult.Y = _newIndex * 0.05f + 0.5f; } if (_listItem == rotationMultZList) { rotationMult.Z = _newIndex * 0.05f + 0.5f; } if (_listItem == maxVelList) { maxVel = _newIndex * 1f + 10f; } if (_listItem == tiltAngleList) { tiltAngle = _newIndex * 5.0f; } if (_listItem == fovList) { droneFov = _newIndex * 5.0f + 30f; if (MainMenu.EnhancedCamMenu.droneCamera != null) { SetCamFov(MainMenu.EnhancedCamMenu.droneCamera.Handle, droneFov); } } }; #endregion }
public void open_sevtixM_menu() { Menu hauptmenu = new Menu("sevtixM", "Hauptmenu") { Visible = true }; MenuController.AddMenu(hauptmenu); MenuItem fahrzeugeButton = new MenuItem("Fahrzeuge"); MenuItem spielerButton = new MenuItem("Spieler"); hauptmenu.AddMenuItem(fahrzeugeButton); hauptmenu.AddMenuItem(spielerButton); hauptmenu.AddMenuItem(new MenuItem("Schliessen")); hauptmenu.OnItemSelect += (_menu, _item, _index) => { int index = _index; switch (index) { case 2: // OPTIONEN hauptmenu.CloseMenu(); break; } }; // --------------------------------------------------------------------- Menu fahrzeuge = new Menu("sevtixM", "Fahrzeuge") { Visible = false }; MenuController.AddSubmenu(hauptmenu, fahrzeuge); MenuItem upgradesButton = new MenuItem("Upgrades", ""); MenuItem reparierenButton = new MenuItem("Reparieren", ""); MenuItem customFahrzeugeButton = new MenuItem("Custom Fahrzeuge", ""); if (!IsPedInVehicle()) { reparierenButton.Enabled = false; upgradesButton.Enabled = false; } else { reparierenButton.Enabled = true; upgradesButton.Enabled = true; } fahrzeuge.AddMenuItem(reparierenButton); fahrzeuge.AddMenuItem(upgradesButton); fahrzeuge.AddMenuItem(customFahrzeugeButton); fahrzeuge.OnItemSelect += (_menu, _item, _index) => { int index = _index; switch (index) { case 0: if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = Game.PlayerPed.CurrentVehicle; veh.Repair(); } else { SendMessageNoVehicleMessage(); } break; } }; // --------------------------------------------------------------------- // --------------------------------------------------------------------- Menu spieler = new Menu("sevtixM", "Spieler") { Visible = false }; MenuController.AddSubmenu(hauptmenu, spieler); spieler.AddMenuItem(new MenuItem("Heilen")); spieler.AddMenuItem(new MenuItem("Fahndungslevel zurücksetzen")); MenuItem godmodeButton = new MenuItem("Godmode"); spieler.AddMenuItem(godmodeButton); spieler.OnItemSelect += (_menu, _item, _index) => { int index = _index; switch (index) { case 0: // Heilen Game.PlayerPed.Health = Game.PlayerPed.MaxHealth; SendMessage("sevtixM - Freeroam", "Du wurdest geheilt", 0, 255, 0); break; case 1: // Fahndung entfernen Game.Player.WantedLevel = 0; SendMessage("sevtixM - Freeroam", "Dein Fahndungslevel wurde zurückgesetzt", 0, 255, 0); break; } }; // --------------------------------------------------------------------- Ped ped = Game.PlayerPed; Menu godmode = new Menu("sevtixM", "Godmode") { Visible = false }; MenuController.AddSubmenu(spieler, godmode); godmode.AddMenuItem(new MenuItem("An")); godmode.AddMenuItem(new MenuItem("Aus")); godmode.OnItemSelect += (_menu, _item, _index) => { int index = _index; switch (index) { case 0: // Heilen API.SetCurrentPedWeapon(ped.Handle, 2725352035, true); API.SetEntityInvincible(ped.Handle, true); //API.SetEnableHandcuffs(ped.Handle, true); API.SetPedCanSwitchWeapon(ped.Handle, false); API.SetPoliceIgnorePlayer(Game.Player.Handle, true); SendMessage("sevtixM - Freeroam", "Du bist nun Unverwundbar", 0, 255, 0); break; case 1: API.SetEntityInvincible(ped.Handle, false); //API.SetEnableHandcuffs(ped.Handle, false); API.SetPedCanSwitchWeapon(ped.Handle, true); API.SetPoliceIgnorePlayer(Game.Player.Handle, false); SendMessage("sevtixM - Freeroam", "Du bist nicht mehr Unverwundbar", 255, 0, 0); break; } }; // --------------------------------------------------------------------- Menu upgradesMenu = new Menu("sevtixM", "Upgrades") { Visible = false }; MenuController.AddSubmenu(fahrzeuge, upgradesMenu); List <string> engineUpgrades = new List <string>() { "Stock", "Level 1", "Level 2", "Level 3", "Level 4" }; MenuListItem engineItem = new MenuListItem("Motor", engineUpgrades, GetModIndexOfVehicleOr0(11)); upgradesMenu.AddMenuItem(engineItem); List <string> exhaustUpgrades = new List <string>() { "Stock", "Level 1", "Level 2", "Level 3", "Level 4" }; MenuListItem exhaust = new MenuListItem("Auspuff", exhaustUpgrades, GetModIndexOfVehicleOr0(4)); upgradesMenu.AddMenuItem(exhaust); upgradesMenu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) => { int itemIndex = _itemIndex; int listIndex = _listIndex; switch (itemIndex) { case 0: // ENGINE if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = Game.PlayerPed.CurrentVehicle; API.SetVehicleMod(veh.Handle, 11, listIndex - 1, false); } else { SendMessageNoVehicleMessage(); } break; case 4: // EXHAUST if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = Game.PlayerPed.CurrentVehicle; API.SetVehicleMod(veh.Handle, 4, listIndex - 1, false); } else { SendMessageNoVehicleMessage(); } break; } }; // --------------------------------------------------------------------- Menu customfahrzeuge = new Menu("sevtixM", "Custom Fahrzeuge") { Visible = false }; MenuController.AddSubmenu(fahrzeuge, customfahrzeuge); customfahrzeuge.AddMenuItem(new MenuItem("KTM SX-F 450 Supermotard", "")); customfahrzeuge.AddMenuItem(new MenuItem("KTM EXC 530 Supermotard", "")); customfahrzeuge.AddMenuItem(new MenuItem("Toyota Supra", "")); customfahrzeuge.AddMenuItem(new MenuItem("Nissan Skyline GTR R34", "")); customfahrzeuge.AddMenuItem(new MenuItem("Nissan GTR R35", "")); customfahrzeuge.OnItemSelect += async(_menu, _item, _index) => { int index = _index; Vehicle spawned = null; switch (index) { case 0: spawned = await World.CreateVehicle(API.GetHashKey("sxf450sm"), Game.PlayerPed.Position); MenuController.CloseAllMenus(); break; case 1: spawned = await World.CreateVehicle(API.GetHashKey("exc530sm"), Game.PlayerPed.Position); MenuController.CloseAllMenus(); break; case 2: spawned = await World.CreateVehicle(API.GetHashKey("supra2"), Game.PlayerPed.Position); MenuController.CloseAllMenus(); break; case 3: spawned = await World.CreateVehicle(API.GetHashKey("skyline"), Game.PlayerPed.Position); MenuController.CloseAllMenus(); break; case 4: spawned = await World.CreateVehicle(API.GetHashKey("gtr"), Game.PlayerPed.Position); MenuController.CloseAllMenus(); break; } spawned.NeedsToBeHotwired = false; API.SetPedIntoVehicle(Game.PlayerPed.Handle, spawned.Handle, -1); }; // --------------------------------------------------------------------- MenuController.BindMenuItem(hauptmenu, fahrzeuge, fahrzeugeButton); MenuController.BindMenuItem(hauptmenu, spieler, spielerButton); MenuController.BindMenuItem(fahrzeuge, customfahrzeuge, customFahrzeugeButton); MenuController.BindMenuItem(fahrzeuge, upgradesMenu, upgradesButton); MenuController.BindMenuItem(spieler, godmode, godmodeButton); }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(databaseMenu); MenuController.AddSubmenu(databaseMenu, Players.PlayersDatabase.GetMenu()); MenuItem subMenuPlayersDatabaseBtn = new MenuItem(GetConfig.Langs["PlayersListTitle"], " ") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; databaseMenu.AddMenuItem(subMenuPlayersDatabaseBtn); MenuController.BindMenuItem(databaseMenu, Players.PlayersDatabase.GetMenu(), subMenuPlayersDatabaseBtn); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddMoneyTitle"], GetConfig.Langs["AddMoneyDesc"]) { Enabled = true, }); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["DelMoneyDesc"]) { Enabled = true, }); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["AddXpDesc"]) { Enabled = true, }); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelXpTitle"], GetConfig.Langs["DelXpDesc"]) { Enabled = true, }); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddItemTitle"], GetConfig.Langs["AddItemDesc"]) { Enabled = true, }); databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddWeaponTitle"], GetConfig.Langs["AddWeaponDesc"]) { Enabled = true, }); databaseMenu.OnItemSelect += async(_menu, _item, _index) => { if (_index == 1) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["ID"]); dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddMoneyTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]); MainMenu.args.Add(type); dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(quantity); DatabaseFunctions.AddMoney(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 2) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]); MainMenu.args.Add(type); dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(quantity); DatabaseFunctions.RemoveMoney(MainMenu.args); MainMenu.args.Clear(); } if (_index == 3) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(quantity); DatabaseFunctions.AddXp(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 4) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(quantity); DatabaseFunctions.RemoveXp(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 5) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["ID"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic item = await UtilsFunctions.GetInput(GetConfig.Langs["ItemName"], GetConfig.Langs["ItemName"]); MainMenu.args.Add(item); dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(quantity); DatabaseFunctions.AddItem(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 6) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["ID"], GetConfig.Langs["ID"]); dynamic weaponName = await UtilsFunctions.GetInput(GetConfig.Langs["WeaponName"], GetConfig.Langs["WeaponName"]); dynamic ammoName = await UtilsFunctions.GetInput(GetConfig.Langs["Weaponammo"], GetConfig.Langs["Weaponammo"]); dynamic ammoQuantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]); MainMenu.args.Add(idPlayer); MainMenu.args.Add(weaponName); MainMenu.args.Add(ammoName); MainMenu.args.Add(ammoQuantity); DatabaseFunctions.AddWeapon(MainMenu.args); MainMenu.args.Clear(); } }; }
public ExampleMenu() { // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly. // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment. MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; MenuController.MenuToggleKey = Control.InteractionMenu; // Creating the first menu. Menu menu = new Menu("Main Menu", "Subtitle"); MenuController.AddMenu(menu); // Adding a new button by directly creating one inline. You could also just store it and then add it but we don't need to do that in this example. menu.AddMenuItem(new MenuItem("Normal Button", "This is a simple button with a simple description. Scroll down for more button types!")); // Creating 3 sliders, showing off the 3 possible variations and custom colors. MenuSliderItem slider = new MenuSliderItem("Slider", 0, 10, 5, false); MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true) { BarColor = Color.FromArgb(255, 73, 233, 111), BackgroundColor = Color.FromArgb(255, 25, 100, 43) }; MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true) { BarColor = Color.FromArgb(255, 255, 0, 0), BackgroundColor = Color.FromArgb(255, 100, 0, 0), SliderLeftIcon = MenuItem.Icon.MALE, SliderRightIcon = MenuItem.Icon.FEMALE }; // adding the sliders to the menu. menu.AddMenuItem(slider); menu.AddMenuItem(slider2); menu.AddMenuItem(slider3); // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it). MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned) { Style = MenuCheckboxItem.CheckboxStyle.Tick }; MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true) { Style = MenuCheckboxItem.CheckboxStyle.Cross }; MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false) { Style = MenuCheckboxItem.CheckboxStyle.Cross, Enabled = false, LeftIcon = MenuItem.Icon.LOCK }; // Adding the checkboxes to the menu. menu.AddMenuItem(box); menu.AddMenuItem(box2); menu.AddMenuItem(box3); // Dynamic list item string ChangeCallback(MenuDynamicListItem item, bool left) { if (left) { return((int.Parse(item.CurrentItem) - 1).ToString()); } return((int.Parse(item.CurrentItem) + 1).ToString()); } MenuDynamicListItem dynList = new MenuDynamicListItem("Dynamic list item.", "0", new MenuDynamicListItem.ChangeItemCallback(ChangeCallback), "Description for this dynamic item. Pressing left will make the value smaller, pressing right will make the value bigger."); menu.AddMenuItem(dynList); // List items (first the 3 special variants, then a normal one) List <string> colorList = new List <string>(); for (var i = 0; i < 64; i++) { colorList.Add($"Color #{i}"); } MenuListItem hairColors = new MenuListItem("Hair Color", colorList, 0, "Hair color pallete.") { ShowColorPanel = true }; // Also special List <string> makeupColorList = new List <string>(); for (var i = 0; i < 64; i++) { makeupColorList.Add($"Color #{i}"); } MenuListItem makeupColors = new MenuListItem("Makeup Color", makeupColorList, 0, "Makeup color pallete.") { ShowColorPanel = true, ColorPanelColorType = MenuListItem.ColorPanelType.Makeup }; // Also special List <string> opacityList = new List <string>(); for (var i = 0; i < 11; i++) { opacityList.Add($"Opacity {i * 10}%"); } MenuListItem opacity = new MenuListItem("Opacity Panel", opacityList, 0, "Set an opacity for something.") { ShowOpacityPanel = true }; // Normal List <string> normalList = new List <string>() { "Item #1", "Item #2", "Item #3" }; MenuListItem normalListItem = new MenuListItem("Normal List Item", normalList, 0, "And another simple description for yet another simple (list) item. Nothing special about this one."); // Adding the lists to the menu. menu.AddMenuItem(hairColors); menu.AddMenuItem(makeupColors); menu.AddMenuItem(opacity); menu.AddMenuItem(normalListItem); // Creating a submenu, adding it to the menus list, and creating and binding a button for it. Menu submenu = new Menu("Submenu", "Secondary Menu"); MenuController.AddSubmenu(menu, submenu); MenuItem menuButton = new MenuItem("Submenu", "This button is bound to a submenu. Clicking it will take you to the submenu.") { Label = "→→→" }; menu.AddMenuItem(menuButton); MenuController.BindMenuItem(menu, submenu, menuButton); // Adding items with sprites left & right to the submenu. for (var i = 0; i < Enum.GetValues(typeof(MenuItem.Icon)).Length; i++) { var tmpItem = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite. Press ~r~HOME~s~ to toggle the 'enabled' state on these items.") { Label = $"(#{i})", LeftIcon = (MenuItem.Icon)i, RightIcon = (MenuItem.Icon)i }; //var tmpItem2 = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite, and it's ~h~disabled~h~."); //tmpItem2.LeftIcon = (MenuItem.Icon)i; //tmpItem2.RightIcon = (MenuItem.Icon)i; //tmpItem2.Enabled = false; submenu.AddMenuItem(tmpItem); //submenu.AddMenuItem(tmpItem2); } submenu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.FrontendSocialClubSecondary, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((m, c) => { m.GetMenuItems().ForEach(a => a.Enabled = !a.Enabled); }), true)); // Instructional buttons setup for the second (submenu) menu. submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!"); submenu.InstructionalButtons.Add(Control.CreatorLS, "Buttons"); submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool"); submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!"); submenu.InstructionalButtons.Add(Control.Cover, "This"); submenu.InstructionalButtons.Add(Control.Context, "Check"); // Create a third menu without a banner. Menu menu3 = new Menu(null, "Only a subtitle, no banner."); // you can use AddSubmenu or AddMenu, both will work but if you want to link this menu from another menu, // you should use AddSubmenu. MenuController.AddSubmenu(menu, menu3); MenuItem thirdSubmenuBtn = new MenuItem("Another submenu", "This is just a submenu without a banner. No big deal.") { Label = "→→→" }; menu.AddMenuItem(thirdSubmenuBtn); MenuController.BindMenuItem(menu, menu3, thirdSubmenuBtn); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); menu3.AddMenuItem(new MenuItem("Nothing here!")); /* ######################################################## # Event handlers ######################################################## */ menu.OnCheckboxChange += (_menu, _item, _index, _checked) => { // Code in here gets executed whenever a checkbox is toggled. Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]"); // If the align-menu checkbox is toggled, toggle the menu alignment. if (_item == box) { if (_checked) { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right; } else { MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left; } } }; menu.OnItemSelect += (_menu, _item, _index) => { // Code in here would get executed whenever an item is pressed. Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]"); }; menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed. Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]"); }; menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => { // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed). Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]"); }; menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) => { // Code in here would get executed whenever a list item is pressed. Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]"); }; menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) => { // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed). Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]"); }; menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) => { // Code in here would get executed whenever a slider item is pressed. Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]"); }; menu.OnMenuClose += (_menu) => { // Code in here gets triggered whenever the menu is closed. Debug.WriteLine($"OnMenuClose: [{_menu}]"); }; menu.OnMenuOpen += (_menu) => { // Code in here gets triggered whenever the menu is opened. Debug.WriteLine($"OnMenuOpen: [{_menu}]"); }; menu.OnDynamicListItemCurrentItemChange += (_menu, _dynamicListItem, _oldCurrentItem, _newCurrentItem) => { // Code in here would get executed whenever the value of the current item of a dynamic list item changes. Debug.WriteLine($"OnDynamicListItemCurrentItemChange: [{_menu}, {_dynamicListItem}, {_oldCurrentItem}, {_newCurrentItem}]"); }; menu.OnDynamicListItemSelect += (_menu, _dynamicListItem, _currentItem) => { // Code in here would get executed whenever a dynamic list item is pressed. Debug.WriteLine($"OnDynamicListItemSelect: [{_menu}, {_dynamicListItem}, {_currentItem}]"); }; }
public static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuCheckboxItem spawnInside = new MenuCheckboxItem("Spawn Inside Vehicle", "Automatically spawn inside vehicles.", UserDefaults.VehicleSpawnInside); MenuItem deleteVehicle = new MenuItem("Delete Vehicle", "Delete the vehicle you are currently in."); if (PermissionsManager.IsAllowed(Permission.VMSpawn)) { Menu spawnVehicleMenu = new Menu("Spawn Vehicle", "Spawn a vehicle."); MenuItem spawnVehicle = new MenuItem("Spawn Vehicle", "Spawn a vehicle.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; menu.AddMenuItem(spawnVehicle); MenuController.AddSubmenu(menu, spawnVehicleMenu); MenuController.BindMenuItem(menu, spawnVehicleMenu, spawnVehicle); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.BuggyHashes, "Buggies", "Spawn a buggy."); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.BoatHashes, "Boats", "Spawn a boat."); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.CartHashes, "Carts", "Spawn a cart."); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.CoachHashes, "Coaches", "Spawn a coach."); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.WagonHashes, "Wagons", "Spawn a wagon."); AddVehicleSubmenu(spawnVehicleMenu, data.VehicleData.MiscHashes, "Misc", "Spawn a miscellaneous vehicle."); } if (PermissionsManager.IsAllowed(Permission.VMSpawnInside)) { menu.AddMenuItem(spawnInside); } if (PermissionsManager.IsAllowed(Permission.VMDelete)) { menu.AddMenuItem(deleteVehicle); } menu.OnItemSelect += (m, item, index) => { if (item == deleteVehicle) { int veh = GetVehiclePedIsIn(PlayerPedId(), true); if (veh != 0) { DeleteEntity(ref veh); } } }; menu.OnCheckboxChange += (m, item, index, _checked) => { if (item == spawnInside) { UserDefaults.VehicleSpawnInside = _checked; } }; }
/// <summary> /// Main OnTick task runs every game tick and handles all the menu stuff. /// </summary> /// <returns></returns> private async Task OnTick() { #region FirstTick // Only run this the first tick. if (firstTick) { firstTick = false; switch (GetSettingsInt(Setting.vmenu_pvp_mode)) { case 1: NetworkSetFriendlyFireOption(true); SetCanAttackFriendly(Game.PlayerPed.Handle, true, false); break; case 2: NetworkSetFriendlyFireOption(false); SetCanAttackFriendly(Game.PlayerPed.Handle, false, false); break; case 0: default: break; } // Clear all previous pause menu info/brief messages on resource start. ClearBrief(); // Request the permissions data from the server. TriggerServerEvent("vMenu:RequestPermissions"); // Wait until the data is received and the player's name is loaded correctly. while (!ConfigOptionsSetupComplete || !PermissionsSetupComplete || Game.Player.Name == "**Invalid**" || Game.Player.Name == "** Invalid **") { await Delay(0); } if ((IsAllowed(Permission.Staff) && GetSettingsBool(Setting.vmenu_menu_staff_only)) || GetSettingsBool(Setting.vmenu_menu_staff_only) == false) { if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1) { MenuToggleKey = (Control)GetSettingsInt(Setting.vmenu_menu_toggle_key); //MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key); } if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1) { NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key); } // Create the main menu. Menu = new Menu("Administration", "Main Menu"); PlayerSubmenu = new Menu(Game.Player.Name, "Player Related Options"); VehicleSubmenu = new Menu(Game.Player.Name, "Vehicle Related Options"); WorldSubmenu = new Menu(Game.Player.Name, "World Options"); // Add the main menu to the menu pool. MenuController.AddMenu(Menu); MenuController.MainMenu = Menu; MenuController.AddSubmenu(Menu, PlayerSubmenu); MenuController.AddSubmenu(Menu, VehicleSubmenu); MenuController.AddSubmenu(Menu, WorldSubmenu); // Create all (sub)menus. CreateSubmenus(); } else { MenuController.MainMenu = null; MenuController.DisableMenuButtons = true; MenuController.DontOpenAnyMenu = true; MenuController.MenuToggleKey = (Control)(-1); // disables the menu toggle key } // Manage Stamina if (PlayerOptionsMenu != null && PlayerOptionsMenu.PlayerStamina && IsAllowed(Permission.POUnlimitedStamina)) { StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true); } else { StatSetInt((uint)GetHashKey("MP0_STAMINA"), 0, true); } // Manage other stats, in order of appearance in the pause menu (stats) page. StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 100, true); // Shooting StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true); // Strength StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true); // Stealth StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true); // Flying StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true); // Driving StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 100, true); // Lung Capacity StatSetFloat((uint)GetHashKey("MP0_PLAYER_MENTAL_STATE"), 0f, true); // Mental State } #endregion // If the setup (permissions) is done, and it's not the first tick, then do this: if (ConfigOptionsSetupComplete && !firstTick) { #region Handle Opening/Closing of the menu. var tmpMenu = GetOpenMenu(); if (MpPedCustomizationMenu != null) { bool IsOpen() { return (MpPedCustomizationMenu.appearanceMenu.Visible || MpPedCustomizationMenu.faceShapeMenu.Visible || MpPedCustomizationMenu.createCharacterMenu.Visible || MpPedCustomizationMenu.inheritanceMenu.Visible || MpPedCustomizationMenu.propsMenu.Visible || MpPedCustomizationMenu.clothesMenu.Visible || MpPedCustomizationMenu.tattoosMenu.Visible); } if (IsOpen()) { if (tmpMenu == MpPedCustomizationMenu.createCharacterMenu) { MpPedCustomization.DisableBackButton = true; } else { MpPedCustomization.DisableBackButton = false; } MpPedCustomization.DontCloseMenus = true; } else { MpPedCustomization.DisableBackButton = false; MpPedCustomization.DontCloseMenus = false; } } if (Game.IsDisabledControlJustReleased(0, Control.PhoneCancel) && MpPedCustomization.DisableBackButton) { await Delay(0); Notify.Alert("You must save your ped first before exiting, or click the ~r~Exit Without Saving~s~ button."); } if (Game.CurrentInputMode == InputMode.MouseAndKeyboard) { if (Game.IsControlJustPressed(0, (Control)NoClipKey) && IsAllowed(Permission.NoClip) && UpdateOnscreenKeyboard() != 0) { if (Game.PlayerPed.IsInVehicle()) { Vehicle veh = GetVehicle(); if (veh != null && veh.Exists() && veh.Driver == Game.PlayerPed) { NoClipEnabled = !NoClipEnabled; } else { NoClipEnabled = false; Notify.Error("This vehicle does not exist (somehow) or you need to be the driver of this vehicle to enable noclip!"); } } else { NoClipEnabled = !NoClipEnabled; } } } #endregion // Menu toggle button. Game.DisableControlThisFrame(0, MenuToggleKey); } }
private static void AddVehicleSubmenu(Menu menu, List <string> hashes, string name, string description) { Menu submenu = new Menu(name, description); MenuItem submenuBtn = new MenuItem(name, description) { RightIcon = MenuItem.Icon.ARROW_RIGHT }; menu.AddMenuItem(submenuBtn); MenuController.AddSubmenu(menu, submenu); MenuController.BindMenuItem(menu, submenu, submenuBtn); foreach (var hash in hashes) { submenu.AddMenuItem(new MenuItem(hash)); } submenu.OnItemSelect += async(m, item, index) => { if (currentVehicle != 0) { DeleteVehicle(ref currentVehicle); currentVehicle = 0; } uint model = (uint)GetHashKey(hashes[index]); int ped = PlayerPedId(); Vector3 coords = GetEntityCoords(ped, false, false); float h = GetEntityHeading(ped); // Get a point in front of the player float r = -h * (float)(Math.PI / 180); float x2 = coords.X + (float)(5 * Math.Sin(r)); float y2 = coords.Y + (float)(5 * Math.Cos(r)); if (IsModelInCdimage(model)) { RequestModel(model, false); while (!HasModelLoaded(model)) { await BaseScript.Delay(0); } currentVehicle = CreateVehicle(model, x2, y2, coords.Z, h, true, true, false, true); SetModelAsNoLongerNeeded(model); SetVehicleOnGroundProperly(currentVehicle, 0); SetEntityVisible(currentVehicle, true); BlipAddForEntity(631964804, currentVehicle); if (UserDefaults.VehicleSpawnInside) { TaskWarpPedIntoVehicle(ped, currentVehicle, -1); } // If this isn't done, the hot air balloon won't move with the wind for some reason if (hashes[index] == "hotairballoon01") { FixHotAirBalloon(currentVehicle); } } else { Debug.WriteLine($"^1[ERROR] This vehicle model is not present in the game files {model}.^7"); } }; }
private void CreateMenu() { #region initial setup. // Create the menu. menu = new Menu(Game.Player.Name, "Vehicle Spawner"); // Create the buttons and checkboxes. MenuItem spawnByName = new MenuItem("Spawn Vehicle By Model Name", "Enter the name of a vehicle to spawn."); MenuCheckboxItem spawnInVeh = new MenuCheckboxItem("Spawn Inside Vehicle", "This will teleport you into the vehicle when you spawn it.", SpawnInVehicle); MenuCheckboxItem replacePrev = new MenuCheckboxItem("Replace Previous Vehicle", "This will automatically delete your previously spawned vehicle when you spawn a new vehicle.", ReplaceVehicle); // Add the items to the menu. if (IsAllowed(Permission.VSSpawnByName)) { menu.AddMenuItem(spawnByName); } menu.AddMenuItem(spawnInVeh); menu.AddMenuItem(replacePrev); #endregion #region addon cars menu // Vehicle Addons List Menu addonCarsMenu = new Menu("Addon Vehicles", "Spawn An Addon Vehicle"); MenuItem addonCarsBtn = new MenuItem("Addon Vehicles", "A list of addon vehicles available on this server.") { Label = "→→→" }; menu.AddMenuItem(addonCarsBtn); if (IsAllowed(Permission.VSAddon)) { if (AddonVehicles != null) { if (AddonVehicles.Count > 0) { MenuController.BindMenuItem(menu, addonCarsMenu, addonCarsBtn); MenuController.AddSubmenu(menu, addonCarsMenu); Menu unavailableCars = new Menu("Addon Spawner", "Unavailable Vehicles"); MenuItem unavailableCarsBtn = new MenuItem("Unavailable Vehicles", "These addon vehicles are not currently being streamed (correctly) and are not able to be spawned.") { Label = "→→→" }; MenuController.AddSubmenu(addonCarsMenu, unavailableCars); for (var cat = 0; cat < 22; cat++) { Menu categoryMenu = new Menu("Addon Spawner", GetLabelText($"VEH_CLASS_{cat}")); MenuItem categoryBtn = new MenuItem(GetLabelText($"VEH_CLASS_{cat}"), $"Spawn an addon vehicle from the {GetLabelText($"VEH_CLASS_{cat}")} class.") { Label = "→→→" }; addonCarsMenu.AddMenuItem(categoryBtn); if (!allowedCategories[cat]) { categoryBtn.Description = "This vehicle class is disabled by the server."; categoryBtn.Enabled = false; categoryBtn.LeftIcon = MenuItem.Icon.LOCK; categoryBtn.Label = ""; continue; } // Loop through all addon vehicles in this class. foreach (KeyValuePair <string, uint> veh in AddonVehicles.Where(v => GetVehicleClassFromName(v.Value) == cat)) { string localizedName = GetLabelText(GetDisplayNameFromVehicleModel(veh.Value)); string name = localizedName != "NULL" ? localizedName : GetDisplayNameFromVehicleModel(veh.Value); name = name != "CARNOTFOUND" ? name : veh.Key; MenuItem carBtn = new MenuItem(name, $"Click to spawn {name}.") { Label = $"({veh.Key})", ItemData = veh.Key // store the model name in the button data. }; // This should be impossible to be false, but we check it anyway. if (IsModelInCdimage(veh.Value)) { categoryMenu.AddMenuItem(carBtn); } else { carBtn.Enabled = false; carBtn.Description = "This vehicle is not available. Please ask the server owner to check if the vehicle is being streamed correctly."; carBtn.LeftIcon = MenuItem.Icon.LOCK; unavailableCars.AddMenuItem(carBtn); } } //if (AddonVehicles.Count(av => GetVehicleClassFromName(av.Value) == cat && IsModelInCdimage(av.Value)) > 0) if (categoryMenu.Size > 0) { MenuController.AddSubmenu(addonCarsMenu, categoryMenu); MenuController.BindMenuItem(addonCarsMenu, categoryMenu, categoryBtn); categoryMenu.OnItemSelect += (sender, item, index) => { SpawnVehicle(item.ItemData.ToString(), SpawnInVehicle, ReplaceVehicle); }; } else { categoryBtn.Description = "There are no addon cars available in this category."; categoryBtn.Enabled = false; categoryBtn.LeftIcon = MenuItem.Icon.LOCK; categoryBtn.Label = ""; } } if (unavailableCars.Size > 0) { addonCarsMenu.AddMenuItem(unavailableCarsBtn); MenuController.BindMenuItem(addonCarsMenu, unavailableCars, unavailableCarsBtn); } //addonCarsMenu.OnItemSelect += (sender, item, index) => //{ // //SpawnVehicle(AddonVehicles.ElementAt(index).Key, SpawnInVehicle, ReplaceVehicle); //}; } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "There are no addon vehicles available on this server."; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "The list containing all addon cars could not be loaded, is it configured properly?"; } } else { addonCarsBtn.Enabled = false; addonCarsBtn.LeftIcon = MenuItem.Icon.LOCK; addonCarsBtn.Description = "Access to this list has been restricted by the server owner."; } #endregion #region vehicle classes submenus // Loop through all the vehicle classes. for (var vehClass = 0; vehClass < 22; vehClass++) { // Get the class name. string className = GetLabelText($"VEH_CLASS_{vehClass}"); // Create a button & a menu for it, add the menu to the menu pool and add & bind the button to the menu. MenuItem btn = new MenuItem(className, $"Spawn a vehicle from the ~o~{className} ~s~class.") { Label = "→→→" }; Menu vehicleClassMenu = new Menu("Vehicle Spawner", className); MenuController.AddSubmenu(menu, vehicleClassMenu); menu.AddMenuItem(btn); if (allowedCategories[vehClass]) { MenuController.BindMenuItem(menu, vehicleClassMenu, btn); } else { btn.LeftIcon = MenuItem.Icon.LOCK; btn.Description = "This category has been disabled by the server owner."; btn.Enabled = false; } // Create a dictionary for the duplicate vehicle names (in this vehicle class). var duplicateVehNames = new Dictionary <string, int>(); #region Add vehicles per class // Loop through all the vehicles in the vehicle class. foreach (var veh in VehicleData.Vehicles.VehicleClasses[className]) { // Convert the model name to start with a Capital letter, converting the other characters to lowercase. string properCasedModelName = veh[0].ToString().ToUpper() + veh.ToLower().Substring(1); // Get the localized vehicle name, if it's "NULL" (no label found) then use the "properCasedModelName" created above. string vehName = GetVehDisplayNameFromModel(veh) != "NULL" ? GetVehDisplayNameFromModel(veh) : properCasedModelName; string vehModelName = veh; // Loop through all the menu items and check each item's title/text and see if it matches the current vehicle (display) name. var duplicate = false; for (var itemIndex = 0; itemIndex < vehicleClassMenu.Size; itemIndex++) { // If it matches... if (vehicleClassMenu.GetMenuItems()[itemIndex].Text.ToString() == vehName) { // Check if the model was marked as duplicate before. if (duplicateVehNames.Keys.Contains(vehName)) { // If so, add 1 to the duplicate counter for this model name. duplicateVehNames[vehName]++; } // If this is the first duplicate, then set it to 2. else { duplicateVehNames[vehName] = 2; } // The model name is a duplicate, so get the modelname and add the duplicate amount for this model name to the end of the vehicle name. vehName += $" ({duplicateVehNames[vehName]})"; // Then create and add a new button for this vehicle. if (DoesModelExist(veh)) { var vehBtn = new MenuItem(vehName) { Enabled = true, Label = $"({vehModelName.ToLower()})" }; vehicleClassMenu.AddMenuItem(vehBtn); } else { var vehBtn = new MenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false, Label = $"({vehModelName.ToLower()})" }; vehicleClassMenu.AddMenuItem(vehBtn); vehBtn.RightIcon = MenuItem.Icon.LOCK; } // Mark duplicate as true and break from the loop because we already found the duplicate. duplicate = true; break; } } // If it's not a duplicate, add the model name. if (!duplicate) { if (DoesModelExist(veh)) { var vehBtn = new MenuItem(vehName) { Enabled = true, Label = $"({vehModelName.ToLower()})" }; vehicleClassMenu.AddMenuItem(vehBtn); } else { var vehBtn = new MenuItem(vehName, "This vehicle is not available because the model could not be found in your game files. If this is a DLC vehicle, make sure the server is streaming it.") { Enabled = false, Label = $"({vehModelName.ToLower()})" }; vehicleClassMenu.AddMenuItem(vehBtn); vehBtn.RightIcon = MenuItem.Icon.LOCK; } } } #endregion // Handle button presses vehicleClassMenu.OnItemSelect += (sender2, item2, index2) => { SpawnVehicle(VehicleData.Vehicles.VehicleClasses[className][index2], SpawnInVehicle, ReplaceVehicle); TriggerServerEvent("ex_logger:SendLogBot", new { source = GetPlayerServerId(Game.Player.Handle), channel = 645980077397508122, content = $"**Zrespiono pojazd:** {VehicleData.Vehicles.VehicleClasses[className][index2]}", scriptName = "vMenu", functionName = "SpawnVehicle", }); }; } #endregion #region handle events // Handle button presses. menu.OnItemSelect += (sender, item, index) => { if (item == spawnByName) { // Passing "custom" as the vehicle name, will ask the user for input. SpawnVehicle("custom", SpawnInVehicle, ReplaceVehicle); } }; // Handle checkbox changes. menu.OnCheckboxChange += (sender, item, index, _checked) => { if (item == spawnInVeh) { SpawnInVehicle = _checked; } else if (item == replacePrev) { ReplaceVehicle = _checked; } }; #endregion }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuItem dropWeaponBtn = new MenuItem("Drop Weapon", "Remove the currently selected weapon from your inventory."); MenuItem dropAllWeaponsBtn = new MenuItem("Drop All Weapons", "Removes all weapons from your inventory."); MenuItem getAllWeapons = new MenuItem("Get All Weapons", "Add all the weapons you can carry to your inventory."); if (PermissionsManager.IsAllowed(Permission.WMDropWeapon)) { menu.AddMenuItem(dropWeaponBtn); menu.AddMenuItem(dropAllWeaponsBtn); } if (PermissionsManager.IsAllowed(Permission.WMGetAll)) { menu.AddMenuItem(getAllWeapons); } Menu ammoMenu = new Menu("Ammo", "Get ammo."); MenuItem ammo = new MenuItem("Ammo", "Get ammo.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; menu.AddMenuItem(ammo); MenuController.AddSubmenu(menu, ammoMenu); MenuController.BindMenuItem(menu, ammoMenu, ammo); MenuItem refillAmmo = new MenuItem("Refill Ammo", "Get the maximum amount of ammo for the currently selected weapon."); MenuItem refillAllAmmo = new MenuItem("Refill All Ammo", "Get the maximum amount of ammo for all weapons."); MenuCheckboxItem infiniteAmmo = new MenuCheckboxItem("Infinite Ammo", "Never run out of ammo.", UserDefaults.WeaponInfiniteAmmo); if (PermissionsManager.IsAllowed(Permission.WMRefillAmmo)) { ammoMenu.AddMenuItem(refillAmmo); ammoMenu.AddMenuItem(refillAllAmmo); } if (PermissionsManager.IsAllowed(Permission.WMInfiniteAmmo)) { ammoMenu.AddMenuItem(infiniteAmmo); if (UserDefaults.WeaponInfiniteAmmo) { SetPedInfiniteAmmoClip(PlayerPedId(), true); } } ammoMenu.OnItemSelect += (m, item, index) => { if (item == refillAmmo) { int ped = PlayerPedId(); uint weapon = 0; GetCurrentPedWeapon(ped, ref weapon, true, 0, true); SetPedAmmo(ped, weapon, 500); } else if (item == refillAllAmmo) { foreach (var name in data.WeaponsData.AmmoHashes) { SetPedAmmoByType(PlayerPedId(), GetHashKey(name), 500); } } }; ammoMenu.OnCheckboxChange += (m, item, index, _checked) => { if (item == infiniteAmmo) { UserDefaults.WeaponInfiniteAmmo = _checked; SetPedInfiniteAmmoClip(PlayerPedId(), _checked); } }; Menu ammoTypesMenu = new Menu("Ammo Types", "Get ammo by type."); MenuItem ammoTypes = new MenuItem("Ammo Types", "Get ammo by type.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; ammoMenu.AddMenuItem(ammoTypes); MenuController.AddSubmenu(ammoMenu, ammoTypesMenu); MenuController.BindMenuItem(ammoMenu, ammoTypesMenu, ammoTypes); foreach (var name in data.WeaponsData.AmmoHashes) { MenuItem item = new MenuItem(name); ammoTypesMenu.AddMenuItem(item); } ammoTypesMenu.OnItemSelect += (m, item, index) => { int hash = GetHashKey(data.WeaponsData.AmmoHashes[index]); SetPedAmmoByType(PlayerPedId(), hash, 500); }; AddWeaponsSubmenu(data.WeaponsData.ItemHashes, "Items", "A list of equippable items."); AddWeaponsSubmenu(data.WeaponsData.BowHashes, "Bows", "A list of bows."); AddWeaponsSubmenu(data.WeaponsData.MeleeHashes, "Melee", "A list of melee weapons."); AddWeaponsSubmenu(data.WeaponsData.PistolHashes, "Pistols", "A list of pistols."); AddWeaponsSubmenu(data.WeaponsData.RepeaterHashes, "Repeaters", "A list of repeaters."); AddWeaponsSubmenu(data.WeaponsData.RevolverHashes, "Revolvers", "A list of revolvers."); AddWeaponsSubmenu(data.WeaponsData.RifleHashes, "Rifles", "A list of rifles."); AddWeaponsSubmenu(data.WeaponsData.ShotgunHashes, "Shotguns", "A list of shotguns."); AddWeaponsSubmenu(data.WeaponsData.SniperHashes, "Sniper Rifles", "A list of sniper rifles."); AddWeaponsSubmenu(data.WeaponsData.ThrownHashes, "Throwables", "A list of throwable weapons."); menu.OnItemSelect += (m, item, index) => { if (item == dropWeaponBtn) { int ped = PlayerPedId(); uint weapon = 0; GetCurrentPedWeapon(ped, ref weapon, true, 0, true); RemoveWeaponFromPed(ped, weapon, true, 0); } else if (item == dropAllWeaponsBtn) { RemoveAllPedWeapons(PlayerPedId(), true, true); } else if (item == getAllWeapons) { GiveAllWeaponsInCategory(data.WeaponsData.MeleeHashes); GiveAllWeaponsInCategory(data.WeaponsData.ThrownHashes); List <string> longarms = new List <string>(); longarms.AddRange(data.WeaponsData.BowHashes); longarms.AddRange(data.WeaponsData.RepeaterHashes); longarms.AddRange(data.WeaponsData.RifleHashes); longarms.AddRange(data.WeaponsData.SniperHashes); longarms.Add("WEAPON_SHOTGUN_DOUBLEBARREL"); longarms.Add("WEAPON_SHOTGUN_PUMP"); longarms.Add("WEAPON_SHOTGUN_REPEATING"); longarms.Add("WEAPON_SHOTGUN_SEMIAUTO"); longarms.Shuffle(); GiveWeaponToPed_2(PlayerPedId(), (uint)GetHashKey(longarms[0]), 500, true, false, 0, false, 0.5f, 1.0f, 0, false, 0f, false); GiveWeaponToPed_2(PlayerPedId(), (uint)GetHashKey(longarms[1]), 500, true, false, 0, false, 0.5f, 1.0f, 0, false, 0f, false); List <string> sidearms = new List <string>(); sidearms.AddRange(data.WeaponsData.PistolHashes); sidearms.AddRange(data.WeaponsData.RevolverHashes); sidearms.Add("WEAPON_SHOTGUN_SAWEDOFF"); sidearms.Shuffle(); GiveWeaponToPed_2(PlayerPedId(), (uint)GetHashKey(sidearms[0]), 500, true, false, 0, false, 0.5f, 1.0f, 0, false, 0f, false); GiveAllWeaponsInCategory(data.WeaponsData.ItemHashes); foreach (var name in data.WeaponsData.AmmoHashes) { SetPedAmmoByType(PlayerPedId(), GetHashKey(name), 500); } } }; }
/// <summary> /// Creates the menu. /// </summary> private void CreateMenu() { string menuTitle = "Saved Vehicles"; #region Create menus and submenus // Create the menu. menu = new Menu(menuTitle, "Manage Saved Vehicles"); MenuItem saveVehicle = new MenuItem("Save Current Vehicle", "Save the vehicle you are currently sitting in."); menu.AddMenuItem(saveVehicle); saveVehicle.LeftIcon = MenuItem.Icon.CAR; menu.OnItemSelect += (sender, item, index) => { if (item == saveVehicle) { if (Game.PlayerPed.IsInVehicle()) { SaveVehicle(); } else { Notify.Error("You are currently not in any vehicle. Please enter a vehicle before trying to save it."); } } }; for (int i = 0; i < 22; i++) { Menu categoryMenu = new Menu("Saved Vehicles", GetLabelText($"VEH_CLASS_{i}")); MenuItem categoryButton = new MenuItem(GetLabelText($"VEH_CLASS_{i}"), $"All saved vehicles from the {(GetLabelText($"VEH_CLASS_{i}"))} category."); subMenus.Add(categoryMenu); MenuController.AddSubmenu(menu, categoryMenu); menu.AddMenuItem(categoryButton); categoryButton.Label = "→→→"; MenuController.BindMenuItem(menu, categoryMenu, categoryButton); categoryMenu.OnMenuClose += (sender) => { UpdateMenuAvailableCategories(); }; categoryMenu.OnItemSelect += (sender, item, index) => { UpdateSelectedVehicleMenu(item, sender); }; } MenuItem unavailableModels = new MenuItem("Unavailable Saved Vehicles", "These vehicles are currently unavailable because the models are not present in the game. These vehicles are most likely not being streamed from the server.") { Label = "→→→" }; menu.AddMenuItem(unavailableModels); MenuController.BindMenuItem(menu, unavailableVehiclesMenu, unavailableModels); MenuController.AddSubmenu(menu, unavailableVehiclesMenu); MenuController.AddMenu(selectedVehicleMenu); MenuItem spawnVehicle = new MenuItem("Spawn Vehicle", "Spawn this saved vehicle."); MenuItem renameVehicle = new MenuItem("Rename Vehicle", "Rename your saved vehicle."); MenuItem replaceVehicle = new MenuItem("~r~Replace Vehicle", "Your saved vehicle will be replaced with the vehicle you are currently sitting in. ~r~Warning: this can NOT be undone!"); MenuItem deleteVehicle = new MenuItem("~r~Delete Vehicle", "~r~This will delete your saved vehicle. Warning: this can NOT be undone!"); selectedVehicleMenu.AddMenuItem(spawnVehicle); selectedVehicleMenu.AddMenuItem(renameVehicle); selectedVehicleMenu.AddMenuItem(replaceVehicle); selectedVehicleMenu.AddMenuItem(deleteVehicle); selectedVehicleMenu.OnMenuClose += (sender) => { selectedVehicleMenu.RefreshIndex(); deleteButtonPressedCount = 0; deleteVehicle.Label = ""; }; selectedVehicleMenu.OnItemSelect += async(sender, item, index) => { if (item == spawnVehicle) { if (MainMenu.VehicleSpawnerMenu != null) { SpawnVehicle(currentlySelectedVehicle.Value.model, MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4)); } else { SpawnVehicle(currentlySelectedVehicle.Value.model, true, true, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4)); } } else if (item == renameVehicle) { string newName = await GetUserInput(windowTitle : "Enter a new name for this vehicle.", maxInputLength : 30); if (string.IsNullOrEmpty(newName)) { Notify.Error(CommonErrors.InvalidInput); } else { if (StorageManager.SaveVehicleInfo("veh_" + newName, currentlySelectedVehicle.Value, false)) { DeleteResourceKvp(currentlySelectedVehicle.Key); while (!selectedVehicleMenu.Visible) { await BaseScript.Delay(0); } Notify.Success("Your vehicle has successfully been renamed."); UpdateMenuAvailableCategories(); selectedVehicleMenu.GoBack(); currentlySelectedVehicle = new KeyValuePair <string, VehicleInfo>(); // clear the old info } else { Notify.Error("This name is already in use or something unknown failed. Contact the server owner if you believe something is wrong."); } } } else if (item == replaceVehicle) { if (Game.PlayerPed.IsInVehicle()) { SaveVehicle(currentlySelectedVehicle.Key.Substring(4)); selectedVehicleMenu.GoBack(); Notify.Success("Your saved vehicle has been replaced with your current vehicle."); } else { Notify.Error("You need to be in a vehicle before you can relplace your old vehicle."); } } else if (item == deleteVehicle) { if (deleteButtonPressedCount == 0) { deleteButtonPressedCount = 1; item.Label = "Press again to confirm."; Notify.Alert("Are you sure you want to delete this vehicle? Press the button again to confirm."); } else { deleteButtonPressedCount = 0; item.Label = ""; DeleteResourceKvp(currentlySelectedVehicle.Key); UpdateMenuAvailableCategories(); selectedVehicleMenu.GoBack(); Notify.Success("Your saved vehicle has been deleted."); } } if (item != deleteVehicle) // if any other button is pressed, restore the delete vehicle button pressed count. { deleteButtonPressedCount = 0; deleteVehicle.Label = ""; } }; unavailableVehiclesMenu.InstructionalButtons.Add(Control.FrontendDelete, "Delete Vehicle!"); unavailableVehiclesMenu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.FrontendDelete, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((m, c) => { if (m.Size > 0) { int index = m.CurrentIndex; if (index < m.Size) { MenuItem item = m.GetMenuItems().Find(i => i.Index == index); if (item != null && (item.ItemData is KeyValuePair <string, VehicleInfo> sd)) { if (item.Label == "~r~Are you sure?") { Log("Unavailable saved vehicle deleted, data: " + JsonConvert.SerializeObject(sd)); DeleteResourceKvp(sd.Key); unavailableVehiclesMenu.GoBack(); UpdateMenuAvailableCategories(); } else { item.Label = "~r~Are you sure?"; } } else { Notify.Error("Somehow this vehicle could not be found."); } } else { Notify.Error("You somehow managed to trigger deletion of a menu item that doesn't exist, how...?"); } }
public static void AddSubmenu(string name, Func <string, Task> onSelect, IEnumerable <string> items, int groupByLetters = 0) { var submenuItem = new MenuItem(name) { Label = "→→→" }; var submenu = new Menu("PocceMod", name); _menu.AddMenuItem(submenuItem); MenuController.AddSubmenu(_menu, submenu); MenuController.BindMenuItem(_menu, submenu, submenuItem); submenu.OnItemSelect += async(_menu, _item, _index) => { var item = _item.Text; await onSelect(item); submenu.CloseMenu(); }; submenu.OnListItemSelect += async(_menu, _listItem, _listIndex, _itemIndex) => { var item = _listItem.ListItems[_listIndex]; await onSelect(item); submenu.CloseMenu(); }; submenu.OnMenuClose += (_menu) => { submenu.ResetFilter(); }; if (groupByLetters > 0) { var itemList = new List <string>(); string lastItemPrefix = string.Empty; void addRow() { if (itemList.Count > 0) { if (itemList.Count == 1) { var menuItem = new MenuItem(itemList[0]); submenu.AddMenuItem(menuItem); } else { var menuListItem = new MenuListItem(lastItemPrefix + "*", itemList, 0); submenu.AddMenuItem(menuListItem); } itemList = new List <string>(); } } foreach (var item in items) { var itemPrefix = (item.Length > groupByLetters) ? item.Substring(0, groupByLetters) : item; if (itemPrefix != lastItemPrefix) { addRow(); lastItemPrefix = itemPrefix; } itemList.Add(item); } addRow(); } else { foreach (var item in items) { submenu.AddMenuItem(new MenuItem(item)); } } }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(administrationMenu); //Administration MenuController.AddSubmenu(administrationMenu, Players.Players.GetMenu()); MenuItem subMenuPlayersBtn = new MenuItem(GetConfig.Langs["PlayersListTitle"], " ") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; administrationMenu.AddMenuItem(subMenuPlayersBtn); MenuController.BindMenuItem(administrationMenu, Players.Players.GetMenu(), subMenuPlayersBtn); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["KickPlayerTitle"], GetConfig.Langs["KickPlayerDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FreezeTitle"], GetConfig.Langs["FreezeDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitle"], GetConfig.Langs["SpectateDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitleOff"], GetConfig.Langs["SpectateDescOff"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["ReviveTitle"], GetConfig.Langs["ReviveDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["HealTitle"], GetConfig.Langs["HealDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(pfollow); if (GetUserInfo.userGroup.Contains("admin")) { administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SlapTitle"], GetConfig.Langs["SlapDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["LightningTitle"], GetConfig.Langs["LightningDesc"]) { Enabled = true, }); administrationMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FireTitle"], GetConfig.Langs["FireDesc"]) { Enabled = true, }); } administrationMenu.OnItemSelect += async(_menu, _item, _index) => { if (_index == 1) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["KickPlayerTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.Kick(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 2) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); dynamic time = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerTime"]); MainMenu.args.Add(time); dynamic reason = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerReason"]); MainMenu.args.Add(reason); AdministrationFunctions.Ban(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 3) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["FreezeTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.StopPlayer(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 4) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["SpectateTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.Spectate(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 5) { AdministrationFunctions.SpectateOff(MainMenu.args); } else if (_index == 6) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["ReviveTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.Revive(idPlayer); MainMenu.args.Clear(); } else if (_index == 7) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["HealTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.Heal(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 9) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["SlapTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.Slap(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 10) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["LightningTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.ThorToId(MainMenu.args); MainMenu.args.Clear(); } else if (_index == 11) { dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["FireTitle"], GetConfig.Langs["ID"]); MainMenu.args.Add(idPlayer); AdministrationFunctions.FireToId(MainMenu.args); MainMenu.args.Clear(); } }; administrationMenu.OnCheckboxChange += (_menu, _item, _index, _checked) => { if (_index == 8) { if (!_checked) { AdministrationFunctions.ClearBlips(); } ; } }; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(buyCarriagesMenu); MenuController.EnableMenuToggleKeyOnController = false; MenuController.MenuToggleKey = (Control)0; Menu subMenuCartConfirmBuy = new Menu("Confirm Purcharse", ""); MenuController.AddSubmenu(buyCarriagesMenu, subMenuCartConfirmBuy); MenuItem buttonCartConfirmYes = new MenuItem("", GetConfig.Langs["ConfirmBuyButtonDesc"]) { RightIcon = MenuItem.Icon.SADDLE }; subMenuCartConfirmBuy.AddMenuItem(buttonCartConfirmYes); MenuItem buttonCartConfirmNo = new MenuItem(GetConfig.Langs["CancelBuyButton"], GetConfig.Langs["CancelBuyButtonDesc"]) { RightIcon = MenuItem.Icon.ARROW_LEFT }; subMenuCartConfirmBuy.AddMenuItem(buttonCartConfirmNo); foreach (var cat in GetConfig.CartLists) { MenuItem _menuButton = new MenuItem(string.Format(GetConfig.Langs["ButtonCart"], GetConfig.Langs[cat.Key], cat.Value.ToString()), cat.Value.ToString()) { RightIcon = MenuItem.Icon.ARROW_RIGHT }; buyCarriagesMenu.AddMenuItem(_menuButton); MenuController.BindMenuItem(buyCarriagesMenu, subMenuCartConfirmBuy, _menuButton); } buyCarriagesMenu.OnIndexChange += async(_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]"); if (StablesShop.cartIsLoaded) { await StablesShop.LoadCartPreview(_newIndex, StablesShop.CartPed); } }; buyCarriagesMenu.OnItemSelect += (_menu, _item, _index) => { subMenuCartConfirmBuy.MenuTitle = GetConfig.Langs[GetConfig.CartLists.ElementAt(_index).Key]; subMenuCartConfirmBuy.MenuSubtitle = string.Format(GetConfig.Langs["subTitleConfirmBuy"], GetConfig.Langs[GetConfig.CartLists.ElementAt(_index).Key], GetConfig.CartLists.ElementAt(_index).Value.ToString()); buttonCartConfirmYes.Label = string.Format(GetConfig.Langs["ConfirmBuyButton"], GetConfig.CartLists.ElementAt(_index).Value.ToString()); StablesShop.cIndex = _index; }; subMenuCartConfirmBuy.OnItemSelect += (_menu, _item, _index) => { if (_index == 0) { StablesShop.ConfirmBuyCarriage(); } else { subMenuCartConfirmBuy.CloseMenu(); } }; buyCarriagesMenu.OnMenuOpen += (_menu) => { StablesShop.BuyCartMode(); StablesShop.LoadCartPreview(0, StablesShop.CartPed); }; buyCarriagesMenu.OnMenuClose += (_menu) => { StablesShop.ExitMyCartMode(); }; }