[Release] Camping

i love this script xD

I’m pretty biased, but this is awesome. https://i.imgur.com/NdJ49FI.jpg

3 Likes

Time to add in hunting stands (the things you sit in attached to trees) and the ability to spawn deer (or enable so they spawn nearby when hunting) so you can hunt them while camping

3 Likes

I didn’t have a problem killing that one across the river from my campsite without a stand. :>

2 Likes

can you send me the script which is you can see the gun on you ?

you need to set up esx, the script that does that is kind of broken unless you want to configure the position of some of the weapons. [ESX] Real Weapons (wearable)

BTW the git is opened for Pull Request to place correctly weapons :wink:
(i’m just so tired each time I read the config so I hope people will do PR lol)

this is not work with customchat.

It says that in the topic…

2 Likes

Like @batastrophe said, I already mentioned that in the original post :wink: :

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.

1 Like

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)
1 Like

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 :wink:

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