Skip to content

Commit

Permalink
Merge pull request #259 from AvarianKnight/dev
Browse files Browse the repository at this point in the history
Fix radio clicks
  • Loading branch information
AvarianKnight authored Jan 15, 2022
2 parents b14e1a9 + 63dbdf6 commit 59db956
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 14 deletions.
12 changes: 11 additions & 1 deletion client/init/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ AddEventHandler('onClientResourceStart', function(resource)
micClicks = 'true'
end
sendUIMessage({
uiEnabled = GetConvarInt("voice_enableUi", 1) == 1,
voiceModes = json.encode(Cfg.voiceModes),
voiceMode = mode - 1
}, true)
})

-- Reinitialize channels if they're set.
if LocalPlayer.state.radioChannel ~= 0 then
setRadioChannel(LocalPlayer.state.radioChannel)
end

if LocalPlayer.state.callChannel ~= 0 then
setCallChannel(LocalPlayer.state.callChannel)
end
print('Script initialization finished.')
end)
2 changes: 1 addition & 1 deletion client/module/phone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function setCallChannel(channel)
callChannel = channel
sendUIMessage({
callInfo = channel
}, true)
})
createPhoneThread()
end

Expand Down
2 changes: 1 addition & 1 deletion client/module/radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function setRadioChannel(channel)
sendUIMessage({
radioChannel = channel,
radioEnabled = radioEnabled
}, true)
})
end

--- exports setRadioChannel
Expand Down
3 changes: 1 addition & 2 deletions client/utils/Nui.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local uiReady = promise.new()
function sendUIMessage(message, respectConvar)
function sendUIMessage(message)
Citizen.Await(uiReady)
if respectConvar and GetConvarInt('voice_enableUi', 1) ~= 1 then return end
SendNUIMessage(message)
end

Expand Down
16 changes: 10 additions & 6 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ end

function handleStateBagInitilization(source)
local plyState = Player(source).state
plyState:set('radio', tonumber(GetConvar('voice_defaultRadioVolume', '0.3')), true)
plyState:set('phone', tonumber(GetConvar('voice_defaultPhoneVolume', '0.6')), true)
plyState:set('proximity', {}, true)
plyState:set('callChannel', 0, true)
plyState:set('radioChannel', 0, true)
plyState:set('voiceIntent', 'speech', true)
if not plyState.pmaVoiceInit then
plyState:set('radio', tonumber(GetConvar('voice_defaultRadioVolume', '0.3')), true)
plyState:set('phone', tonumber(GetConvar('voice_defaultPhoneVolume', '0.6')), true)
plyState:set('proximity', {}, true)
plyState:set('callChannel', 0, true)
plyState:set('radioChannel', 0, true)
plyState:set('voiceIntent', 'speech', true)
-- We want to save voice inits because we'll automatically reinitalize calls and channels
plyState:set('pmaVoiceInit', true, false)
end
end

-- temp fix before an actual fix is added
Expand Down
2 changes: 1 addition & 1 deletion ui/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 59db956

Please sign in to comment.