Hello. I tried that for multiple types of objects and neither of them doesn’t care when I change their Z coordinate. And the problem is the most of them floats in the air. I don’t know why I can’t move them up and down and this is driving me crazy 
RegisterNetEvent('esx_extraitems:tent')
AddEventHandler('esx_extraitems:tent', function()
local model = {
'prop_skid_tent_03',
'prop_skid_tent_01'
}
model = model[math.random(#model)]
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * 1.5)
z = z - 1.0
ESX.Game.SpawnObject(model, {
x = x,
y = y,
z = z
}, function(obj)
SetEntityHeading(obj, GetEntityHeading(playerPed))
PlaceObjectOnGroundProperly(obj)
end)
TriggerEvent("pNotify:SendNotification", {
layout = "bottomRight",
text = "Rozstawiłeś namiot",
type = "info",
theme = "gta",
sounds = {
sources = {"notification.wav"}, -- For sounds to work, you place your sound in the html folder and then add it to the files array in the __resource.lua file.
volume = 0.2,
conditions = {"docVisible"} -- This means it will play the sound when the notification becomes visible.
}
})
end)
The most funny thing is when I do higher number like z = z - 10.0 then it is moved, but it’s under the ground floating.
Z coordinate is the height in the world, but you are calling PlaceObjectOnGroundProperly so it will reset the height to the ground height on that location
Okay, that’s a good tip, didn’t knew that. So should I remove that PlaceObjectOnGroundProperly and use other native?
//edit Okay, I get it to work by using CreateObject instead of ESX.Game.SpawnObject 
//edit2 Okay, not fixed. The first one spawning good but then the other is flying again 
RegisterNetEvent('esx_extraitems:tent')
AddEventHandler('esx_extraitems:tent', function()
local model = {
'prop_skid_tent_03',
'prop_skid_tent_01'
}
model = model[math.random(#model)]
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * 1.5)
z = z - 1.0
if DoesEntityExist(tent) then
DeleteEntity(tent)
tent = CreateObject (GetHashKey(model), x, y, z , true, false, false)
else
tent = CreateObject (GetHashKey(model), x, y, z , true, false, false)
end
TriggerEvent("pNotify:SendNotification", {
layout = "bottomRight",
text = "Rozstawiłeś namiot",
type = "info",
theme = "gta",
sounds = {
sources = {"notification.wav"}, -- For sounds to work, you place your sound in the html folder and then add it to the files array in the __resource.lua file.
volume = 0.2,
conditions = {"docVisible"} -- This means it will play the sound when the notification becomes visible.
}
})
end)
I did this but nothing better. The first object with certain model is on the ground and the next one is floating.
Okay, I used CreateObjectNoOffset instead of CreateObject. It’s working properly now,