Create weapons on map

Hi,

I try to create weapon at specific point on the map, all look work but no weapon on the map… there is my code, any idea?

local x = 1

Citizen.CreateThread(function()
        Citizen.Wait(0)
        while not weaponPlaced do
        --    RemoveAllPedWeapons(GetPlayerPed(-1), true)
            weaponPlace = weaponCoords[x] 
            --weaponNum = GetRandomIntInRange(1, #weaponsList)
            givenWeapon = weaponsList[GetRandomIntInRange(1, #weaponsList)]
            
            while not HasModelLoaded(GetHashKey(givenWeapon)) do
                Citizen.Wait(0)
            end
            --weaponHash = GetHashKey(givenWeapon)
            weapon = CreatePickupRotate(GetHashKey(givenWeapon), weaponPlace[1], weaponPlace[2], weaponPlace[3], 0.0, 0.0, 0.0, 8, 1.0, 24, 24, true, GetHashKey(givenWeapon))
            --CreateWeaponObject(weaponHash, 10, weaponPlace[1], weaponPlace[2], weaponPlace[3], true, 220.20, 1)
            SetEntityDynamic(weapon, true)
            SetEntityRecordsCollisions(weapon, true)
            SetEntityHasGravity(weapon, true)
            FreezeEntityPosition(weapon, false)
            SetEntityVelocity(weapon, 0.0, 0.0, -0.2)
            x = x + 1
            TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'Weapon: '..givenWeapon)
            if x == #weaponCoords then
                weaponPlaced = true
            end
        end
    end)

As you can see, I try a lok of stuff, nothing work… I have the message “Weapon: WEAPON_NAME” for each “x” but no weapon on map…

Thanks for your help!

from @Mr.Scammer

local spawnableWeapons =
{
	"PICKUP_WEAPON_PISTOL",
	"PICKUP_WEAPON_SMG",
	"PICKUP_WEAPON_KNIFE",
	"PICKUP_WEAPON_ASSAULTRIFLE",
}
choosenWeapon = spawnableWeapons[math.random(1, #spawnableWeapons)]

			weapon = CreatePickupRotate(GetHashKey(choosenWeapon), newX, newY, z, 0.0, 0.0, 0.0, 8, 1.0, 24, 24, true, GetHashKey(choosenWeapon))
			SetEntityDynamic(weapon, true)
			SetEntityRecordsCollisions(weapon, true)
			SetEntityHasGravity(weapon, true)
			FreezeEntityPosition(weapon, false)
			SetEntityVelocity(weapon, 0.0, 0.0, -0.2)

I also have a working version, but i’m not home now. I will share you my working code asap.

edit:
lol, i should read better before I repost the code

Yep, I found help in Zombie mod released by @Mr.Scammer, but not work for me… thanks for your help!