Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hotkeys for radio. #50

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local RadioVolume = 50
local hasRadio = false
local radioProp = nil

local keybindControls = {
["`"] = 243, ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

--Function
local function LoadAnimDic(dict)
if not HasAnimDictLoaded(dict) then
Expand Down Expand Up @@ -145,6 +149,13 @@ RegisterNetEvent('qb-radio:onRadioDrop', function()
end
end)

Citizen.CreateThread(function()
local OpenRadioBind = Config.keyBind.useRadio
if IsControlPressed(1, keybindControls[OpenRadioBind]) then
TriggerEvent('qb-radio:use')
end
end)

-- NUI
RegisterNUICallback('joinRadio', function(data, cb)
local rchannel = tonumber(data.channel)
Expand Down Expand Up @@ -220,6 +231,13 @@ RegisterNUICallback("decreaseradiochannel", function(_, cb)
end
end)

RegisterCommand('openradio', function()
TriggerEvent('qb-radio:use')
end)
RegisterKeyMapping('openradio', 'Open Radio', 'keyboard', Config.keyBind.openRadio)
RegisterKeyMapping('Volup1', 'Turn Radio Up', 'keyboard', Config.keyBind.volUp1)
RegisterKeyMapping('Radiovoldown', 'Turn Radio Down', 'keyboard', Config.keyBind.radioVolDown)

RegisterNUICallback('poweredOff', function(_, cb)
leaveradio()
cb("ok")
Expand Down
9 changes: 8 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Config = {}

Config.keyBind = {
useRadio = "ENTER",
openRadio = "F7",
volUp1 = "PAGEUP",
radioVolDown = "PAGEDOWN"
}

Config.RestrictedChannels = {
[1] = {
police = true,
Expand Down Expand Up @@ -43,4 +50,4 @@ Config.RestrictedChannels = {
}
}

Config.MaxFrequency = 500
Config.MaxFrequency = 300
Loading