tweak(gamestate/server): Parse and block SCRIPT_ENTITY_STATE_CHANGE_EVENT (type 9)
Goal of this PR
- This game event is sent when a client tries to change state values on a remotely owned entity.
- State Type 9 is used to make the current player-ped the exclusive driver of the targeted entity, which can be abused to kick other players out of the vehicle or deny them any future access to the driver-seat. Blocking this game event fixes the specific abuse-type.
How is this PR achieving the goal
Basic parsing of SCRIPT_ENTITY_STATE_CHANGE_EVENT and blocking of the event when the state type equals 9.
This can be changed to expose the parsed event to ScRTs (custom cancellation logic) or control the event cancellation with a ConVar, however checking all relevant code paths showed that this event is only used to change the state of a remotely owned entity, which is probably an unwanted thing in general.
Because every state type has its own custom parameter set I implemented this with GetScriptEntityStateChangeEventHandler which makes additional parsing and cancelling easier (10 types in total).
This PR has only been tested on FiveM and needs additional testing on RedM!
This PR applies to the following area(s)
FiveM, RedM, Server
Successfully tested on
Game builds: 2699
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
fixes #2553