-
Notifications
You must be signed in to change notification settings - Fork 61
/
client.lua
161 lines (144 loc) · 4.09 KB
/
client.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
-- Variables
local QBCore = exports['qb-core']:GetCoreObject()
local currentZone = nil
local PlayerData = {}
-- Handlers
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then return end
PlayerData = QBCore.Functions.GetPlayerData()
end)
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
PlayerData = QBCore.Functions.GetPlayerData()
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerData.job = JobInfo
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
PlayerData = {}
end)
-- Static Header
local musicHeader = {
{
header = 'Play some music!',
params = {
event = 'qb-djbooth:client:playMusic'
}
}
}
-- Main Menu
function createMusicMenu()
musicMenu = {
{
isHeader = true,
header = '💿 | DJ Booth'
},
{
header = '🎶 | Play a song',
txt = 'Enter a youtube URL',
params = {
event = 'qb-djbooth:client:musicMenu',
args = {
zoneName = currentZone
}
}
},
{
header = '⏸️ | Pause Music',
txt = 'Pause currently playing music',
params = {
isServer = true,
event = 'qb-djbooth:server:pauseMusic',
args = {
zoneName = currentZone
}
}
},
{
header = '▶️ | Resume Music',
txt = 'Resume playing paused music',
params = {
isServer = true,
event = 'qb-djbooth:server:resumeMusic',
args = {
zoneName = currentZone
}
}
},
{
header = '🔈 | Change Volume',
txt = 'Resume playing paused music',
params = {
event = 'qb-djbooth:client:changeVolume',
args = {
zoneName = currentZone
}
}
},
{
header = '❌ | Turn off music',
txt = 'Stop the music & choose a new song',
params = {
isServer = true,
event = 'qb-djbooth:server:stopMusic',
args = {
zoneName = currentZone
}
}
}
}
end
-- DJ Booths
local vanilla = BoxZone:Create(Config.Locations['vanilla'].coords, 1, 1, {
name="vanilla",
heading=0
})
vanilla:onPlayerInOut(function(isPointInside)
if isPointInside and PlayerData.job.name == Config.Locations['vanilla'].job then
currentZone = 'vanilla'
exports['qb-menu']:showHeader(musicHeader)
else
currentZone = nil
exports['qb-menu']:closeMenu()
end
end)
-- Events
RegisterNetEvent('qb-djbooth:client:playMusic', function()
createMusicMenu()
exports['qb-menu']:openMenu(musicMenu)
end)
RegisterNetEvent('qb-djbooth:client:musicMenu', function()
local dialog = exports['qb-input']:ShowInput({
header = 'Song Selection',
submitText = "Submit",
inputs = {
{
type = 'text',
isRequired = true,
name = 'song',
text = 'YouTube URL'
}
}
})
if dialog then
if not dialog.song then return end
TriggerServerEvent('qb-djbooth:server:playMusic', dialog.song, currentZone)
end
end)
RegisterNetEvent('qb-djbooth:client:changeVolume', function()
local dialog = exports['qb-input']:ShowInput({
header = 'Music Volume',
submitText = "Submit",
inputs = {
{
type = 'text', -- number doesn't accept decimals??
isRequired = true,
name = 'volume',
text = 'Min: 0.01 - Max: 1'
}
}
})
if dialog then
if not dialog.volume then return end
TriggerServerEvent('qb-djbooth:server:changeVolume', dialog.volume, currentZone)
end
end)