116 lines
		
	
	
	
		
			4 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
	
		
			4 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| local Webhooks = {
 | |
|     create = 'YOUR-WEBHOOK',  -- help: https://docs.brutalscripts.com/site/others/discord-webhook
 | |
|     delete = 'YOUR-WEBHOOK',
 | |
|     purchase = 'YOUR-WEBHOOK',
 | |
|     rent = 'YOUR-WEBHOOK',
 | |
|     ownerchange = 'YOUR-WEBHOOK',
 | |
| }
 | |
| 
 | |
| function GetWebhook()
 | |
|     return Webhooks
 | |
| end
 | |
| 
 | |
| RESCB("brutal_housing:server:GetDressing",function(source,cb)
 | |
|     local src = source
 | |
|     local dressingTable = {}
 | |
|     local dataArrived = false
 | |
| 
 | |
|     if Config['Core']:upper() == 'ESX' then
 | |
|         TriggerEvent('esx_datastore:getDataStore', 'property', GetIdentifier(src), function(store)
 | |
|             local dressings = store.get('dressing') or {}
 | |
|         
 | |
|             for k,v in pairs(dressings) do
 | |
|                 table.insert(dressingTable, {label = v.label, skin = v.skin})
 | |
|             end
 | |
|         end)
 | |
|         dataArrived = true
 | |
|     elseif Config['Core']:upper() == 'QBCORE' then
 | |
|         local results = MySQL.query.await('SELECT * FROM player_outfits WHERE citizenid = ?', { GetIdentifier(src) })
 | |
|         for k, v in pairs(results) do
 | |
|             table.insert(dressingTable, {label = v.outfitname ~= "" and v.outfitname or "None", skin = results[k].skin, model = v.model})
 | |
|         end
 | |
|         dataArrived = true
 | |
|     end
 | |
| 
 | |
|     while not dataArrived do
 | |
|         Citizen.Wait(10)
 | |
|     end
 | |
| 
 | |
|     cb(dressingTable)
 | |
| end)
 | |
| 
 | |
| RegisterNetEvent("brutal_housing:server:qbcore-loadPlayerSkin")
 | |
| AddEventHandler("brutal_housing:server:qbcore-loadPlayerSkin", function(model, skin)
 | |
|     local src = source
 | |
| 
 | |
|     if model ~= nil and skin ~= nil then
 | |
|         MySQL.query('DELETE FROM playerskins WHERE citizenid = ?', { GetIdentifier(src) }, function()
 | |
|             MySQL.insert('INSERT INTO playerskins (citizenid, model, skin, active) VALUES (?, ?, ?, ?)', {
 | |
|                 GetIdentifier(src),
 | |
|                 model,
 | |
|                 skin,
 | |
|                 1
 | |
|             })
 | |
|         end)
 | |
|     end
 | |
| end)
 | |
| 
 | |
| function StaffCheck(source)
 | |
|     local staff = false
 | |
| 
 | |
|     if Config.Core:upper() == 'ESX'then
 | |
|         local player = Core.GetPlayerFromId(source)
 | |
|         local playerGroup = player.getGroup()
 | |
| 
 | |
|         for i, Group in ipairs(Config.AdminGroups) do
 | |
|             if playerGroup == Group then
 | |
|                 staff = true
 | |
|                 break
 | |
|             end
 | |
|         end
 | |
|     elseif Config.Core:upper() == 'QBCORE' then
 | |
| 
 | |
|         for i, Group in ipairs(Config.AdminGroups) do
 | |
|             if Core.Functions.HasPermission(source, Group) or IsPlayerAceAllowed(source, Group) or IsPlayerAceAllowed(source, 'command') then
 | |
|                 staff = true
 | |
|                 break
 | |
|             end
 | |
|         end
 | |
|     end
 | |
| 
 | |
|     return staff
 | |
| end
 | |
| 
 | |
| RegisterNetEvent("brutal_housing:qb-inventory:server:OpenInventory", function(job, data)
 | |
|     local src = source
 | |
|     
 | |
|     -- Check if job contains both type and ID (like "stash_H104_17548482891")
 | |
|     if string.find(job, "stash_") then
 | |
|         -- Extract the actual stash ID by removing "stash_" prefix
 | |
|         local stashId = string.gsub(job, "stash_", "")
 | |
|         
 | |
|         -- Open the inventory with proper parameters
 | |
|         exports["tgiann-inventory"]:OpenInventory(src, "stash", stashId, {
 | |
|             maxWeight = data.weight or 10000,
 | |
|             slots = data.slots or 50,
 | |
|             label = data.label or "Housing Stash " .. stashId
 | |
|         })
 | |
|     -- Handle trunk inventories
 | |
|     elseif string.find(job, "trunk_") then
 | |
|         local plate = string.gsub(job, "trunk_", "")
 | |
|         exports["tgiann-inventory"]:OpenInventory(src, "trunk", plate)
 | |
|     -- Handle glovebox inventories
 | |
|     elseif string.find(job, "glovebox_") then
 | |
|         local plate = string.gsub(job, "glovebox_", "")
 | |
|         exports["tgiann-inventory"]:OpenInventory(src, "glovebox", plate)
 | |
|     -- Handle regular inventory types
 | |
|     elseif job == "stash" or job == "trunk" or job == "glovebox" then
 | |
|         -- For cases where job and data are properly separated
 | |
|         local invId = tostring(data)
 | |
|         exports["tgiann-inventory"]:OpenInventory(src, job, invId)
 | |
|     else
 | |
|         -- Log error for truly unsupported inventory types
 | |
|         print("Truly unsupported inventory type: " .. job)
 | |
|     end
 | |
| end)
 | |
| 
 | 
