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

New functions setWeaponRenderEnabled & isWeaponRenderEnabled #3917

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Jan 1, 2025

This PR adds functions that allow disabling the rendering of weapons. Some servers do not use the original weapons and replace them with their own system. To remove the original weapons, they need to replace the model with an empty one or manipulate the weapon model's LOD distance. The function only toggles the rendering of the weapon object, so shooting, aiming, etc., can still be done

bool setWeaponRenderEnabled(bool enabled)
bool isWeaponRenderEnabled()

Thanks to @ds1-e for idea

@FileEX FileEX changed the title New function setWeaponRenderEnabled New functions setWeaponRenderEnabled & isWeaponRenderEnabled Jan 1, 2025
@ds1-e
Copy link
Contributor

ds1-e commented Jan 1, 2025

On a side note regarding why it should be used instead of other ways to hide weapon model, see this comment

@lynconsix
Copy link

This PR adds functions that allow disabling the rendering of weapons. Some servers do not use the original weapons and replace them with their own system. To remove the original weapons, they need to replace the model with an empty one or manipulate the weapon model's LOD distance. The function only toggles the rendering of the weapon object, so shooting, aiming, etc., can still be done

bool setWeaponRenderEnabled(bool enabled)
bool isWeaponRenderEnabled()

Thanks to @ds1-e for idea

It's much better this way instead of replacing models, because replacing models for “new” weapons consumes memory.

@botder
Copy link
Member

botder commented Jan 1, 2025

You have to reset the state after quit/on server join.

@lynconsix
Copy link

@FileEX
You could add another function, resetWeaponRender(int modelid) and instead of disabling all weapon rendering, identify the model of the weapon you want to disable.
setWeaponRenderEnabled(int modelid, bool enabled) & isWeaponRenderEnabled(int modelid)

@ds1-e
Copy link
Contributor

ds1-e commented Jan 1, 2025

@lynconsix I disagree. See my previous comment for details, there's no need to add extra steps on top of already horribly performing GTA function. If you want to selectively disable certain weapons, just use old methods (after all you should still rather use something like pAttach for any weapon, considering it's more smoother alternative)

@FileEX
Copy link
Contributor Author

FileEX commented Jan 1, 2025

You have to reset the state after quit/on server join.

Done

@derxgbb
Copy link

derxgbb commented Jan 1, 2025

I do agree with @lynconsix to have a modelid param for obvious reasons. Without that this new feature will only be used by servers where every weapon model is changed. (if this PR gets merged like this - it is still nice)

off topic:
This reminds me of weapon properties.
You can't set a given player's weapon property because the func doesn't have a player/ped param so it changes for everyone and there is no real clientside variant of this function. The current clientside version of this func only works on custom weapons so the func name should be setCustomWeaponProperty

@ds1-e
Copy link
Contributor

ds1-e commented Jan 2, 2025

I do agree with @lynconsix to have a modelid param for obvious reasons. Without that this new feature will only be used by servers where every weapon model is changed. (if this PR gets merged like this - it is still nice)

off topic: This reminds me of weapon properties. You can't set a given player's weapon property because the func doesn't have a player/ped param so it changes for everyone and there is no real clientside variant of this function. The current clientside version of this func only works on custom weapons so the func name should be setCustomWeaponProperty

This can already be done using:

engineSetModelLODDistance(weaponModelID, 0.001)

What can't be done however, is disabling GTA function call which i've already mentioned twice (and seems to be totally ignored), being secondary purpose of it. Adding selectivity would force it to process anyways, which completely excludes it.

Client/game_sa/CGameSA.cpp Outdated Show resolved Hide resolved
@botder botder merged commit efed59b into multitheftauto:master Jan 3, 2025
6 checks passed
@botder botder added this to the 1.6.1 milestone Jan 3, 2025
@botder botder added the enhancement New feature or request label Jan 3, 2025
@FileEX FileEX deleted the feature/render-weapon branch January 3, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants