diff --git a/resources/[inventory]/shisha/client.lua b/resources/[inventory]/shisha/client.lua index 48b933559..6c9806844 100644 --- a/resources/[inventory]/shisha/client.lua +++ b/resources/[inventory]/shisha/client.lua @@ -163,14 +163,14 @@ AddEventHandler("chema_shisha:Drag", function() local VapeFailure = math.random(1,99999) if VapeFailure == 1 then TaskPlayAnim(ped, ad, anim, 8.00, -8.00, -1, (2 + 16 + 32), 0.00, 0, 0, 0) - PlaySoundFrontend(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1) + TriggerServerEvent('InteractSound_SV:PlayOnSource', 'shisha_bubbling', 0.5) Wait(250) AddExplosion(PedPos.x, PedPos.y, PedPos.z+1.00, 34, 0.00, true, false, 1.00) ApplyDamageToPed(ped, 200, false) TriggerServerEvent("Vape:Failure", 0) else TaskPlayAnim(ped, ad, anim, 8.00, -8.00, -1, (2 + 16 + 32), 0.00, 0, 0, 0) - PlaySoundFrontend(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1) + TriggerServerEvent('InteractSound_SV:PlayOnSource', 'shisha_bubbling', 0.5) Wait(950) TriggerServerEvent("eff_smokes", PedToNet(ped)) Wait(1000) @@ -236,3 +236,28 @@ function DrawText3D(coords, text, size) DrawText(x, y) end end + +RegisterNetEvent("chema_shisha:deleteAll") +AddEventHandler("chema_shisha:deleteAll", function() + -- Delete all shishas in the area + for i = 1, #shisha do + local objectHash = shisha[i] + local radius = 100.0 -- Search in a 100.0 radius around the player + + local ped = PlayerPedId() + local pos = GetEntityCoords(ped) + + -- Find all objects of this type + local shishaObj = GetClosestObjectOfType(pos.x, pos.y, pos.z, radius, objectHash, false, false, false) + while DoesEntityExist(shishaObj) do + DeleteObject(shishaObj) + -- Look for the next one + shishaObj = GetClosestObjectOfType(pos.x, pos.y, pos.z, radius, objectHash, false, false, false) + end + end + + -- Also delete any mobile hookahs that might be out + if DoesEntityExist(mobilehooka) then + DeleteObject(mobilehooka) + end +end) diff --git a/resources/[inventory]/shisha/fxmanifest.lua b/resources/[inventory]/shisha/fxmanifest.lua index 0a4a070b7..2d0580413 100644 --- a/resources/[inventory]/shisha/fxmanifest.lua +++ b/resources/[inventory]/shisha/fxmanifest.lua @@ -12,3 +12,7 @@ client_scripts { server_scripts { 'server.lua', } + +dependencies { + 'interact-sound' +} diff --git a/resources/[inventory]/shisha/server.lua b/resources/[inventory]/shisha/server.lua index d9b899bf2..42bd0b1ee 100644 --- a/resources/[inventory]/shisha/server.lua +++ b/resources/[inventory]/shisha/server.lua @@ -21,3 +21,14 @@ QBCore.Commands.Add("deleteshisha", "Lösche deine Shisha und bekomme sie zurüc Player.Functions.AddItem("shisha", 1) TriggerClientEvent('QBCore:Notify', source, 'Shisha entfernt und ins Inventar zurückgelegt', 'success') end) + +QBCore.Commands.Add("deleteallshishas", "Delete all placed shishas on the server (Admin Only)", {}, true, function(source) + local Player = QBCore.Functions.GetPlayer(source) + + if Player.PlayerData.permission == "admin" or Player.PlayerData.permission == "god" then + TriggerClientEvent("chema_shisha:deleteAll", -1) + TriggerClientEvent('QBCore:Notify', source, 'All shishas have been deleted', 'success') + else + TriggerClientEvent('QBCore:Notify', source, 'You do not have permission to use this command', 'error') + end +end) diff --git a/resources/[tools]/interact-sound/LICENSE b/resources/[tools]/interact-sound/LICENSE new file mode 100644 index 000000000..11eaedb78 --- /dev/null +++ b/resources/[tools]/interact-sound/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Scott Plunkett + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/resources/[tools]/interact-sound/README.md b/resources/[tools]/interact-sound/README.md new file mode 100644 index 000000000..adb8d1498 --- /dev/null +++ b/resources/[tools]/interact-sound/README.md @@ -0,0 +1,3 @@ +# Interact Sound + +Play sounds using the NUI environment in FiveM's FXServer. diff --git a/resources/[tools]/interact-sound/client/html/index.html b/resources/[tools]/interact-sound/client/html/index.html new file mode 100644 index 000000000..457ee9ba6 --- /dev/null +++ b/resources/[tools]/interact-sound/client/html/index.html @@ -0,0 +1,25 @@ + +
+ + + + + + diff --git a/resources/[tools]/interact-sound/client/html/sounds/shisha_bubbling.ogg b/resources/[tools]/interact-sound/client/html/sounds/shisha_bubbling.ogg new file mode 100644 index 000000000..ebfa82c20 Binary files /dev/null and b/resources/[tools]/interact-sound/client/html/sounds/shisha_bubbling.ogg differ diff --git a/resources/[tools]/interact-sound/client/main.lua b/resources/[tools]/interact-sound/client/main.lua new file mode 100644 index 000000000..666dd0f89 --- /dev/null +++ b/resources/[tools]/interact-sound/client/main.lua @@ -0,0 +1,92 @@ + +------ +-- InteractionSound by Scott +-- Version: v0.0.1 +-- Path: client/main.lua +-- +-- Allows sounds to be played on single clients, all clients, or all clients within +-- a specific range from the entity to which the sound has been created. +------ + +local standardVolumeOutput = 0.3; +local hasPlayerLoaded = false +Citizen.CreateThread(function() + Wait(15000) + hasPlayerLoaded = true +end) +------ +-- RegisterNetEvent LIFE_CL:Sound:PlayOnOne +-- +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- +-- Starts playing a sound locally on a single client. +------ +RegisterNetEvent('InteractSound_CL:PlayOnOne') +AddEventHandler('InteractSound_CL:PlayOnOne', function(soundFile, soundVolume) + if hasPlayerLoaded then + SendNUIMessage({ + transactionType = 'playSound', + transactionFile = soundFile, + transactionVolume = soundVolume + }) + end +end) + +------ +-- RegisterNetEvent LIFE_CL:Sound:PlayOnAll +-- +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- +-- Starts playing a sound on all clients who are online in the server. +------ +RegisterNetEvent('InteractSound_CL:PlayOnAll') +AddEventHandler('InteractSound_CL:PlayOnAll', function(soundFile, soundVolume) + if hasPlayerLoaded then + SendNUIMessage({ + transactionType = 'playSound', + transactionFile = soundFile, + transactionVolume = soundVolume or standardVolumeOutput + }) + end +end) + +------ +-- RegisterNetEvent LIFE_CL:Sound:PlayWithinDistance +-- +-- @param playOnEntity - The entity network id (will be converted from net id to entity on client) +-- - of the entity for which the max distance is to be drawn from. +-- @param maxDistance - The maximum float distance (client uses Vdist) to allow the player to +-- - hear the soundFile being played. +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- +-- Starts playing a sound on a client if the client is within the specificed maxDistance from the playOnEntity. +-- @TODO Change sound volume based on the distance the player is away from the playOnEntity. +------ +RegisterNetEvent('InteractSound_CL:PlayWithinDistance') +AddEventHandler('InteractSound_CL:PlayWithinDistance', function(otherPlayerCoords, maxDistance, soundFile, soundVolume) + if hasPlayerLoaded then + local myCoords = GetEntityCoords(PlayerPedId()) + local distance = #(myCoords - otherPlayerCoords) + + if distance < maxDistance then + SendNUIMessage({ + transactionType = 'playSound', + transactionFile = soundFile, + transactionVolume = soundVolume or standardVolumeOutput + }) + end + end +end) + diff --git a/resources/[tools]/interact-sound/fxmanifest.lua b/resources/[tools]/interact-sound/fxmanifest.lua new file mode 100644 index 000000000..1a347ec01 --- /dev/null +++ b/resources/[tools]/interact-sound/fxmanifest.lua @@ -0,0 +1,22 @@ +-- FXVersion Version +fx_version 'adamant' +games {"rdr3","gta5"} +rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' + +-- Client Scripts +client_script 'client/main.lua' + +-- Server Scripts +server_script 'server/main.lua' + +-- NUI Default Page +ui_page "client/html/index.html" + +-- Files needed for NUI +-- DON'T FORGET TO ADD THE SOUND FILES TO THIS! +files { + 'client/html/index.html', + -- Begin Sound Files Here... + -- client/html/sounds/ ... .ogg + 'client/html/sounds/demo.ogg' +} diff --git a/resources/[tools]/interact-sound/server/main.lua b/resources/[tools]/interact-sound/server/main.lua new file mode 100644 index 000000000..e057e9d27 --- /dev/null +++ b/resources/[tools]/interact-sound/server/main.lua @@ -0,0 +1,102 @@ + +------ +-- Interaction Sounds by Scott +-- Version: v0.0.1 +-- Path: server/main.lua +-- +-- Allows sounds to be played on single clients, all clients, or all clients within +-- a specific range from the entity to which the sound has been created. Triggers +-- client events only. Used to trigger sounds on other clients from the client or +-- server without having to pass directly to another client. +------ + +------ +-- RegisterServerEvent InteractSound_SV:PlayOnOne +-- Triggers -> ClientEvent InteractSound_CL:PlayOnOne +-- +-- @param clientNetId - The network id of the client that the sound should be played on. +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- - Can also specify a folder/sound file. +-- +-- Starts playing a sound locally on a single client. +------ +RegisterNetEvent('InteractSound_SV:PlayOnOne') +AddEventHandler('InteractSound_SV:PlayOnOne', function(clientNetId, soundFile, soundVolume) + TriggerClientEvent('InteractSound_CL:PlayOnOne', clientNetId, soundFile, soundVolume) +end) + +------ +-- RegisterServerEvent InteractSound_SV:PlayOnSource +-- Triggers -> ClientEvent InteractSound_CL:PlayOnSource +-- +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- - Can also specify a folder/sound file. +-- +-- Starts playing a sound locally on a single client, which is the source of the event. +------ +RegisterNetEvent('InteractSound_SV:PlayOnSource') +AddEventHandler('InteractSound_SV:PlayOnSource', function(soundFile, soundVolume) + TriggerClientEvent('InteractSound_CL:PlayOnOne', source, soundFile, soundVolume) +end) + +------ +-- RegisterServerEvent InteractSound_SV:PlayOnAll +-- Triggers -> ClientEvent InteractSound_CL:PlayOnAll +-- +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- +-- Starts playing a sound on all clients who are online in the server. +------ +RegisterNetEvent('InteractSound_SV:PlayOnAll') +AddEventHandler('InteractSound_SV:PlayOnAll', function(soundFile, soundVolume) + TriggerClientEvent('InteractSound_CL:PlayOnAll', -1, soundFile, soundVolume) +end) + +------ +-- RegisterServerEvent InteractSound_SV:PlayWithinDistance +-- Triggers -> ClientEvent InteractSound_CL:PlayWithinDistance +-- +-- @param playOnEntity - The entity network id (will be converted from net id to entity on client) +-- - of the entity for which the max distance is to be drawn from. +-- @param maxDistance - The maximum float distance (client uses Vdist) to allow the player to +-- - hear the soundFile being played. +-- @param soundFile - The name of the soundfile within the client/html/sounds/ folder. +-- - Can also specify a folder/sound file. +-- @param soundVolume - The volume at which the soundFile should be played. Nil or don't +-- - provide it for the default of standardVolumeOutput. Should be between +-- - 0.1 to 1.0. +-- +-- Starts playing a sound on a client if the client is within the specificed maxDistance from the playOnEntity. +-- @TODO Change sound volume based on the distance the player is away from the playOnEntity. +------ +RegisterNetEvent('InteractSound_SV:PlayWithinDistance') +AddEventHandler('InteractSound_SV:PlayWithinDistance', function(maxDistance, soundFile, soundVolume) + if GetConvar("onesync_enableInfinity", "false") == "true" then + TriggerClientEvent('InteractSound_CL:PlayWithinDistanceOS', -1, GetEntityCoords(GetPlayerPed(source)), maxDistance, soundFile, soundVolume) + else + TriggerClientEvent('InteractSound_CL:PlayWithinDistance', -1, source, maxDistance, soundFile, soundVolume) + end +end) + +RegisterNetEvent('InteractSound_SV:PlayWithinDistance') +AddEventHandler('InteractSound_SV:PlayWithinDistance', function(maxDistance, soundFile, soundVolume) + local src = source + local DistanceLimit = 300 + if maxDistance < DistanceLimit then + TriggerClientEvent('InteractSound_CL:PlayWithinDistance', -1, GetEntityCoords(GetPlayerPed(src)), maxDistance, soundFile, soundVolume) + else + print(('[interact-sound] [^3WARNING^7] %s attempted to trigger InteractSound_SV:PlayWithinDistance over the distance limit ' .. DistanceLimit):format(GetPlayerName(src))) + end +end)