Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions SharedClasses/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public enum Setting
vmenu_disable_entity_outlines_tool,
vmenu_disable_player_stats_setup,

// Vehicle Chameleon Colours
// Vehicle Settings
vmenu_using_chameleon_colours,
vmenu_vehicle_spawn_delay,
vmenu_delete_vehicle_distance,

// Prevent Extras Abuse
vmenu_prevent_extras_when_damaged,
Expand All @@ -61,6 +63,7 @@ public enum Setting
vmenu_vehicle_blackout_enabled,
vmenu_weather_change_duration,
vmenu_enable_snow,
vmenu_smooth_time_transitions,

// Time settings
vmenu_enable_time_sync,
Expand Down Expand Up @@ -92,12 +95,12 @@ public static bool GetSettingsBool(Setting setting)
/// </summary>
/// <param name="setting"></param>
/// <returns></returns>
public static int GetSettingsInt(Setting setting)
public static int GetSettingsInt(Setting setting, int defaultValue = -1)
{
var convarInt = GetConvarInt(setting.ToString(), -1);
if (convarInt == -1)
var convarInt = GetConvarInt(setting.ToString(), defaultValue);
if (convarInt == defaultValue)
{
if (int.TryParse(GetConvar(setting.ToString(), "-1"), out var convarIntAlt))
if (int.TryParse(GetConvar(setting.ToString(), defaultValue.ToString()), out var convarIntAlt))
{
return convarIntAlt;
}
Expand All @@ -110,13 +113,13 @@ public static int GetSettingsInt(Setting setting)
/// </summary>
/// <param name="setting"></param>
/// <returns></returns>
public static float GetSettingsFloat(Setting setting)
public static float GetSettingsFloat(Setting setting, float defaultValue = -1f)
{
if (float.TryParse(GetConvar(setting.ToString(), "-1.0"), out var result))
if (float.TryParse(GetConvar(setting.ToString(), defaultValue.ToString()), out var result))
{
return result;
}
return -1f;
return defaultValue;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions SharedClasses/PermissionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public enum Permission
#region vehicle spawner
VSMenu,
VSAll,
VSBypassRateLimit,
VSDisableReplacePrevious,
VSSpawnByName,
VSAddon,
Expand Down Expand Up @@ -481,8 +482,7 @@ private static bool IsAllowedServer(Permission permission, string playerHandle)
{
return false;
}

return IsPlayerAceAllowed(playerHandle, GetAceName(permission));
return GetPermissionAndParentPermissions(permission).Any(p => IsPlayerAceAllowed(playerHandle, GetAceName(p)));
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion SharedClasses/SupplementaryPermissionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static bool IsAllowedServer(string permission, string playerHandle)
return false;
}

return IsPlayerAceAllowed(playerHandle, GetAceName(permission));
return GetPermissionAndParentPermissions(permission).Any(p => IsPlayerAceAllowed(playerHandle, GetAceName(p)));
}
#endif

Expand Down
31 changes: 23 additions & 8 deletions vMenu/CommonFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using static CitizenFX.Core.UI.Screen;
using static vMenuShared.PermissionsManager;
using vMenuShared;

namespace vMenuClient
{
Expand Down Expand Up @@ -1225,6 +1226,8 @@ public static async Task<int> SpawnVehicle(string vehicleName = "custom", bool s
#endregion

#region Main Spawn Vehicle Function
public static int lastSpawnTime = 0;
public static int spawnTime = ConfigManager.GetSettingsInt(ConfigManager.Setting.vmenu_vehicle_spawn_delay, 5) * 1000; // make convar
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// make convar

Todo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope just left in while writing it ill remove it

/// <summary>
/// Spawns a vehicle.
/// </summary>
Expand Down Expand Up @@ -1260,8 +1263,19 @@ public static async Task<int> SpawnVehicle(uint vehicleHash, bool spawnInside, b
return 0;
}
}



int gameTime = GetGameTimer();
if (!IsAllowed(Permission.VSBypassRateLimit))
{
if (lastSpawnTime + spawnTime > gameTime)
{
Notify.Error($"You are spawning vehicles too quickly. Please wait {Math.Ceiling((double)(lastSpawnTime + spawnTime - gameTime)/1000)} second(s) before trying again.");
return 0;
}
}

lastSpawnTime = gameTime;

if (!skipLoad)
{
var successFull = await LoadModel(vehicleHash);
Expand Down Expand Up @@ -1375,6 +1389,12 @@ public static async Task<int> SpawnVehicle(uint vehicleHash, bool spawnInside, b
{
vehicle.PlaceOnGround();
}

if (!vehicle.Model.IsTrain) // to be extra fucking safe
{
// workaround of retarded feature above:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this block means this comment makes no sense.
Because it was relating to line 1408:

//vehicle.Speed = speed; // retarded feature that randomly breaks for no fucking reason

So you can probably just cleanup both the commented out line and the comment here.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why did you move it up here btw? Now it gets it's speed before the vehicle mods, and the RPM is set (delayed) after the velocity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was moved so if your not spawning in the vehicle it doesn't keep the momentum

SetVehicleForwardSpeed(vehicle.Handle, speed);
}
}

// If mod info about the vehicle was specified, check if it's not null.
Expand All @@ -1386,11 +1406,6 @@ public static async Task<int> SpawnVehicle(uint vehicleHash, bool spawnInside, b
// Set the previous vehicle to the new vehicle.
_previousVehicle = vehicle;
//vehicle.Speed = speed; // retarded feature that randomly breaks for no fucking reason
if (!vehicle.Model.IsTrain) // to be extra fucking safe
{
// workaround of retarded feature above:
SetVehicleForwardSpeed(vehicle.Handle, speed);
}
vehicle.CurrentRPM = rpm;

int vehicleDefaultRadio = UserDefaults.VehicleDefaultRadio;
Expand Down Expand Up @@ -2141,7 +2156,7 @@ public static void UpdateServerTime(int hours, int minutes)
{
realMinutes = 0;
}
TriggerServerEvent("vMenu:UpdateServerTime", realHours, realMinutes);
TriggerServerEvent("vMenu:UpdateServerTime", realHours, realMinutes, EventManager.IsServerTimeFrozen);
}

/// <summary>
Expand Down
74 changes: 74 additions & 0 deletions vMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,80 @@ public MainMenu()
}
}
}), false);

