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

feat: Toggleable mic clicks #23

Merged
merged 4 commits into from
Feb 7, 2024
Merged
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
13 changes: 13 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local onRadio = false
local radioChannel = 0
local radioVolume = 50
local hasRadio = false
local micClicks = true

local function connectToRadio(channel)
radioChannel = channel
Expand Down Expand Up @@ -172,6 +173,18 @@ RegisterNUICallback('decreaseradiochannel', function(_, cb)
cb('ok')
end)

RegisterNUICallback('toggleClicks', function(_, cb)
micClicks = not micClicks
exports['pma-voice']:setVoiceProperty("micClicks", micClicks)
qbx.playAudio({
audioName = "Off_High",
audioRef = 'MP_RADIO_SFX',
source = cache.ped
})
exports.qbx_core:Notify(locale('clicks'..(micClicks and 'On' or 'Off')), micClicks and 'success' or 'error')
cb('ok')
end)

RegisterNUICallback('poweredOff', function(_, cb)
leaveradio()
cb('ok')
Expand Down
14 changes: 14 additions & 0 deletions html/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ body {
user-select: none;
}

#toggleClicks {
position: absolute;
width: 4vh;
height: 3.5vh;
bottom: 37.5vh;
border-radius: 5px;
transition: all 0.1s linear;
left: 7.5vh;
}

#toggleClicks:hover {
background: rgba(255, 255, 255, 0.25);
}

#submit {
position: absolute;
width: 2.2vh;
Expand Down
7 changes: 7 additions & 0 deletions html/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ $(function() {

QBRadio = {}

document.getElementById('toggleClicks').addEventListener('click', function (e) {
e.preventDefault();
fetch(`https://${GetParentResourceName()}/toggleClicks`, {
method: 'POST',
});
});

$(document).on('click', '#submit', function(e){
e.preventDefault();

Expand Down
1 change: 1 addition & 0 deletions html/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div class="radio-container">
<img src="./img/radio.png" alt="" class="radio">

<div id="toggleClicks"></div>
<div class="channel">
<input id="channel" type="number" name="channel" min="1" max="500" placeholder="1-500">
</div>
Expand Down
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"min_volume": "The radio is already set to the lowest volume",
"max_volume": "he radio is already set to maximum volume",
"new_volume": "New volume: ",
"new_channel": "New channel: "
"new_channel": "New channel: ",
"clicksOn": "Mic clicks are now on",
"clicksOff": "Mic clicks are now off"
}
4 changes: 3 additions & 1 deletion locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"min_volume": "Cette radio est déjà au volume minimum",
"max_volume": "Cette radio est déjà au volume maximum",
"new_volume": "Nouveau volume : ",
"new_channel": "Nouvelle fréquence : "
"new_channel": "Nouvelle fréquence : ",
"clicksOn": "Clicks radio activés",
"clicksOff": "Clicks radio désactivés"
}
Loading