Skip to content

Commit aa4abf0

Browse files
committed
Follow mbiddle great idea of replacing round functions with qbcore ones
1 parent d548e14 commit aa4abf0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

client.lua

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ local function SplitStr(inputstr, sep)
2828
return t
2929
end
3030

31-
function round(number, decimalPlaces)
32-
local multiple = 10^(decimalPlaces or 0)
33-
return math.floor(number * multiple + 0.5) / multiple
34-
end
35-
3631
local function connecttoradio(channel)
3732
if channel > Config.MaxFrequency or channel <= 0 then QBCore.Functions.Notify(Lang:t('restricted_channel_error'), 'error') return false end
3833
if Config.RestrictedChannels[channel] ~= nil then
@@ -160,7 +155,7 @@ end)
160155

161156
-- NUI
162157
RegisterNUICallback('joinRadio', function(data, cb)
163-
local rchannel = round(tonumber(data.channel), 2)
158+
local rchannel = QBCore.Shared.Round(tonumber(data.channel), 2)
164159
if rchannel ~= nil then
165160
if rchannel <= Config.MaxFrequency and rchannel > 0 then
166161
if rchannel ~= RadioChannel then
@@ -219,7 +214,7 @@ end)
219214

220215
RegisterNUICallback("increaseradiochannel", function(_, cb)
221216
if not onRadio then return end
222-
local newChannel = round(tonumber(RadioChannel + 1), 2)
217+
local newChannel = QBCore.Shared.Round(tonumber(RadioChannel + 1), 2)
223218
local canaccess = connecttoradio(newChannel)
224219
cb({
225220
canaccess = canaccess,
@@ -229,7 +224,7 @@ end)
229224

230225
RegisterNUICallback("decreaseradiochannel", function(_, cb)
231226
if not onRadio then return end
232-
local newChannel = round(tonumber(RadioChannel - 1), 2)
227+
local newChannel = QBCore.Shared.Round(tonumber(RadioChannel - 1), 2)
233228
local canaccess = connecttoradio(newChannel)
234229
cb({
235230
canaccess = canaccess,

0 commit comments

Comments
 (0)