RegisterCommand("vMenu:DV", new Action<dynamic, List<dynamic>, string>(async (source, args, rawCommand) =>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this command just trigger existing functionality to delete the vehicle? I'm assuming the option for the permission VODelete already has all the necessary checks implemented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it uses the default delete vehicle functionality partly, but it also has a raycast element to it so you dont need to be inside it to delete it

{
if (IsAllowed(Permission.VODelete))
{
var player = Game.PlayerPed;

if (!player.IsAlive)
return;

if (player.IsInVehicle())
{
var veh = GetVehicle();

if (veh != null && veh.Exists() && veh.Driver == player)
{
SetVehicleHasBeenOwnedByPlayer(veh.Handle, false);
SetEntityAsMissionEntity(veh.Handle, false, false);
veh.Delete();
}
else
{
Notify.Error("This vehicle does not exist (somehow) or you need to be the driver of this vehicle to delete it!");
}

return;
}

float distance = GetSettingsFloat(Setting.vmenu_delete_vehicle_distance, 5.0f);
int maxDeleteTries = 5;
int maxHitTries = 5;

var forward = GetOffsetFromEntityInWorldCoords(player.Handle, 0f, distance, 0f);
var ray = StartShapeTestCapsule(player.Position.X, player.Position.Y, player.Position.Z, forward.X, forward.Y, forward.Z, 5f, 10, player.Handle, 7);

bool hit = false;
Vector3 endCoords = Vector3.Zero;
Vector3 surfaceNormal = Vector3.Zero;
int entity = 0;

for (int i = 0; i < maxHitTries; i++)
{
GetShapeTestResult(ray, ref hit, ref endCoords, ref surfaceNormal, ref entity);
if (hit) break;
await Task.FromResult(0);
}

if (!hit || !DoesEntityExist(entity) || !IsEntityAVehicle(entity))
{
Notify.Error("No vehicle found in front of you to delete!");
return;
}

var hitVeh = new Vehicle(entity);

for (int i = 0; i <= maxDeleteTries && DoesEntityExist(entity); i++)
{
NetworkRequestControlOfEntity(entity);
SetVehicleHasBeenOwnedByPlayer(entity, false);
SetEntityAsMissionEntity(entity, false, false);
hitVeh.Delete();
await Task.FromResult(0);
}

if (DoesEntityExist(entity))
{
Notify.Error("Failed to delete the vehicle in front of you. Try again or ask an admin for help.");
}
else
{
Notify.Success("Vehicle deleted successfully.");
}
}
}), false);

if (!(GetSettingsString(Setting.vmenu_noclip_toggle_key) == null))
{
Expand Down
2 changes: 1 addition & 1 deletion vMenu/vMenuClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if exist &quot;$(SolutionDir)\postbuild.cmd&quot; &quot;$(SolutionDir)postbuild.cmd&quot;" />
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="if exist &quot;$(SolutionDir)postbuild.cmd&quot; &quot;$(SolutionDir)postbuild.cmd&quot;" />
</Target>

<ItemGroup>
Expand Down
Loading
Loading