[Release] [Standalone] HideInTrash

HideInTrash is a script that allows the player to hide in dumpsters

Commands

  • /resetTrash - Clears ped from trash can and animation, used for if ped is stuck in trash

Download
Release HideInTrash v1.0.0

TODO

  • Nothing Currently

Feature request can be made Here

Changelog

View

v1.0.0

  • Initial Release

Screenshots


19 Likes

:joy: i was waiting for this

ahahahahahha very nice stufff

Make optimization through sleep for example

local canHide = true
local dumpsters = {
    "prop_dumpster_01a",
    "prop_dumpster_02a",
    "prop_dumpster_02b",
    "prop_dumpster_4a",
    "prop_dumpster_4b"
}
local inTrash = false
local sleep = 0
Citizen.CreateThread(function()
    while true do
        sleep = 1000
        if inTrash then
            local dumpster = GetEntityAttachedTo(PlayerPedId())
            local dumpPos = GetEntityCoords(dumpster)
            if DoesEntityExist(dumpster) or not IsPedDeadOrDying(PlayerPedId()) or not IsPedFatallyInjured(PlayerPedId()) then
                SetEntityCollision(PlayerPedId(), false, false)
                DrawText3Ds(dumpPos.x, dumpPos.y, dumpPos.z + 1.1, 'Press [~g~E~w~] to get out')
                if not IsEntityPlayingAnim(PlayerPedId(), 'timetable@floyd@cryingonbed@base', 3) then
                    loadDict('timetable@floyd@cryingonbed@base')
                    TaskPlayAnim(PlayerPedId(), 'timetable@floyd@cryingonbed@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
                end
                sleep = 3
                if IsControlJustReleased(0, 38) and inTrash then
                    SetEntityCollision(PlayerPedId(), true, true)
                    inTrash = false
                    DetachEntity(PlayerPedId(), true, true)
                    SetEntityVisible(PlayerPedId(), true, false)
                    ClearPedTasks(PlayerPedId())
                    SetEntityCoords(PlayerPedId(), GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -0.7, -0.75))
                    Wait(250)
                end
            else
                SetEntityCollision(PlayerPedId(), true, true)
                DetachEntity(PlayerPedId(), true, true)
                SetEntityVisible(PlayerPedId(), true, false)
                ClearPedTasks(PlayerPedId())
                SetEntityCoords(PlayerPedId(), GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -0.7, -0.75))
            end
        end
        Wait(sleep)
    end
end)

Citizen.CreateThread(function()
    while true do
        sleep = 1500
        if canHide then
            local ped = GetPlayerPed(-1)
            local pos = GetEntityCoords(ped)
            local dumpsterFound = false

            for i = 1, #dumpsters do
                local dumpster = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, dumpsters[i], false, false, false)
                local dumpPos = GetEntityCoords(dumpster)
                local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, dumpPos.x, dumpPos.y, dumpPos.z, true)

                if dist < 1.8 then
                    if not inTrash then
                        sleep = 3
                        DrawText3Ds(dumpPos.x, dumpPos.y, dumpPos.z + 1.1, 'Press [~g~E~w~] to hide inside')
                        if IsControlJustReleased(0, 38) and not inTrash then
                            if DoesEntityExist(ped) then
                                if not IsEntityAttached(ped) or GetDistanceBetweenCoords(GetEntityCoords(ped), GetEntityCoords(PlayerPedId()), true) >= 5.0 then
                                    AttachEntityToEntity(PlayerPedId(), dumpster, -1, 0.0, -0.3, 2.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)
                                    loadDict('timetable@floyd@cryingonbed@base')
                                    TaskPlayAnim(PlayerPedId(), 'timetable@floyd@cryingonbed@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
                                    Wait(50)
                                    SetEntityVisible(PlayerPedId(), false, false)
                                    inTrash = true
                                else
                                    TriggerEvent('chat:addMessage', {
                                        color = { 255, 0, 0},
                                        multiline = true,
                                        args = {"SYSTEM", "Someone is already hiding in that dumpster!"}
                                    })
                                end
                            end
                        end
                    end
                end
            end
        end
        Wait(sleep)
    end
end)

loadDict = function(dict)
    while not HasAnimDictLoaded(dict) do Wait(0) RequestAnimDict(dict) end
