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.57k stars 2.11k forks source link

entityCreating Event: Ambient Pickup GetEntityModel returns 0 #2924

Open borianm opened 1 week ago

borianm commented 1 week ago

What happened?

I created an ambient pickup on the client. I listened to the entityCreating event on the server. The creation triggered the event, but when I run GetEntityModel(entity) it returns 0.

Expected result

GetEntityModel(entity) should return the pickup hash

Reproduction steps

  1. Create this client command and run it:

    RegisterCommand('test_pickup', function()
    local pickupCoords = GetEntityCoords(PlayerPedId())
    local weaponModel = GetHashKey("weapon_pistol")
    local pickupHash = GetHashKey("PICKUP_WEAPON_PISTOL")
    
    Citizen.CreateThread(function()
        local pickup = CreateAmbientPickup(pickupHash, pickupCoords.x, pickupCoords.y, pickupCoords.z + 2.0, 0, 100, weaponModel, true, true)
    end)
    end)
  2. Listen to the entityCreating event on the server and fetch the entity model:
    on('entityCreating', (entity) => {
    console.log(GetEntityModel(entity))
    })
  3. It should return the same pickup hash when the command is ran, but it returns 0.

Importancy

Unknown

Area(s)

FiveM, FXServer, Natives

Specific version(s)

Client 10939 / FXServer 10367 Windows

Additional information

No response

tens0rfl0w commented 5 days ago

While this still wouldn't return the correct model hash on the server-side weaponModel needs to be an actual model and not a weapon type (in your case w_pi_pistol).