CWeaponDamageEvent returns wrong weapon hash

When using weaponDamageEvent, data.weaponType returns an unsigned int. GetSelectedPedWeapon, GetHashKey, joaat, and compile-time hashing all return a signed int.

Not a huge issue since you can work around it (see below), but it caught me off-guard and I haven’t seen any mention of it.

AddEventHandler('weaponDamageEvent', function(playerId, data)
    print(data.weaponType, GetSelectedPedWeapon(GetPlayerPed(playerId)), `WEAPON_CROWBAR`, `WEAPON_CROWBAR` & 0xFFFFFFFF)
end)

Printed values are

2227010557
-2067956739
-2067956739
2227010557

CFireEvent, CGiveWeaponEvent, CRemoveWeaponEvent, and CStartProjectileEvent all return the expected hash.

There’s a lot of places that do this ‘inconsistently’ and as per usual this can’t be changed without breaking compatibility.

I’ve tried to find a past post explaining this but probably used the wrong search terms (or it was on GitHub or Discord or wherever), but really I don’t know the ‘expected’ outcome you’d want to see, and by now I expect this to be known behavior given there’s a lot of other places that don’t sign-extend hashes.

Closing as this isn’t actionable and ‘solved’ isn’t really correct either as it’s not ‘solved’.