forked from AlterGamingNetwork/mellotrainer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcl_settings_voice.lua
153 lines (134 loc) · 3.54 KB
/
cl_settings_voice.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
--[[--------------------------------------------------------------------------
*
* Mello Trainer
* (C) Michael Goodwin 2017
* http://github.com/thestonedturtle/mellotrainer/releases
*
* This menu used the Scorpion Trainer as a framework to build off of.
* https://github.com/pongo1231/ScorpionTrainer
* (C) Emre Cürgül 2017
*
* A lot of useful functionality has been converted from the lambda menu.
* https://lambda.menu
* (C) Oui 2017
*
* Additional Contributors:
* WolfKnight (https://forum.fivem.net/u/WolfKnight)
*
---------------------------------------------------------------------------]]
-- Update voice feature variables
function updateVoiceDistanceVariables(distance)
featureVPTooClose = false
featureVPVeryClose = false
featureVPClose = false
featureVPNearby = false
featureVPDistant = false
featureVPFar = false
featureVPVeryFar = false
featureVPAllPlayers = false
if(distance == 0)then
featureVPAllPlayers = true;
elseif(distance == 5)then
featureVPTooClose = true
elseif(distance == 25)then
featureVPVeryClose = true
elseif(distance == 75)then
featureVPClose = true
elseif(distance == 200)then
featureVPNearby = true
elseif(distance == 500)then
featureVPDistant = true
elseif(distance == 2500)then
featureVPFar = true
elseif(distance == 8000)then
featureVPVeryFar = true
end
end
-- Update voice channel variables
function updateVoiceChannelVariables(channel)
featureChannelDefault = false;
featureChannel1 = false;
featureChannel2 = false;
featureChannel3 = false;
featureChannel4 = false;
featureChannel5 = false;
if(channel == 0)then
featureChannelDefault = true
else
_G["featureChannel"..tostring(channel)] = true
end
end
RegisterNUICallback("voiceopts", function(data, cb)
local playerPed = GetPlayerPed(-1)
local action = data.action
local state = data.newstate
local request = data.data[3]
local text,text2
if(state) then
text = "~g~ON"
text2 = "~r~OFF"
else
text = "~r~OFF"
text2 = "~g~ON"
end
if(action=="channel")then
if(request == "0" or request == 0)then
NetworkClearVoiceChannel()
drawNotification("Voice Channel reset")
else
NetworkSetVoiceChannel(tonumber(request))
drawNotification("Now In Voice Channel: "..request)
end
updateVoiceChannelVariables(request)
elseif(action=="distance")then
local distance = tonumber(request) + 0.00
NetworkSetTalkerProximity(distance)
updateVoiceDistanceVariables(distance)
if(distance > 0)then
drawNotification("Voice Proximity: "..distance.." meters")
else
drawNotification("Voice Proximity: All Players")
end
elseif(action=="voicetoggle")then
featureVoiceChat = state
NetworkSetVoiceActive(state)
drawNotification("Voice Chat: "..text)
elseif(action=="showtoggle")then
featureShowVoiceChatSpeaker = state
if(not state)then
SendNUIMessage({hidevoice=true})
end
drawNotification("Voice Speakers Overlay: "..text)
end
if(cb)then cb("ok") end
end)
-- Update voice names
Citizen.CreateThread(function()
local me = PlayerId(-1)
while true do
Citizen.Wait(0)
if(featureShowVoiceChatSpeaker)then
local names = {}
local nameCount = 0
for i=0, maxPlayers, 1 do
if(NetworkIsPlayerConnected(i)) then
if(NetworkIsPlayerTalking(i))then
table.insert(names, GetPlayerName(i))
nameCount = nameCount + 1
end
end
end
if(nameCount > 0)then
local results = json.encode(names, {indent=true})
SendNUIMessage({
showvoice = true,
talkingplayers = results
})
else
SendNUIMessage({
hidevoice = true
})
end
end
end
end)