From 63d7667c3d83170027c4eff27331e7d4b88ff9b2 Mon Sep 17 00:00:00 2001
From: Vespura <31419184+TomGrobbe@users.noreply.github.com>
Date: Thu, 10 May 2018 15:30:29 +0200
Subject: [PATCH] cleaned up
---
vMenu/CommonFunctions.cs | 107 +++++++++------------------------------
1 file changed, 25 insertions(+), 82 deletions(-)
diff --git a/vMenu/CommonFunctions.cs b/vMenu/CommonFunctions.cs
index 0894c0e5..4f3f917c 100644
--- a/vMenu/CommonFunctions.cs
+++ b/vMenu/CommonFunctions.cs
@@ -35,10 +35,7 @@ public CommonFunctions() { }
///
///
///
- public string GetLocalizedName(string label)
- {
- return GetLabelText(label);
- }
+ public string GetLocalizedName(string label) => GetLabelText(label);
#endregion
#region Get Localized Vehicle Display Name
@@ -47,10 +44,7 @@ public string GetLocalizedName(string label)
///
///
///
- public string GetVehDisplayNameFromModel(string name)
- {
- return GetLabelText(GetDisplayNameFromVehicleModel((uint)GetHashKey(name)));
- }
+ public string GetVehDisplayNameFromModel(string name) => GetLabelText(GetDisplayNameFromVehicleModel((uint)GetHashKey(name)));
#endregion
#region GetHashKey for other classes
@@ -59,10 +53,7 @@ public string GetVehDisplayNameFromModel(string name)
///
/// String to convert into a hash.
/// The has value of the input string.
- public uint GetHash(string input)
- {
- return (uint)GetHashKey(input);
- }
+ public uint GetHash(string input) => (uint)GetHashKey(input);
#endregion
#region DoesModelExist
@@ -71,20 +62,14 @@ public uint GetHash(string input)
///
/// The model name
///
- public bool DoesModelExist(string modelName)
- {
- return IsModelInCdimage((uint)GetHashKey(modelName));
- }
+ public bool DoesModelExist(string modelName) => DoesModelExist((uint)GetHashKey(modelName));
///
/// Does this model exist?
///
/// The model hash
///
- public bool DoesModelExist(uint modelHash)
- {
- return IsModelInCdimage(modelHash);
- }
+ public bool DoesModelExist(uint modelHash) => IsModelInCdimage(modelHash);
#endregion
#region GetVehicle from specified player id (if not specified, return the vehicle of the current player)
@@ -95,14 +80,7 @@ public bool DoesModelExist(uint modelHash)
/// Get the vehicle for this player.
/// If true, return the last vehicle, if false (default) return the current vehicle.
/// Returns a vehicle (int).
- public int GetVehicle(int player = -1, bool lastVehicle = false)
- {
- if (player == -1)
- {
- return GetVehiclePedIsIn(PlayerPedId(), lastVehicle);
- }
- return GetVehiclePedIsIn(GetPlayerPed(player), lastVehicle);
- }
+ public int GetVehicle(int player = -1, bool lastVehicle = false) => GetVehiclePedIsIn(GetPlayerPed(player), lastVehicle);
#endregion
#region GetVehicleModel (uint)(hash) from Entity/Vehicle (int)
@@ -111,10 +89,7 @@ public int GetVehicle(int player = -1, bool lastVehicle = false)
///
/// Entity/vehicle.
/// Returns the (uint) model hash from a (vehicle) entity.
- public uint GetVehicleModel(int vehicle)
- {
- return (uint)GetHashKey(GetEntityModel(vehicle).ToString());
- }
+ public uint GetVehicleModel(int vehicle) => (uint)GetHashKey(GetEntityModel(vehicle).ToString());
#endregion
#region Drive Tasks (WIP)
@@ -169,10 +144,7 @@ public void DriveWander()
///
/// Quit the current network session, but leaves you connected to the server so addons/resources are still streamed.
///
- public void QuitSession()
- {
- NetworkSessionEnd(true, true);
- }
+ public void QuitSession() => NetworkSessionEnd(true, true);
///
/// Quit the game after 5 seconds.
@@ -331,7 +303,7 @@ public async Task TeleportToCoords(Vector3 pos)
}
///
- ///
+ /// Teleports to the player's waypoint. If no waypoint is set, notify the user.
///
public async void TeleportToWp()
{
@@ -430,15 +402,12 @@ public async void BanPlayer(Player player, bool forever)
}
#endregion
- #region Kill Player
+ #region Kill Player/commit suicide options
///
/// Kill player
///
///
- public void KillPlayer(Player player)
- {
- TriggerServerEvent("vMenu:KillPlayer", player.ServerId);
- }
+ public void KillPlayer(Player player) => TriggerServerEvent("vMenu:KillPlayer", player.ServerId);
public async void CommitSuicide()
{
@@ -482,10 +451,7 @@ public async void CommitSuicide()
/// Summon player.
///
///
- public void SummonPlayer(Player player)
- {
- TriggerServerEvent("vMenu:SummonPlayer", player.ServerId);
- }
+ public void SummonPlayer(Player player) => TriggerServerEvent("vMenu:SummonPlayer", player.ServerId);
#endregion
#region Spectate function
@@ -589,14 +555,11 @@ public void CycleThroughSeats()
}
}
}
-
-
}
else
{
Notify.Alert("There are no more available seats to cycle through.");
}
-
}
#endregion
@@ -983,10 +946,7 @@ public async void SaveVehicle(string updateExistingSavedVehicleName = null)
///
///
///
- public VehicleInfo GetSavedVehicleInfo(string saveName)
- {
- return sm.GetSavedVehicleInfo(saveName);
- }
+ public VehicleInfo GetSavedVehicleInfo(string saveName) => sm.GetSavedVehicleInfo(saveName);
#endregion
#region Get Saved Vehicles Dictionary
@@ -1206,11 +1166,9 @@ public string ToProperString(string inputString)
///
///
///
- public bool IsAllowed(Permission permission)
- {
+ public bool IsAllowed(Permission permission) =>
// Get the permissions.
- return PermissionsManager.IsAllowed(permission);
- }
+ PermissionsManager.IsAllowed(permission);
#endregion
#region Play Scenarios
@@ -1477,19 +1435,13 @@ public Dictionary JsonToDictionary(string json)
/// The new weather type.
/// Manual blackout mode enabled/disabled.
/// Dynamic weather changes enabled/disabled.
- public void UpdateServerWeather(string newWeather, bool blackout, bool dynamicChanges)
- {
- TriggerServerEvent("vMenu:UpdateServerWeather", newWeather, blackout, dynamicChanges);
- }
+ public void UpdateServerWeather(string newWeather, bool blackout, bool dynamicChanges) => TriggerServerEvent("vMenu:UpdateServerWeather", newWeather, blackout, dynamicChanges);
///
/// Modify the clouds for everyone. If removeClouds is true, then remove all clouds. If it's false, then randomize the clouds.
///
/// Removes the clouds from the sky if true, otherwise randomizes the clouds type for all players.
- public void ModifyClouds(bool removeClouds)
- {
- TriggerServerEvent("vMenu:UpdateServerWeatherCloudsType", removeClouds);
- }
+ public void ModifyClouds(bool removeClouds) => TriggerServerEvent("vMenu:UpdateServerWeatherCloudsType", removeClouds);
#endregion
#region Time Sync
@@ -1584,10 +1536,8 @@ public string[] StringToArray(string inputString)
/// The text to display.
/// The x position for the text draw origin.
/// The y position for the text draw origin.
- public void DrawTextOnScreen(string text, float xPosition, float yPosition)
- {
+ public void DrawTextOnScreen(string text, float xPosition, float yPosition) =>
DrawTextOnScreen(text, xPosition, yPosition, size: 0.48f);
- }
///
/// Draw text on the screen at the provided x and y locations.
@@ -1596,10 +1546,8 @@ public void DrawTextOnScreen(string text, float xPosition, float yPosition)
/// The x position for the text draw origin.
/// The y position for the text draw origin.
/// The size of the text.
- public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size)
- {
+ public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size) =>
DrawTextOnScreen(text, xPosition, yPosition, size, CitizenFX.Core.UI.Alignment.Left);
- }
///
/// Draw text on the screen at the provided x and y locations.
@@ -1609,10 +1557,8 @@ public void DrawTextOnScreen(string text, float xPosition, float yPosition, floa
/// The y position for the text draw origin.
/// The size of the text.
/// Align the text. 0: center, 1: left, 2: right
- public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size, CitizenFX.Core.UI.Alignment justification)
- {
+ public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size, CitizenFX.Core.UI.Alignment justification) =>
DrawTextOnScreen(text, xPosition, yPosition, size, justification, 6);
- }
///
/// Draw text on the screen at the provided x and y locations.
@@ -1623,10 +1569,8 @@ public void DrawTextOnScreen(string text, float xPosition, float yPosition, floa
/// The size of the text.
/// Align the text. 0: center, 1: left, 2: right
/// Specify the font to use (0-8).
- public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size, CitizenFX.Core.UI.Alignment justification, int font)
- {
+ public void DrawTextOnScreen(string text, float xPosition, float yPosition, float size, CitizenFX.Core.UI.Alignment justification, int font) =>
DrawTextOnScreen(text, xPosition, yPosition, size, justification, font, false);
- }
///
/// Draw text on the screen at the provided x and y locations.
@@ -1673,15 +1617,13 @@ public struct PedInfo
public Dictionary drawableVariations;
public Dictionary drawableVariationTextures;
};
+
#region Set Player Skin
///
/// Sets the player's model to the provided modelName.
///
/// The model name.
- public void SetPlayerSkin(string modelName, PedInfo pedCustomizationOptions)
- {
- SetPlayerSkin((uint)GetHashKey(modelName), pedCustomizationOptions);
- }
+ public void SetPlayerSkin(string modelName, PedInfo pedCustomizationOptions) => SetPlayerSkin((uint)GetHashKey(modelName), pedCustomizationOptions);
///
/// Sets the player's model to the provided modelHash.
@@ -1935,7 +1877,6 @@ public PedInfo JsonToPedInfo(string json, string saveName)
}
#region Save and restore weapon loadouts when changing models
-
private struct WeaponInfo
{
public int Ammo;
@@ -1943,7 +1884,9 @@ private struct WeaponInfo
public List Components;
public int Tint;
}
+
private List weaponsList = new List();
+
///
/// Saves all current weapons and components.
///