fivem
fivem copied to clipboard
feat(fivem/state): add ConVar & Native to disallow server created entities being deleted by the client
Goal of this PR
Disallow server-created entities from being deleted by clients when sv_disallowClientDelete
is set to true.
How is this PR achieving the goal
Adds a new check to ProcessCloneRemove
to block the deletion of the server spawned created and recreate the entity for the calling client.
The way this is done isn't perfect (the entity will flicker for the person requesting the delete) but this shouldn't have any possible regressions (hopefully)
This PR applies to the following area(s)
Server
Successfully tested on
Platforms: Windows
Checklist
- [x] Code compiles and has been tested successfully.
- [x] Code explains itself well and/or is documented.
- [x] My commit message explains what the changes do and what they are for.
- [x] No extra compilation warnings are added by these changes.
Fixes issues
It's a great idea to provide a way to prevent the deletion of server-created entities. However, I think it would be beneficial to add native functions to allow or disallow the deletion of entities regardless of the convar value (similar to SetEntityIgnoreRequestControlFilter) A convar is not very flexible; for some servers, it could involve modifying a considerable number of scripts, which can be particularly complicated with the increasing use of escrowed resources.
It's a great idea to provide a way to prevent the deletion of server-created entities. However, I think it would be beneficial to add native functions to allow or disallow the deletion of entities regardless of the convar value (similar to SetEntityIgnoreRequestControlFilter) A convar is not very flexible; for some servers, it could involve modifying a considerable number of scripts, which can be particularly complicated with the increasing use of escrowed resources.
This is a good idea, I will implement it here in a bit.
This now adds SET_ENTITY_REJECTS_CLIENT_DELETION
and adds another flag rejectClientDeletion
that will default to the value of sv_disallowClientDelete
There were some possible issues with this PR that could lead to some weird/bad regressions.