Deleting entities that are not owned

How can I prevent or check when a client uses the native DeleteEntity(entity) to delete entities to other clients?

You could maybe try something like this:

Firstly, thank you for your response.

Okay, I understood what you meant with the natives above, however, I don’t know if that would be the way to resolve this considering that some mod menus execute things directly from the client by passing DeleteEntity directly

Maybe I didn’t explain it well, so I’ll try to detail what’s going on. On my server, when a cheater enters, he manages to manipulate the entity that does not belong to him, I will show you a code that the cheater loads on the client (where for some reason it is synchronized for all users).

if cheater('deleteveh') then
     DeleteEntity(GetVehiclePedIsIn(PlayerPedId()))
end

See what happened, the cheater managed to inject code into the client where he can manipulate entities that are NOT his. And another, sometimes they don’t even check if the player is inside the car (which is even worse, deleting cars that are nearby), unfortunately I haven’t found a way around this yet.

If there was at least a listener running to which something this event is triggered, I could try to check with the resources you gave me

Oh, I thought you wanted to know if the entity is owned before deleting it in your script.

I don’t think there is a way to detect it and if there were one, you would have a problem because DeleteEntity can be used non-maliciously.

How did you get this piece of code?

Any menu mod has this function, and anyone who knows how to inject something into their server would be able to use this using the menu or not, that’s the client’s problem.

I don’t think there would be a problem as there are several other events that intercept (hooks) to know when an event is executed, you can see this here Events - Cfx.re Docs

An ideal scenario would be when DeleteEntity was executed on the client it would automatically trigger an event basically how the events mentioned above work, so this check could be done by capturing the event that was called.

It would also be very interesting if there was the same for TriggerEvents in general