citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.52k stars 2.07k forks source link

Server created peds lose (client granted) weapons when exiting scope of player #2097

Open Lucas7yoshi opened 1 year ago

Lucas7yoshi commented 1 year ago

Situation:

Repro: This repro does basically what the situation above does

How to use:

Use /repro-weapon-loss-cleanup to delete peds

Video:

https://github.com/citizenfx/fivem/assets/28872095/775d93b5-f288-4dd5-806f-b0b5e49c202c

Repro Resource: repro-weapon-loss.zip

gottfriedleibniz commented 1 year ago

Based on the video, I suspect the Peds task bits are being thrown off by ammo not being updated/synchronized, i.e., out of weapons/ammo so run. For reference, that subtree is only synchronized in states 1 (CLONE_CREATE) or 4 (CLONE_REASSIGN; vernacular needs improving) and OneSync happens to replace much of the reassignment logic.

In the meantime, you can always implement a fairly crude workaround using state bag handlers to reinitialize the inventory/loadout and correct the task.

blattersturm commented 1 year ago

... ah. The ped inventory being the one user of mask 4 would explain a lot here.