end

function DrawText3Ds(x, y, z, text)
    local onScreen,_x,_y=World3dToScreen2d(x,y,z)
    local factor = #text / 460
    local px,py,pz=table.unpack(GetGameplayCamCoords())

    SetTextScale(0.3, 0.3)
    SetTextFont(6)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 160)
    SetTextEntry("STRING")
    SetTextCentre(1)
    AddTextComponentString(text)
    DrawText(_x,_y)
    DrawRect(_x,_y + 0.0115, 0.02 + factor, 0.027, 28, 28, 28, 95)
end

RegisterCommand("resetTrash", function(source, args, rawCommand)

    --SetEntityCollision(PlayerPedId(), true, true)

    inTrash = false
    DetachEntity(PlayerPedId(), true, true)
    SetEntityVisible(PlayerPedId(), true, false)
    ClearPedTasks(PlayerPedId())
    SetEntityCoords(PlayerPedId(), GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -0.5, -0.75))

    print("Reset Trash")
end, false)
1 Like

Could you add a way for other players to check if someone is in a dumpster?

4 Likes

currently if someone tries to get in the dumpster and someone is in it, they get an error message saying there is someone in it. Did you mean like instead of the prompt asking if they want to get in that it tells them someone is in it? In that case I feel it would give away the RP value of hiding in the trash unless you were willing to get in it yourself and therefore opening the dumpster to look/get in

I think it is more about if someone is being chased, that the people who are chasing them can actually start searching in dumpsters to try to find the person. Imagine police looking through all the dumpsters in an alley because one person ran away from them.

well done, nice idea!

More like a “search this dumpster” kind of thing. And maybe a “drag out of dumpster” option if you find someone.

it doesnt stop you from getting into a trashcan if someone is in it, am i doing something wrong? such a cool idea if it had a check for if someone was in it

1 Like

can someone do this with qtarget ?

hey, can you make this for qtarget ?

1 Like

To get it to work with qtarget without showing the 3D text. Replace lines 44-83 with:

RegisterNetEvent("garbage:Hide")
AddEventHandler("garbage:Hide", function()
    if canHide then
        local ped = GetPlayerPed(-1)
        local pos = GetEntityCoords(ped)
        local dumpsterFound = false

        for i = 1, #dumpsters do
            local dumpster = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, dumpsters[i], false, false, false)
            local dumpPos = GetEntityCoords(dumpster)
            local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, dumpPos.x, dumpPos.y, dumpPos.z, true)
            if not inTrash then
                if DoesEntityExist(ped) then
                    if not IsEntityAttached(ped) or GetDistanceBetweenCoords(GetEntityCoords(ped), GetEntityCoords(PlayerPedId()), true) >= 5.0 then
                        AttachEntityToEntity(PlayerPedId(), dumpster, -1, 0.0, -0.3, 2.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)	
                        loadDict('timetable@floyd@cryingonbed@base')
                        TaskPlayAnim(PlayerPedId(), 'timetable@floyd@cryingonbed@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
                        Wait(50)
                        SetEntityVisible(PlayerPedId(), false, false)
                        inTrash = true
                    else
                        TriggerEvent('chat:addMessage', {
                            color = { 255, 0, 0},
                            multiline = true,
                            args = {"SYSTEM", "Someone is already hiding in that dumpster!"}
                            })
                    end
                end
            end
        end
    end
end)

We create a function that can be called from target instead of it in a constant update with Citizen.CreateThread(function().

Now in your target main or config where ever you set your target entities add:

local garbage = {
    164866,
    174594,
    279298
}
exports.qtarget:AddTargetEntity(garbage, {
    options = {
        {
            event = "player:OpenInventory",
            icon = "fas fa-box-circle-check",
            label = "Search",
            num = 1
        },
        {
            event = "garbage:Hide",
            icon = "fas fa-box-circle-check",
            label = "Hide",
            num = 2
        },
    },

    distance = 2
})

Hey, couldn’t understand at all, i’ve tried but can’t get it :frowning:

im falling forever when i place this in my qb-trashsearch until i hit E then i just fall till I land on ground somewhere, how is this fixed?

Remove lines.

SetEntityCoords(PlayerPedId(), GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -0.7, -0.75))
1 Like

Brilliant!

Couldn’t get it to work.