├── LICENSE ├── README.md ├── client └── client.lua ├── config.lua ├── fxmanifest.lua └── server.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Thedoc Scripts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Thedoc-Bins (stash) | qb-core 2 | ![This is an image](https://cdn.discordapp.com/attachments/841430505609756682/960461152943484938/th-bins.png) 3 | 4 | ## Dependencies 5 | * **[qb-core](https://github.com/qbcore-framework/qb-core)** 6 | 7 | 8 | ## Optional 9 | * **[qb-target](https://github.com/BerkieBb/qb-target/)** 10 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | local closetobin = false 3 | 4 | CreateThread(function() 5 | if Config.UseQBTarget then 6 | exports['qb-target']:AddTargetModel(Config.Bins, { 7 | options = { 8 | { 9 | type = "client", 10 | event = "qb-client:targetbin", 11 | icon = "fas fa-trash", 12 | label = Config.Text, 13 | }, 14 | }, 15 | distance = 2.5 16 | }) 17 | end 18 | end) 19 | 20 | CreateThread(function() 21 | if not Config.UseQBTarget then 22 | while true do 23 | local sleep = 1250 24 | local closestobj = GetClosestBin() 25 | local objpos = GetEntityCoords(closestobj) 26 | if closestobj ~= nil then 27 | if not closetobin then 28 | DisplayBin(objpos, closestobj) 29 | closetobin = true 30 | end 31 | else 32 | closetobin = false 33 | end 34 | Wait(sleep) 35 | end 36 | end 37 | end) 38 | 39 | RegisterNetEvent('qb-client:targetbin', function() 40 | local targetobj = GetClosestBin() 41 | if targetobj ~= nil then 42 | StashBin(targetobj) 43 | end 44 | end) 45 | 46 | function GetClosestBin() 47 | local ped = PlayerPedId() 48 | local pos = GetEntityCoords(ped) 49 | local object = nil 50 | for _, bins in pairs(Config.Bins) do 51 | local ClosestObject = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, GetHashKey(bins), 0, 0, 0) 52 | if ClosestObject ~= 0 then 53 | if object == nil then 54 | object = ClosestObject 55 | end 56 | end 57 | end 58 | return object 59 | end 60 | 61 | function DisplayBin(objpos, closestobj) 62 | CreateThread(function() 63 | while closetobin do 64 | QBCore.Functions.DrawText3D(objpos.x, objpos.y, objpos.z + 1, "~b~[E]~w~ - " ..Config.Text) 65 | if IsControlJustPressed(0, 38) then 66 | StashBin(closestobj) 67 | end 68 | Wait(5) 69 | end 70 | end) 71 | end 72 | 73 | function StashBin(obj) 74 | TriggerServerEvent("inventory:server:OpenInventory", "stash", "bin" .. tostring(obj), { 75 | maxweight = Config.Binmaxweight, 76 | slots = Config.Binslots, 77 | }) 78 | TriggerEvent("inventory:client:SetCurrentStash", "bin" .. tostring(obj)) 79 | end 80 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.Text = "Bin" 4 | Config.Binmaxweight = 4000000 5 | Config.Binslots = 300 6 | Config.UseQBTarget = false 7 | Config.AutoDelete = true 8 | 9 | Config.Bins = { 10 | "prop_bin_05a", 11 | "prop_bin_08a", 12 | "prop_bin_01a", 13 | "prop_cs_bin_03", 14 | "prop_cs_bin_01", 15 | "prop_cs_bin_02", 16 | "prop_cs_bin_01_skinned", 17 | "prop_bin_07b", 18 | "prop_recyclebin_03_a", 19 | "prop_bin_14a", 20 | "prop_bin_11b", 21 | "prop_bin_11a", 22 | "prop_bin_07d", 23 | "prop_bin_06a", 24 | "prop_bin_04a", 25 | "prop_bin_02a", 26 | "prop_bin_08a", 27 | "prop_bin_07a", 28 | "prop_bin_05a", 29 | "prop_cs_dumpster_01a", 30 | "p_dumpster_t", 31 | "prop_dumpster_4b", 32 | "prop_dumpster_4a", 33 | "prop_dumpster_3a", 34 | "prop_dumpster_01a", 35 | "prop_dumpster_02b", 36 | "prop_dumpster_02a" 37 | } 38 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | games {'gta5'} 3 | author 'thedoc' 4 | 5 | shared_script 'config.lua' 6 | client_script 'client/client.lua' 7 | server_scripts { 8 | '@oxmysql/lib/MySQL.lua', 9 | 'server.lua' 10 | } 11 | -------------------------------------------------------------------------------- /server.lua: -------------------------------------------------------------------------------- 1 | AddEventHandler('onResourceStart', function(resource) 2 | if resource == GetCurrentResourceName() then 3 | if Config.AutoDelete then 4 | MySQL.Async.execute('DELETE FROM stashitems WHERE stash like "%bin%"', {}) 5 | end 6 | end 7 | end) 8 | --------------------------------------------------------------------------------