From 3dc9829cda1889716aec81328a7154c0dfb1ff21 Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Sun, 10 May 2020 16:12:19 +0200
Subject: [PATCH 1/6] Update CFX dependencies
---
vMenu/vMenuClient.csproj | 2 +-
vMenuServer/vMenuServer.csproj | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/vMenu/vMenuClient.csproj b/vMenu/vMenuClient.csproj
index 6848d9e7..013dea8e 100644
--- a/vMenu/vMenuClient.csproj
+++ b/vMenu/vMenuClient.csproj
@@ -18,7 +18,7 @@
-
+
runtime
diff --git a/vMenuServer/vMenuServer.csproj b/vMenuServer/vMenuServer.csproj
index 16719a8e..3b44b398 100644
--- a/vMenuServer/vMenuServer.csproj
+++ b/vMenuServer/vMenuServer.csproj
@@ -1,4 +1,4 @@
-
+
net452
embedded
@@ -19,7 +19,7 @@
-
+
runtime
From 4b16aa2ceba541878d603eb296fc2540be388d81 Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Sun, 10 May 2020 16:13:16 +0200
Subject: [PATCH 2/6] Add storage functions to get some more saved kvp data
---
vMenu/StorageManager.cs | 21 +++++++++++++++++++++
vMenu/menus/WeaponLoadouts.cs | 17 +++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/vMenu/StorageManager.cs b/vMenu/StorageManager.cs
index c909df8a..9c1b7582 100644
--- a/vMenu/StorageManager.cs
+++ b/vMenu/StorageManager.cs
@@ -97,6 +97,27 @@ public static bool SavePedInfo(string saveName, PedInfo pedData, bool overrideEx
}
+ public static List GetSavedMpPeds()
+ {
+ List peds = new List();
+ var handle = StartFindKvp("mp_ped_");
+ while (true)
+ {
+ string foundName = FindKvp(handle);
+ if (string.IsNullOrEmpty(foundName))
+ {
+ break;
+ }
+ else
+ {
+ peds.Add(GetSavedMpCharacterData(foundName));
+ }
+ }
+ EndFindKvp(handle);
+ peds.Sort((a, b) => a.SaveName.ToLower().CompareTo(b.SaveName.ToLower()));
+ return peds;
+ }
+
///
/// Delete the specified saved item from local storage.
///
diff --git a/vMenu/menus/WeaponLoadouts.cs b/vMenu/menus/WeaponLoadouts.cs
index ecb8618f..d47c8018 100644
--- a/vMenu/menus/WeaponLoadouts.cs
+++ b/vMenu/menus/WeaponLoadouts.cs
@@ -23,6 +23,23 @@ public class WeaponLoadouts
private Dictionary> SavedWeapons = new Dictionary>();
+ public static Dictionary> GetSavedWeapons()
+ {
+ int handle = StartFindKvp("vmenu_string_saved_weapon_loadout_");
+ Dictionary> saves = new Dictionary>();
+ while (true)
+ {
+ string kvp = FindKvp(handle);
+ if (string.IsNullOrEmpty(kvp))
+ {
+ break;
+ }
+ saves.Add(kvp, JsonConvert.DeserializeObject>(GetResourceKvpString(kvp)));
+ }
+ EndFindKvp(handle);
+ return saves;
+ }
+
private string SelectedSavedLoadoutName { get; set; } = "";
// vmenu_temp_weapons_loadout_before_respawn
// vmenu_string_saved_weapon_loadout_
From 7659d89f73d33b47e6455050dbf31aad07e544fd Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Sun, 10 May 2020 16:13:48 +0200
Subject: [PATCH 3/6] (WIP) Add import/export data menu item
---
vMenu/menus/MiscSettings.cs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/vMenu/menus/MiscSettings.cs b/vMenu/menus/MiscSettings.cs
index 2eee074d..6bc6118f 100644
--- a/vMenu/menus/MiscSettings.cs
+++ b/vMenu/menus/MiscSettings.cs
@@ -119,6 +119,7 @@ private void CreateMenu()
{
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);
@@ -575,6 +576,7 @@ private void CreateMenu()
menu.AddMenuItem(hideHud);
menu.AddMenuItem(lockCamX);
menu.AddMenuItem(lockCamY);
+ menu.AddMenuItem(exportData);
menu.AddMenuItem(saveSettings);
// Handle checkbox changes.
@@ -690,8 +692,27 @@ private void CreateMenu()
// Handle button presses.
menu.OnItemSelect += (sender, item, index) =>
{
+ // export data
+ if (item == exportData)
+ {
+ var vehicles = GetSavedVehicles();
+ var normalPeds = StorageManager.GetSavedPeds();
+ var mpPeds = StorageManager.GetSavedMpPeds();
+ var weaponLoadouts = WeaponLoadouts.GetSavedWeapons();
+ //SetNuiFocus(true, true);
+ //SendNuiMessage(JsonConvert.SerializeObject(new
+ //var data = JsonConvert.SerializeObject(new
+ //{
+ // saved_vehicles = vehicles,
+ // normal_peds = normalPeds,
+ // mp_characters = mpPeds,
+ // weapon_loadouts = weaponLoadouts
+ //});
+ //Debug.WriteLine(data.Length + "\n" + data);
+ //TriggerServerEvent("test", data);
+ }
// save settings
- if (item == saveSettings)
+ else if (item == saveSettings)
{
UserDefaults.SaveSettings();
}
From 4f1111f36812366cc86252908d5ce6489f4fe147 Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Thu, 21 May 2020 21:17:45 +0200
Subject: [PATCH 4/6] Update MenuAPI
---
vMenu/vMenuClient.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vMenu/vMenuClient.csproj b/vMenu/vMenuClient.csproj
index 013dea8e..c7c7b94c 100644
--- a/vMenu/vMenuClient.csproj
+++ b/vMenu/vMenuClient.csproj
@@ -14,7 +14,7 @@
-
+
From 1939549f163f3165866e312921df915e659fe117 Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Thu, 21 May 2020 21:24:04 +0200
Subject: [PATCH 5/6] Add vehicle paint fade/enveff scale features & rework
getter/setter for vehicle headlight colors
---
vMenu/CommonFunctions.cs | 8 ++++++--
vMenu/menus/VehicleOptions.cs | 36 ++++++++++++++++++++++++++---------
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/vMenu/CommonFunctions.cs b/vMenu/CommonFunctions.cs
index 6442c147..ccc2d30a 100644
--- a/vMenu/CommonFunctions.cs
+++ b/vMenu/CommonFunctions.cs
@@ -1269,7 +1269,9 @@ public static async void SpawnVehicle(uint vehicleHash, bool spawnInside, bool r
vehicle.CanTiresBurst = !vehicleInfo.bulletProofTires;
- VehicleOptions._SET_VEHICLE_HEADLIGHTS_COLOR(vehicle, vehicleInfo.headlightColor);
+ SetVehicleEnveffScale(vehicle.Handle, vehicleInfo.enveffScale);
+
+ VehicleOptions._SetHeadlightsColorOnVehicle(vehicle, vehicleInfo.headlightColor);
}
// Set the previous vehicle to the new vehicle.
@@ -1315,6 +1317,7 @@ public struct VehicleInfo
public bool xenonHeadlights;
public bool bulletProofTires;
public int headlightColor;
+ public float enveffScale;
};
#endregion
@@ -1408,7 +1411,8 @@ public static async void SaveVehicle(string updateExistingSavedVehicleName = nul
windowTint = (int)veh.Mods.WindowTint,
xenonHeadlights = IsToggleModOn(veh.Handle, 22),
bulletProofTires = !veh.CanTiresBurst,
- headlightColor = VehicleOptions._GET_VEHICLE_HEADLIGHTS_COLOR(veh)
+ headlightColor = VehicleOptions._GetHeadlightsColorFromVehicle(veh),
+ enveffScale = GetVehicleEnveffScale(veh.Handle)
};
#endregion
diff --git a/vMenu/menus/VehicleOptions.cs b/vMenu/menus/VehicleOptions.cs
index 681024a7..20ca5faf 100644
--- a/vMenu/menus/VehicleOptions.cs
+++ b/vMenu/menus/VehicleOptions.cs
@@ -969,9 +969,11 @@ private void CreateMenu()
MenuListItem wheelColorsList = new MenuListItem("Wheel Color", wheelColors, 0);
MenuListItem dashColorList = new MenuListItem("Dashboard Color", classic, 0);
MenuListItem intColorList = new MenuListItem("Interior / Trim Color", classic, 0);
+ MenuSliderItem vehicleEnveffScale = new MenuSliderItem("Vehicle Enveff Scale", "This works on certain vehicles only, like the besra for example. It 'fades' certain paint layers.", 0, 20, 10, true);
MenuItem chrome = new MenuItem("Chrome");
VehicleColorsMenu.AddMenuItem(chrome);
+ VehicleColorsMenu.AddMenuItem(vehicleEnveffScale);
VehicleColorsMenu.OnItemSelect += (sender, item, index) =>
{
@@ -985,7 +987,22 @@ private void CreateMenu()
}
else
{
- Notify.Error("You need to be the driver of a vehicle in order to change the vehicle colors.");
+ Notify.Error("You need to be the driver of a driveable vehicle to change this.");
+ }
+ };
+ VehicleColorsMenu.OnSliderPositionChange += (m, sliderItem, oldPosition, newPosition, itemIndex) =>
+ {
+ Vehicle veh = GetVehicle();
+ if (veh != null && veh.Driver == Game.PlayerPed && !veh.IsDead)
+ {
+ if (sliderItem == vehicleEnveffScale)
+ {
+ SetVehicleEnveffScale(veh.Handle, newPosition / 20f);
+ }
+ }
+ else
+ {
+ Notify.Error("You need to be the driver of a driveable vehicle to change this slider.");
}
};
@@ -1746,7 +1763,7 @@ public void UpdateMods(int selectedIndex = 0)
// Add the checkboxes to the menu.
VehicleModMenu.AddMenuItem(toggleCustomWheels);
VehicleModMenu.AddMenuItem(xenonHeadlights);
- int currentHeadlightColor = _GET_VEHICLE_HEADLIGHTS_COLOR(veh);
+ int currentHeadlightColor = _GetHeadlightsColorFromVehicle(veh);
if (currentHeadlightColor < 0 || currentHeadlightColor > 12)
{
currentHeadlightColor = 13;
@@ -2006,11 +2023,11 @@ public void UpdateMods(int selectedIndex = 0)
{
if (newIndex == 13) // default
{
- _SET_VEHICLE_HEADLIGHTS_COLOR(veh, 255);
+ _SetHeadlightsColorOnVehicle(veh, 255);
}
else if (newIndex > -1 && newIndex < 13)
{
- _SET_VEHICLE_HEADLIGHTS_COLOR(veh, newIndex);
+ _SetHeadlightsColorOnVehicle(veh, newIndex);
}
}
#endregion
@@ -2033,28 +2050,29 @@ public void UpdateMods(int selectedIndex = 0)
//VehicleModMenu.CurrentIndex = selectedIndex;
}
- internal static void _SET_VEHICLE_HEADLIGHTS_COLOR(Vehicle veh, int newIndex)
+ internal static void _SetHeadlightsColorOnVehicle(Vehicle veh, int newIndex)
{
+
if (veh != null && veh.Exists() && veh.Driver == Game.PlayerPed)
{
if (newIndex > -1 && newIndex < 13)
{
- CitizenFX.Core.Native.Function.Call((CitizenFX.Core.Native.Hash)0xE41033B25D003A07, veh.Handle, newIndex);
+ SetVehicleHeadlightsColour(veh.Handle, newIndex);
}
else
{
- CitizenFX.Core.Native.Function.Call((CitizenFX.Core.Native.Hash)0xE41033B25D003A07, veh.Handle, -1);
+ SetVehicleHeadlightsColour(veh.Handle, -1);
}
}
}
- internal static int _GET_VEHICLE_HEADLIGHTS_COLOR(Vehicle vehicle)
+ internal static int _GetHeadlightsColorFromVehicle(Vehicle vehicle)
{
if (vehicle != null && vehicle.Exists())
{
if (IsToggleModOn(vehicle.Handle, 22))
{
- int val = CitizenFX.Core.Native.Function.Call((CitizenFX.Core.Native.Hash)0x3DFF319A831E0CDB, vehicle.Handle);
+ int val = GetVehicleHeadlightsColour(vehicle.Handle);
if (val > -1 && val < 13)
{
return val;
From 3507ebc75976d7cf58c51bb1a6f1946bf9290c1c Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Thu, 21 May 2020 21:24:48 +0200
Subject: [PATCH 6/6] Add Benny's (1) & Benny's (2) vehicle wheel types and
improve list index change logic
---
vMenu/menus/VehicleOptions.cs | 62 ++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 23 deletions(-)
diff --git a/vMenu/menus/VehicleOptions.cs b/vMenu/menus/VehicleOptions.cs
index 20ca5faf..6dffc167 100644
--- a/vMenu/menus/VehicleOptions.cs
+++ b/vMenu/menus/VehicleOptions.cs
@@ -1750,9 +1750,12 @@ public void UpdateMods(int selectedIndex = 0)
#region more variables and setup
veh = GetVehicle();
// Create the wheel types list & listitem and add it to the menu.
- List wheelTypes = new List() { "Sports", "Muscle", "Lowrider", "SUV", "Offroad", "Tuner", "Bike Wheels", "High End" };
- MenuListItem vehicleWheelType = new MenuListItem("Wheel Type", wheelTypes, GetVehicleWheelType(veh.Handle), $"Choose a ~y~wheel type~s~ for your vehicle.");
- VehicleModMenu.AddMenuItem(vehicleWheelType);
+ List wheelTypes = new List() { "Sports", "Muscle", "Lowrider", "SUV", "Offroad", "Tuner", "Bike Wheels", "High End", "Benny's (1)", "Benny's (2)" };
+ MenuListItem vehicleWheelType = new MenuListItem("Wheel Type", wheelTypes, MathUtil.Clamp(GetVehicleWheelType(veh.Handle), 0, 9), $"Choose a ~y~wheel type~s~ for your vehicle.");
+ if (!veh.Model.IsBoat && !veh.Model.IsHelicopter && !veh.Model.IsPlane && !veh.Model.IsBicycle && !veh.Model.IsTrain)
+ {
+ VehicleModMenu.AddMenuItem(vehicleWheelType);
+ }
// Create the checkboxes for some options.
MenuCheckboxItem toggleCustomWheels = new MenuCheckboxItem("Toggle Custom Wheels", "Press this to add or remove ~y~custom~s~ wheels.", GetVehicleModVariation(veh.Handle, 23));
@@ -1943,33 +1946,46 @@ public void UpdateMods(int selectedIndex = 0)
// Wheel types
else if (item2 == vehicleWheelType)
{
- // Set the wheel type.
- int nindex = newIndex;
- if (newIndex >= item2.ItemsCount)
- {
- nindex = 0;
- }
- else if (newIndex < 0)
+ // 6 should be used for bikes only.
+ if ((newIndex == 6 && veh.Model.IsBike) || (newIndex != 6 && !veh.Model.IsBike))
{
- nindex = item2.ItemsCount - 1;
- }
+ // Set the wheel type
+ SetVehicleWheelType(veh.Handle, newIndex);
- // set the wheel type
- SetVehicleWheelType(veh.Handle, nindex);
+ bool customWheels = GetVehicleModVariation(veh.Handle, 23);
- bool customWheels = GetVehicleModVariation(veh.Handle, 23);
+ // Reset the wheel mod index for front wheels
+ SetVehicleMod(veh.Handle, 23, -1, customWheels);
- // reset the wheel mod index for front wheels
- SetVehicleMod(veh.Handle, 23, -1, customWheels);
+ // If the model is a bike, do the same thing for the rear wheels.
+ if (veh.Model.IsBike)
+ {
+ SetVehicleMod(veh.Handle, 24, -1, customWheels);
+ }
- // if the model is a bike, do the same thing for the rear wheels.
- if (veh.Model.IsBike)
+ // Refresh the menu with the item index so that the view doesn't change
+ UpdateMods(selectedIndex: itemIndex);
+ }
+ else
{
- SetVehicleMod(veh.Handle, 24, -1, customWheels);
+ // Go past the index if it's not a bike.
+ if (!veh.Model.IsBike)
+ {
+ if (newIndex > oldIndex)
+ {
+ item2.ListIndex++;
+ }
+ else
+ {
+ item2.ListIndex--;
+ }
+ }
+ // Reset the index to 6 if it is a bike
+ else
+ {
+ item2.ListIndex = 6;
+ }
}
-
- // Refresh the menu with the item index so that the view doesn't change
- UpdateMods(selectedIndex: itemIndex);
}
// Tire smoke
else if (item2 == tireSmoke)