Skip to content
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

Change InfiniteAmmo only if WPUnlimitedAmmo is allowed #271

Merged
merged 2 commits into from
May 5, 2022
Merged

Change InfiniteAmmo only if WPUnlimitedAmmo is allowed #271

merged 2 commits into from
May 5, 2022

Conversation

IS4Code
Copy link

@IS4Code IS4Code commented Jan 1, 2022

At the moment, if the weapons menu is enabled, vMenu modifies Game.PlayerPed.Weapons.Current.InfiniteAmmo on each tick. However, this breaks any other scripts that touch that property.

This changes the handler so that infinite ammo is set at all only if vMenu.WeaponOptions.UnlimitedAmmo as a permission is enabled, so at least it could be fixed by disabling that permission, while keeping the rest of the menu enabled.

Copy link
Contributor

@cm8263 cm8263 left a comment

Choose a reason for hiding this comment

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

I was confused at first about what you were going for here, but I understand now. For anyone else who took a peek and didn't understand the significance right away:

The way this is written presently is that regardless of the output of IsAllowed(Permission.WPUnlimitedAmmo), Game.PlayerPed.Weapons.Current.InfiniteAmmo is still being updated every tick (as @IllidanS4 said in their description), which means that if another resource tries to set the value of Game.PlayerPed.Weapons.Current.InfiniteAmmo, it is immediately overridden by this resource.

This isn't a perfect solution as an Admin, for example, might have this permission and therefore still run into the issue, but it's would solve the problem for "regular" players at least. The only suggestion I would make it moving IsAllowed(Permission.WPUnlimitedAmmo) to the front of the if statement, so we are not hitting natives unnecessarily (i.e. when a player does not have permission). Removing the permission from everyone, including Admins or similar, when using a third-party script that controls Game.PlayerPed.Weapons.Current.InfiniteAmmo would solve the above issue after this change was implemented.

vMenu/FunctionsController.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@cm8263 cm8263 left a comment

Choose a reason for hiding this comment

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

Looks good to me. If OP or anyone else has a better suggestion for solving the permissions problem without removing the permission from all players, feel free to add to the PR.

@TomGrobbe TomGrobbe merged commit 81f230d into TomGrobbe:development May 5, 2022
matty45 pushed a commit to matty45/M-vMenu that referenced this pull request May 25, 2022
Change InfiniteAmmo only if WPUnlimitedAmmo is allowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants