Skip to content

Add generation of loot, add support for metadata.image #87

Merged
thelindat merged 4 commits into
overextended:mainfrom
OfficialNoms:main
May 24, 2021
Merged

Add generation of loot, add support for metadata.image #87
thelindat merged 4 commits into
overextended:mainfrom
OfficialNoms:main

Conversation

@OfficialNoms

@OfficialNoms OfficialNoms commented May 23, 2021

Copy link
Copy Markdown
Contributor

Preface that there are probably better ways of doing this - and you're more than welcome to tear it apart and putting it back together again properly.

This pull request does the following:

metadata.image

  • The inventory now pulls from <item>.metadata.image for its images to support custom images being set in metadata, such as broken or modified items.
  • If <item>.metadata.image isn't defined, set it to <item>.name

Glovebox, Trunk, Dumpster loot

  • Vehicles that are unowned and empty will (by config) generate loot based on data that exists within the shared items.lua file.
  • Dumpsters are a special kind of stash that generate trash and could have other random items generated in them - you can configure this in the Config and shared items.lua by using the following template:
	['my_loot_item'] = {
		trunkChance = 10, --10% chance of generating
		gloveboxChance = 5, --5% chance of generating
		dumpsterChance = 30, --30% chance of generating
		lootMin = 1, -- The minimum amount to spawn
		lootMax = 6, -- Tha maximum amount to spawn
	},
  • If no configs for random loot generation are set the item is just ignored
  • You can open a dumpster by calling exports['linden_inventory']:OpenDumpster({ name = 'Dumpster-'..dumpster, slots = 20}) where dumpster is the unique id of the dumpster you're near. A bt-target example of this is below.

dumpster.lua

Config = {}
Config.Dumpsters = {218085040, 666561306, -58485588, -206690185, 1511880420, 682791951}

Citizen.CreateThread(function()
    exports['bt-target']:AddTargetModel(Config.Dumpsters, {
        options = {
            {
                event = "qrp_dumpsters:openDumpster",
                icon = "fas fa-dumpster",
                label = "Search Dumpster",
            },
        },
        job = {"all"},
        distance = 2.5
    })
end)

RegisterNetEvent('qrp_dumpsters:openDumpster')
AddEventHandler('qrp_dumpsters:openDumpster', function()
    local ped = GetPlayerPed(-1)
    local pos = GetEntityCoords(ped)
    for i = 1, #Config.Dumpsters do 
        local dumpster = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, Config.Dumpsters[i], false, false, false)
        local dumpPos = GetEntityCoords(dumpster)
        local dist = #(pos - dumpPos)
        if dist < 2.5 then 
            exports['linden_inventory']:OpenDumpster({ name = 'Dumpster-'..dumpster, slots = 20})
        end
    end 
end)```

Noms added 4 commits May 23, 2021 22:34
• use `exports['linden_inventory']:OpenDumpster({ name = 'Dumpster-'..dumpster, slots = 20})` where `dumpster` is your unique dumpster model id
@thelindat thelindat merged commit d81c447 into overextended:main May 24, 2021
thelindat pushed a commit that referenced this pull request Apr 22, 2026
* feat(client): export based setting for altering the getPlayerName method

* tweak(utils/client): removed useless luadoc inject-field rule disable
thelindat pushed a commit that referenced this pull request Apr 24, 2026
* feat(client): export based setting for altering the getPlayerName method

* tweak(utils/client): removed useless luadoc inject-field rule disable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants