-
-
Notifications
You must be signed in to change notification settings - Fork 446
New features and fixes #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: supplemental-permissions-pilot
Are you sure you want to change the base?
Changes from all commits
f8c34ac
0d1bda5
fe6dba5
a28000b
eb04052
da4dbdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
|
|
||
| using static CitizenFX.Core.UI.Screen; | ||
| using static vMenuShared.PermissionsManager; | ||
| using vMenuShared; | ||
|
|
||
| namespace vMenuClient | ||
| { | ||
|
|
@@ -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 | ||
| /// <summary> | ||
| /// Spawns a vehicle. | ||
| /// </summary> | ||
|
|
@@ -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); | ||
|
|
@@ -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: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this block means this comment makes no sense.
So you can probably just cleanup both the commented out line and the comment here.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
@@ -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; | ||
|
|
@@ -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> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,80 @@ public MainMenu() | |
| } | ||
| } | ||
| }), false); | ||
|
|
||
| RegisterCommand("vMenu:DV", new Action<dynamic, List<dynamic>, string>(async (source, args, rawCommand) => | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo?
There was a problem hiding this comment.
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