fivem icon indicating copy to clipboard operation
fivem copied to clipboard

feat(fivem/state): add ConVar & Native to disallow server created entities being deleted by the client

Open AvarianKnight opened this issue 11 months ago • 3 comments

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

AvarianKnight avatar Mar 18 '24 18:03 AvarianKnight

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.

william-des avatar Mar 19 '24 00:03 william-des

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.

AvarianKnight avatar Mar 19 '24 05:03 AvarianKnight

This now adds SET_ENTITY_REJECTS_CLIENT_DELETION and adds another flag rejectClientDeletion that will default to the value of sv_disallowClientDelete

AvarianKnight avatar Mar 19 '24 09:03 AvarianKnight

There were some possible issues with this PR that could lead to some weird/bad regressions.

AvarianKnight avatar Jun 11 '24 05:06 AvarianKnight