im having issues with it spawning under ground
I had this happen to me twice out of about 100+ spawned tents. I’m not sure why this is happening, trying /tent
again a few times usually works, or moving slightly sometimes also works.
ok ill try thanks…
Here you go fellas, added some chairs and fixed the commas at the end of the array
More objects here
http://objects.codeshock.hu/gallery.php?page=90&perpage=12&search=
client.lua
local prevtent = 0
RegisterCommand('tent', function(source, args, rawCommand)
if prevtent ~= 0 then
SetEntityAsMissionEntity(prevtent)
DeleteObject(prevtent)
prevtent = 0
end
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, -1.95))
local tents = {
'prop_skid_tent_01',
'prop_skid_tent_01b',
'prop_skid_tent_03'
}
local randomint = math.random(1,3)
local tent = GetHashKey(tents[randomint])
local prop = CreateObject(tent, x, y, z, true, false, true)
SetEntityHeading(prop, GetEntityHeading(PlayerPedId()))
prevtent = prop
end, false)
RegisterCommand('deltent', function(source, args, rawCommand)
if prevtent == 0 then
TriggerEvent('chatMessage', '', {255,255,255}, '^8Error: ^0no previous tent spawned, or your previous tent has already been deleted.')
else
SetEntityAsMissionEntity(prevtent)
DeleteObject(prevtent)
prevtent = 0
end
end, false)
local prevchair = 0
RegisterCommand('chair', function(source, args, rawCommand)
if prevchair ~= 0 then
SetEntityAsMissionEntity(prevchair)
DeleteObject(prevchair)
prevchair = 0
end
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, -1.02))
local chair = {
'prop_chair_02',
'prop_chair_05',
'prop_chair_10'
}
local randomint = math.random(1,3)
local chair = GetHashKey(chair[randomint])
local prop = CreateObject(chair, x, y, z, true, false, true)
SetEntityHeading(prop, GetEntityHeading(PlayerPedId()))
prevchair = prop
end, false)
RegisterCommand('delchair', function(source, args, rawCommand)
if prevchair == 0 then
TriggerEvent('chatMessage', '', {255,255,255}, '^8Error: ^0no previous chair spawned, or your previous chair has already been deleted.')
else
SetEntityAsMissionEntity(prevchair)
DeleteObject(prevchair)
prevchair = 0
end
end, false)
local prevfire = 0
RegisterCommand('campfire', function(source, args, rawCommand)
if prevfire ~= 0 then
SetEntityAsMissionEntity(prevfire)
DeleteObject(prevfire)
prevfire = 0
end
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, -1.55))
local prop = CreateObject(GetHashKey("prop_beach_fire"), x, y, z, true, false, true)
SetEntityHeading(prop, GetEntityHeading(PlayerPedId()))
prevfire = prop
end, false)
RegisterCommand('delcampfire', function(source, args, rawCommand)
if prevfire == 0 then
TriggerEvent('chatMessage', '', {255,255,255}, '^8Error: ^0no previous campfire spawned, or your previous campfire has already been deleted.')
else
SetEntityAsMissionEntity(prevfire)
DeleteObject(prevfire)
prevfire = 0
end
end, false)
RegisterCommand('delobject', function(source, args, rawCommand)
local prop = 0
local deelz = 10
local deelxy = 2
for offsety=-2,2 do
for offsetx=-2,2 do
for offsetz=-8,8 do
local CoordFrom = GetEntityCoords(PlayerPedId(), true)
local CoordTo = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, 0.0)
local RayHandle = StartShapeTestRay(CoordFrom.x, CoordFrom.y, CoordFrom.z-(offsetz/deelz), CoordTo.x+(offsetx/deelxy), CoordTo.y+(offsety/deelxy), CoordTo.z-(offsetz/deelz), 16, PlayerPedId(), 0)
local _, _, _, _, object = GetShapeTestResult(RayHandle)
if object ~= 0 then
prop = object
break
end
end
end
end
if prop == 0 then
TriggerEvent('chatMessage', '', {255,255,255}, '^8Error: ^0could not detect object.')
else
SetEntityAsMissionEntity(prop)
DeleteObject(prop)
end
end, false)
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/tent', 'Spawn a tent in front of you. If you already have a tent then this will override your old tent.')
TriggerEvent('chat:addSuggestion', '/deltent', 'Deletes your tent.')
TriggerEvent('chat:addSuggestion', '/chair', 'Spawn a chair in front of you. If you already have a chair then this will override your old chair.')
TriggerEvent('chat:addSuggestion', '/delchair', 'Deletes your chair.')
TriggerEvent('chat:addSuggestion', '/campfire', 'Spawn a campfire in front of you. If you already have a campfire then this will override your old campfire.')
TriggerEvent('chat:addSuggestion', '/delcampfire', 'Deletes your campfire.')
TriggerEvent('chat:addSuggestion', '/delobject', 'Deletes any object/prop in front of you.')
end)
Nice addition, though you mentioned you “fixed the commas at the end of the array” those actually don’t matter in lua, if you loop through the array using pairs or ipairs it will work with or without a trailing comma
I’ve heard that but that’s just how I’ve been told to do it. Kept having them not appear a few times and since I did that they pop up no issue. Some of it is just calling a model tho. Maybe we are all just crazy
Impossible considering the number was always random either 1, 2 or 3. couldn’t have been a number outside of the array. though the tent might spawn below the ground as that sometimes happens randomly.
yeah that or sometimes i noticed the model just doesnt appear like the game doesnt want to spawn it, kind of like sometimes when you spawn a car. Either way i thought id save you a little time adding them lol
np, will update the main script soon if that’s ok with you.
go for it buddy, i dont care
Can we sit to chairs ?
You can use the sit emote.
Don’t really intend on updating this in the future so no sorry won’t upload it to github. Especially because it’s such a small and simple script. Will add a gist for the client file though if you want that. added a gist link to the bottom of the OP.
awesome release! thanks.
Is there a way to add this to ESX?
No its standalone.
@Vespura
I was thinking that you can add something so we can sleep on, like airmattress or something like that xd
Just an idea