144 lines
4.2 KiB
Lua
144 lines
4.2 KiB
Lua
RegisterCommand('houseMenu', function()
|
|
if IsNuiFocused() then return end
|
|
if decorate.active then return end
|
|
if not CurrentHouse then return end
|
|
local house = Config.Houses[CurrentHouse]
|
|
if house.apartmentNumber and not EnteredHouse then
|
|
OpenMyApartments()
|
|
return
|
|
end
|
|
if not CurrentHouseData.haskey and not CurrentHouseData.isOfficialOwner then return Notification(i18n.t('not_have_keys'), 'error') end
|
|
management:open(house)
|
|
end, false)
|
|
|
|
RegisterKeyMapping('houseMenu', 'House Menu', 'keyboard', Config.OpenHouseMenu)
|
|
|
|
RegisterNetEvent('housing:onExitHouse', function(house)
|
|
if house then
|
|
DestroyHouseSound(house)
|
|
end
|
|
end)
|
|
|
|
function DoRamAnimation(bool)
|
|
local ped = cache.ped
|
|
local dict = 'missheistfbi3b_ig7'
|
|
local anim = 'lift_fibagent_loop'
|
|
|
|
if bool then
|
|
lib.requestAnimDict(dict)
|
|
TaskPlayAnim(ped, dict, anim, 8.0, 8.0, -1, 1, -1, false, false, false)
|
|
RemoveAnimDict(dict)
|
|
else
|
|
lib.requestAnimDict(dict)
|
|
TaskPlayAnim(ped, dict, 'exit', 8.0, 8.0, -1, 1, -1, false, false, false)
|
|
RemoveAnimDict(dict)
|
|
end
|
|
end
|
|
|
|
HouseSoundPlaying = false
|
|
HouseSoundVolume = 0.5
|
|
HouseSoundUrl = ''
|
|
|
|
---@param house string
|
|
---@param link string
|
|
---@param volume? number
|
|
function PlayHouseSound(house, link, volume)
|
|
if not link or link == '' then
|
|
return
|
|
end
|
|
|
|
if HouseSoundPlaying then
|
|
DestroyHouseSound(house)
|
|
end
|
|
|
|
local houseData = Config.Houses[house]
|
|
|
|
local soundCoords = nil
|
|
if houseData.coords.shellCoords then
|
|
-- Shell house
|
|
soundCoords = vec3(houseData.coords.shellCoords.x, houseData.coords.shellCoords.y, houseData.coords.shellCoords.z)
|
|
elseif houseData.ipl and houseData.ipl.houseName then
|
|
-- IPL house
|
|
local iplData = Config.IplData[houseData.ipl.houseName]
|
|
if iplData and iplData.iplCoords then
|
|
soundCoords = vec3(iplData.iplCoords.x, iplData.iplCoords.y, iplData.iplCoords.z)
|
|
end
|
|
elseif houseData.coords.test then
|
|
-- MLO house
|
|
soundCoords = vec3(houseData.coords.test.x, houseData.coords.test.y, houseData.coords.test.z)
|
|
end
|
|
|
|
if not soundCoords then
|
|
return
|
|
end
|
|
|
|
local baseVolume = volume or 0.5
|
|
HouseSoundVolume = baseVolume
|
|
HouseSoundUrl = link
|
|
|
|
if GetResourceState('mx-surround'):find('started') then
|
|
HouseSoundPlaying = true
|
|
exports['mx-surround']:Play('house', link, soundCoords, true)
|
|
exports['mx-surround']:setVolumeMax('house', baseVolume)
|
|
return
|
|
end
|
|
if GetResourceState('qs-3dsound'):find('started') then
|
|
HouseSoundPlaying = true
|
|
exports['qs-3dsound']:Play('house', link, soundCoords, true)
|
|
exports['qs-3dsound']:setVolumeMax('house', baseVolume)
|
|
return
|
|
end
|
|
|
|
if GetResourceState('xsound'):find('started') then
|
|
HouseSoundPlaying = true
|
|
exports['xsound']:PlayUrlPos('house', link, baseVolume, soundCoords, true)
|
|
exports['xsound']:Distance('house', 50.0)
|
|
return
|
|
end
|
|
end
|
|
|
|
---@param house string
|
|
function DestroyHouseSound(house)
|
|
if not EnteredHouse or EnteredHouse ~= house then
|
|
Debug('DestroyHouseSound ::: Not Entered House, destroying anyway')
|
|
end
|
|
|
|
HouseSoundPlaying = false
|
|
HouseSoundUrl = ''
|
|
|
|
if GetResourceState('mx-surround'):find('started') then
|
|
exports['mx-surround']:Destroy('house')
|
|
end
|
|
if GetResourceState('qs-3dsound'):find('started') then
|
|
exports['qs-3dsound']:Destroy('house')
|
|
end
|
|
|
|
if GetResourceState('xsound'):find('started') then
|
|
exports['xsound']:Destroy('house')
|
|
end
|
|
end
|
|
|
|
---@param house string
|
|
---@param volume number
|
|
function UpdateHouseSoundVolume(house, volume)
|
|
if not HouseSoundPlaying then
|
|
return
|
|
end
|
|
|
|
HouseSoundVolume = volume or HouseSoundVolume
|
|
|
|
if GetResourceState('mx-surround'):find('started') then
|
|
exports['mx-surround']:setVolumeMax('house', HouseSoundVolume)
|
|
return
|
|
end
|
|
if GetResourceState('qs-3dsound'):find('started') then
|
|
exports['qs-3dsound']:setVolumeMax('house', HouseSoundVolume)
|
|
return
|
|
end
|
|
|
|
if GetResourceState('xsound'):find('started') then
|
|
exports['xsound']:setVolumeMax('house', HouseSoundVolume)
|
|
return
|
|
end
|
|
end
|