-
Notifications
You must be signed in to change notification settings - Fork 61
/
server.lua
70 lines (65 loc) · 2.6 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
local xSound = exports.xsound
RegisterNetEvent('qb-djbooth:server:playMusic', function(song, zoneName)
local src = source
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
local boothCoords = Config.Locations[zoneName].coords
local dist = #(coords - boothCoords)
if dist > 3 then return end
xSound:PlayUrlPos(-1, zoneName, song, Config.DefaultVolume, coords)
xSound:Distance(-1, zoneName, Config.Locations[zoneName].radius)
Config.Locations[zoneName].playing = true
TriggerClientEvent('qb-djbooth:client:playMusic', src)
end)
RegisterNetEvent('qb-djbooth:server:stopMusic', function(data)
local src = source
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
local boothCoords = Config.Locations[data.zoneName].coords
local dist = #(coords - boothCoords)
if dist > 3 then return end
if Config.Locations[data.zoneName].playing then
Config.Locations[data.zoneName].playing = false
xSound:Destroy(-1, data.zoneName)
end
TriggerClientEvent('qb-djbooth:client:playMusic', src)
end)
RegisterNetEvent('qb-djbooth:server:pauseMusic', function(data)
local src = source
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
local boothCoords = Config.Locations[data.zoneName].coords
local dist = #(coords - boothCoords)
if dist > 3 then return end
if Config.Locations[data.zoneName].playing then
Config.Locations[data.zoneName].playing = false
xSound:Pause(-1, data.zoneName)
end
TriggerClientEvent('qb-djbooth:client:playMusic', src)
end)
RegisterNetEvent('qb-djbooth:server:resumeMusic', function(data)
local src = source
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
local boothCoords = Config.Locations[data.zoneName].coords
local dist = #(coords - boothCoords)
if dist > 3 then return end
if not Config.Locations[data.zoneName].playing then
Config.Locations[data.zoneName].playing = true
xSound:Resume(-1, data.zoneName)
end
TriggerClientEvent('qb-djbooth:client:playMusic', src)
end)
RegisterNetEvent('qb-djbooth:server:changeVolume', function(volume, zoneName)
local src = source
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
local boothCoords = Config.Locations[zoneName].coords
local dist = #(coords - boothCoords)
if dist > 3 then return end
if not tonumber(volume) then return end
if Config.Locations[zoneName].playing then
xSound:setVolume(-1, zoneName, volume)
end
TriggerClientEvent('qb-djbooth:client:playMusic', src)
end)