feat(gamestate/server): Add IS_OBJECT_A_PICKUP
Goal of this PR
I'm currently dealing with an issue related to pickup creation exploits on my server. I want to be able to detect and prevent the creation of pickups reliably.
At the moment, many servers work around this by using GetEntityModel(entity) == 0 during entityCreating, but this approach is fragile and likely to break once the CPickupCreationDataNode is parsed properly (as introduced in PR https://github.com/citizenfx/fivem/pull/2940).
Additionally, we still can't access the raw entity type until PR https://github.com/citizenfx/fivem/pull/2945 is merged.
How is this PR achieving the goal
This PR introduces the IS_OBJECT_A_PICKUP native, matching the existing client-side counterpart.
Ideally, I’d prefer the other PR (https://github.com/citizenfx/fivem/pull/2945) to be accepted in order to unify this logic under a single getter, rather than relying on multiple IS_..._A_... checks.
However, since that PR has been stalled since November, this solution offers a more straightforward and less controversial path forward.
AddEventHandler('entityCreating', function(entity)
if IsObjectAPickup(entity) then
CancelEvent()
end
end)
This PR applies to the following area(s)
Server
Successfully tested on
Game builds: All builds
Platforms: Windows, Linux
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
Important note: This PR is useless if https://github.com/citizenfx/fivem/pull/2945 is accepted.
I was going to say "why not just add a native that returns the raw version" just to realize that there is already a pr that returns the raw version :P
Just modified the check so it's PickupPlacement or Pickup, rather than just Pickup
Closing as the raw type native (PR 2945) is now ready to merge