diff --git a/server-data/resources/[bpt_addons]/bpt_crafting/html/script.js b/server-data/resources/[bpt_addons]/bpt_crafting/html/script.js index 798891071..f072ebe04 100644 --- a/server-data/resources/[bpt_addons]/bpt_crafting/html/script.js +++ b/server-data/resources/[bpt_addons]/bpt_crafting/html/script.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line no-unused-vars let timeout; let opened; let recipes; @@ -101,6 +102,7 @@ function openCategory() { } +// eslint-disable-next-line no-unused-vars function openCrafting(t) { $('#main').html(''); @@ -285,6 +287,7 @@ function addToQueue(item, time, id) { } +// eslint-disable-next-line no-unused-vars function craft(t) { const item = t.dataset.item; $.post('https://bpt_crafting/craft', JSON.stringify({ @@ -296,9 +299,11 @@ function setProgress(p) { const prog = (398 / 100) * p; $('#u136').animate({ width: prog, + // eslint-disable-next-line no-empty-function }, 500, function() {}); } +// eslint-disable-next-line no-unused-vars function inspect(t) { if (opened != t) { opened = t; diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js index 0bc20543a..50602f58a 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js @@ -15,7 +15,6 @@ const lastClick = 0; function getRandomQuestion() { let random = Math.floor(Math.random() * nbPossibleQuestions); - // eslint-disable-next-line no-constant-condition while (true) { if (questionUsed.indexOf(random) === -1) { break; diff --git a/server-data/resources/[bpt_addons]/bpt_hunting/client/functions.lua b/server-data/resources/[bpt_addons]/bpt_hunting/client/functions.lua index 6790f1f5f..b5598ffbe 100644 --- a/server-data/resources/[bpt_addons]/bpt_hunting/client/functions.lua +++ b/server-data/resources/[bpt_addons]/bpt_hunting/client/functions.lua @@ -6,11 +6,11 @@ DrawText3D = function(x, y, z, text) if onScreen then SetTextScale(scale, scale) SetTextFont(4) - SetTextProportional(1) + SetTextProportional(true) SetTextColour(255, 255, 255, 215) SetTextOutline() SetTextEntry("STRING") - SetTextCentre(1) + SetTextCentre(true) AddTextComponentString(text) DrawText(_x, _y) local _ = (string.len(text)) / 650 diff --git a/server-data/resources/[bpt_addons]/bpt_hunting/client/main.lua b/server-data/resources/[bpt_addons]/bpt_hunting/client/main.lua index f26f47526..3ddc4bf72 100644 --- a/server-data/resources/[bpt_addons]/bpt_hunting/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_hunting/client/main.lua @@ -1,11 +1,11 @@ ESX = exports["es_extended"]:getSharedObject() -local oPlayer, playerpos = false, false +local oPlayer = false CreateThread(function() while true do - oPlayer = PlayerPedId() - playerpos = GetEntityCoords(oPlayer) + OPlayer = PlayerPedId() + Playerpos = GetEntityCoords(oPlayer) Wait(500) end end) @@ -18,7 +18,7 @@ CreateThread(function() repeat success, ped = FindNextPed(handle) local pos = GetEntityCoords(ped) - local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, playerpos.x, playerpos.y, playerpos.z, true) + local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, Playerpos.x, Playerpos.y, Playerpos.z, true) if distance < 2 and CanSlaughterPed(ped) then DrawText3D(pos.x, pos.y, pos.z + 0.6, "[H] ~b~Skin Animal ~s~") while IsControlPressed(0, 30) do @@ -27,8 +27,8 @@ CreateThread(function() if IsControlJustPressed(1, 74) then if GetSelectedPedWeapon(PlayerPedId()) == GetHashKey("WEAPON_KNIFE") then local oldped = ped - SetEntityHeading(ped, GetHeadingFromVector_2d(pos.x - playerpos.x - playerpos.y) + 180) - SetEntityHeading(oPlayer, GetHeadingFromVector_2d(pos.x - playerpos.x, pos.y - playerpos.y)) + SetEntityHeading(ped, GetHeadingFromVector_2d(pos.x - Playerpos.x - Playerpos.y) + 180) + SetEntityHeading(OPlayer, GetHeadingFromVector_2d(pos.x - Playerpos.x, pos.y - Playerpos.y)) exports.rprogress:Custom({ Async = true, diff --git a/server-data/resources/[esx]/vSync/server/server.lua b/server-data/resources/[esx]/vSync/server/server.lua index ccccdd0f7..68288abad 100644 --- a/server-data/resources/[esx]/vSync/server/server.lua +++ b/server-data/resources/[esx]/vSync/server/server.lua @@ -11,17 +11,17 @@ AddEventHandler("vSync:requestSync", function() TriggerClientEvent("vSync:updateTime", -1, baseTime, timeOffset, freezeTime) end) -function isAllowedToChange(player) +function IsAllowedToChange(player) if Config.AdminById then - for k, v in ipairs(Config.Admins) do - for k2, v2 in ipairs(GetPlayerIdentifiers(player)) do + for _, v in ipairs(Config.Admins) do + for _, v2 in ipairs(GetPlayerIdentifiers(player)) do if string.lower(v2) == string.lower(v) then return true end end end else - for k, v in ipairs(Config.Ace) do + for _, v in ipairs(Config.Ace) do if IsPlayerAceAllowed(player, v) then return true end @@ -30,9 +30,9 @@ function isAllowedToChange(player) return false end -RegisterCommand("freezetime", function(source, args) +RegisterCommand("freezetime", function(source) if source ~= 0 then - if isAllowedToChange(source) then + if IsAllowedToChange(source) then freezeTime = not freezeTime if freezeTime then TriggerClientEvent("vSync:notify", source, _U("time_frozenc")) @@ -54,7 +54,7 @@ end) RegisterCommand("freezeweather", function(source, args) if source ~= 0 then - if isAllowedToChange(source) then + if IsAllowedToChange(source) then Config.DynamicWeather = not Config.DynamicWeather if not Config.DynamicWeather then TriggerClientEvent("vSync:notify", source, _U("dynamic_weather_disabled")) @@ -81,7 +81,7 @@ RegisterCommand("weather", function(source, args) print(_U("weather_invalid_syntax")) return else - for i, wtype in ipairs(Config.AvailableWeatherTypes) do + for _, wtype in ipairs(Config.AvailableWeatherTypes) do if wtype == string.upper(args[1]) then validWeatherType = true end @@ -96,12 +96,12 @@ RegisterCommand("weather", function(source, args) end end else - if isAllowedToChange(source) then + if IsAllowedToChange(source) then local validWeatherType = false if args[1] == nil then TriggerClientEvent("chatMessage", source, "", { 255, 255, 255 }, _U("weather_invalid_syntaxc")) else - for i, wtype in ipairs(Config.AvailableWeatherTypes) do + for _, wtype in ipairs(Config.AvailableWeatherTypes) do if wtype == string.upper(args[1]) then validWeatherType = true end @@ -131,7 +131,7 @@ RegisterCommand("blackout", function(source) print(_U("blackout_disabled")) end else - if isAllowedToChange(source) then + if IsAllowedToChange(source) then blackout = not blackout if blackout then TriggerClientEvent("vSync:notify", source, _U("blackout_enabledc")) @@ -148,43 +148,46 @@ RegisterCommand("morning", function(source) print(_U("time_console")) return end - if isAllowedToChange(source) then + if IsAllowedToChange(source) then ShiftToMinute(0) ShiftToHour(9) TriggerClientEvent("vSync:notify", source, _U("time_morning")) TriggerEvent("vSync:requestSync") end end) + RegisterCommand("noon", function(source) if source == 0 then print(_U("time_console")) return end - if isAllowedToChange(source) then + if IsAllowedToChange(source) then ShiftToMinute(0) ShiftToHour(12) TriggerClientEvent("vSync:notify", source, _U("time_noon")) TriggerEvent("vSync:requestSync") end end) + RegisterCommand("evening", function(source) if source == 0 then print(_U("time_console")) return end - if isAllowedToChange(source) then + if IsAllowedToChange(source) then ShiftToMinute(0) ShiftToHour(18) TriggerClientEvent("vSync:notify", source, _U("time_evening")) TriggerEvent("vSync:requestSync") end end) + RegisterCommand("night", function(source) if source == 0 then print(_U("time_console")) return end - if isAllowedToChange(source) then + if IsAllowedToChange(source) then ShiftToMinute(0) ShiftToHour(23) TriggerClientEvent("vSync:notify", source, _U("time_night")) @@ -200,7 +203,7 @@ function ShiftToHour(hour) timeOffset = timeOffset - ((((baseTime + timeOffset) / 60) % 24) - hour) * 60 end -RegisterCommand("time", function(source, args, rawCommand) +RegisterCommand("time", function(source, args) if source == 0 then if tonumber(args[1]) ~= nil and tonumber(args[2]) ~= nil then local argh = tonumber(args[1]) diff --git a/server-data/resources/[esx_addons]/esx_scoreboard/client/main.lua b/server-data/resources/[esx_addons]/esx_scoreboard/client/main.lua index 3b881bb36..922a1ec6e 100644 --- a/server-data/resources/[esx_addons]/esx_scoreboard/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_scoreboard/client/main.lua @@ -1,4 +1,3 @@ ---- CrazyFox Discord Channel: https://discord.gg/4E8sth5 local Keys = { ["ESC"] = 322, ["F1"] = 288, diff --git a/server-data/resources/[esx_addons]/esx_scoreboard/html/listener.js b/server-data/resources/[esx_addons]/esx_scoreboard/html/listener.js index 373e92d97..0f5876162 100644 --- a/server-data/resources/[esx_addons]/esx_scoreboard/html/listener.js +++ b/server-data/resources/[esx_addons]/esx_scoreboard/html/listener.js @@ -1,89 +1,92 @@ -var visable = false; -$(function () { - window.addEventListener('message', function (event) { +let visable = false; +$(function() { + window.addEventListener('message', function(event) { switch (event.data.action) { - case 'toggle': - if (visable) { - $('#wrap').fadeOut(); - } else { - $('#wrap').fadeIn(); - } - if (visable) { - $('#wrap2').fadeOut(); - } else { - $('#wrap2').fadeIn(); - } - visable = !visable; - break; - case 'close': + case 'toggle': + if (visable) { $('#wrap').fadeOut(); - visable = false; - break; - case 'toggleID': - if (event.data.state) { - $('td:nth-child(2),th:nth-child(2)').show(); - $('td:nth-child(5),th:nth-child(5)').show(); - $('td:nth-child(8),th:nth-child(8)').show(); - } else { - $('td:nth-child(2),th:nth-child(2)').hide(); - $('td:nth-child(5),th:nth-child(5)').hide(); - $('td:nth-child(8),th:nth-child(8)').hide(); - } - break; - case 'scrollUP': - $("#style-1").scrollTop($("#style-1").scrollTop() - 100); - break; - case 'scrollDOWN': - $("#style-1").scrollTop($("#style-1").scrollTop() + 100); - break; - case 'updatePlayerList': - $('#playerlist tr:gt(0)').remove(); - $('#playerlist').append(event.data.players); - applyPingColor(); - //sortPlayerList(); - break; - case 'updatePing': - updatePing(event.data.players); - applyPingColor(); - break; - case 'updateServerInfo': - if (event.data.maxPlayers) { - $('#max_players').html(event.data.maxPlayers); - } - break; - default: - console.log('esx_scoreboard: unknown action!'); - break; + } + else { + $('#wrap').fadeIn(); + } + if (visable) { + $('#wrap2').fadeOut(); + } + else { + $('#wrap2').fadeIn(); + } + visable = !visable; + break; + case 'close': + $('#wrap').fadeOut(); + visable = false; + break; + case 'toggleID': + if (event.data.state) { + $('td:nth-child(2),th:nth-child(2)').show(); + $('td:nth-child(5),th:nth-child(5)').show(); + $('td:nth-child(8),th:nth-child(8)').show(); + } + else { + $('td:nth-child(2),th:nth-child(2)').hide(); + $('td:nth-child(5),th:nth-child(5)').hide(); + $('td:nth-child(8),th:nth-child(8)').hide(); + } + break; + case 'scrollUP': + $('#style-1').scrollTop($('#style-1').scrollTop() - 100); + break; + case 'scrollDOWN': + $('#style-1').scrollTop($('#style-1').scrollTop() + 100); + break; + case 'updatePlayerList': + $('#playerlist tr:gt(0)').remove(); + $('#playerlist').append(event.data.players); + applyPingColor(); + break; + case 'updatePing': + updatePing(event.data.players); + applyPingColor(); + break; + case 'updateServerInfo': + if (event.data.maxPlayers) { + $('#max_players').html(event.data.maxPlayers); + } + break; + default: + console.log('esx_scoreboard: unknown action!'); + break; } }, false); }); function applyPingColor() { - $('#playerlist tr').each(function () { - $(this).find('td:nth-child(3),td:nth-child(6),td:nth-child(9)').each(function () { - var ping = $(this).html(); - var color = 'green'; + $('#playerlist tr').each(function() { + $(this).find('td:nth-child(3),td:nth-child(6),td:nth-child(9)').each(function() { + const ping = $(this).html(); + let color = 'green'; if (ping > 150 && ping < 190) { color = 'orange'; - } else if (ping >= 200) { + } + else if (ping >= 200) { color = 'red'; } $(this).css('color', color); - $(this).html(ping + " ms"); + $(this).html(ping + ' ms'); }); }); } function updatePing(players) { - jQuery.each(players, function (index, element) { + jQuery.each(players, function(index, element) { if (element != null) { - $('#playerlist tr:not(.heading)').each(function () { - $(this).find('td:nth-child(2):contains(' + element.id + ')').each(function () { + $('#playerlist tr:not(.heading)').each(function() { + $(this).find('td:nth-child(2):contains(' + element.id + ')').each(function() { $(this).parent().find('td').eq(2).html(element.ping); }); - $(this).find('td:nth-child(5):contains(' + element.id + ')').each(function () { + $(this).find('td:nth-child(5):contains(' + element.id + ')').each(function() { $(this).parent().find('td').eq(5).html(element.ping); }); - $(this).find('td:nth-child(8):contains(' + element.id + ')').each(function () { + $(this).find('td:nth-child(8):contains(' + element.id + ')').each(function() { $(this).parent().find('td').eq(8).html(element.ping); }); }); @@ -91,15 +94,16 @@ function updatePing(players) { }); } +// eslint-disable-next-line no-unused-vars function sortPlayerList() { - var table = $('#playerlist'), + const table = $('#playerlist'), rows = $('tr:not(.heading)', table); - rows.sort(function (a, b) { - var keyA = $('td', a).eq(1).html(); - var keyB = $('td', b).eq(1).html(); + rows.sort(function(a, b) { + const keyA = $('td', a).eq(1).html(); + const keyB = $('td', b).eq(1).html(); return (keyA - keyB); }); - rows.each(function (index, row) { + rows.each(function(index, row) { table.append(row); }); } diff --git a/server-data/resources/[ox]/ox_inventory/data/items.lua b/server-data/resources/[ox]/ox_inventory/data/items.lua index 895bbd13b..80fed145a 100644 --- a/server-data/resources/[ox]/ox_inventory/data/items.lua +++ b/server-data/resources/[ox]/ox_inventory/data/items.lua @@ -18,7 +18,7 @@ return { label = "Burger", weight = 220, client = { - status = { hunger = 25000 }, + status = { hunger = 30000 }, anim = "eating", prop = "burger", usetime = 2500, @@ -291,7 +291,7 @@ return { ["radio"] = { label = "Radio", - weight = 1000, + weight = 300, stack = false, consume = 0, allowArmed = true, diff --git a/server-data/resources/[phone]/esx-radio/client.lua b/server-data/resources/[phone]/esx-radio/client.lua index ef827f56d..468557144 100644 --- a/server-data/resources/[phone]/esx-radio/client.lua +++ b/server-data/resources/[phone]/esx-radio/client.lua @@ -57,14 +57,14 @@ local function toggleRadioAnimation(pState) if pState then TriggerEvent("attachItemRadio", "radio01") TaskPlayAnim(PlayerPedId(), "cellphone@", "cellphone_text_read_base", 2.0, 3.0, -1, 49, 0, 0, 0, 0) - radioProp = CreateObject(`prop_cs_hand_radio`, 1.0, 1.0, 1.0, 1, 1, 0) - AttachEntityToEntity(radioProp, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 57005), 0.14, 0.01, -0.02, 110.0, 120.0, -15.0, 1, 0, 0, 0, 2, 1) + RadioProp = CreateObject(`prop_cs_hand_radio`, 1.0, 1.0, 1.0, 1, 1, 0) + AttachEntityToEntity(RadioProp, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 57005), 0.14, 0.01, -0.02, 110.0, 120.0, -15.0, 1, 0, 0, 0, 2, 1) else StopAnimTask(PlayerPedId(), "cellphone@", "cellphone_text_read_base", 1.0) ClearPedTasks(PlayerPedId()) if radioProp ~= 0 then - DeleteObject(radioProp) - radioProp = 0 + DeleteObject(RadioProp) + RadioProp = 0 end end end diff --git a/server-data/resources/[phone]/esx-radio/config.lua b/server-data/resources/[phone]/esx-radio/config.lua index e0a94712a..d03dd5d61 100644 --- a/server-data/resources/[phone]/esx-radio/config.lua +++ b/server-data/resources/[phone]/esx-radio/config.lua @@ -10,11 +10,11 @@ Config.KeyMappings = { Key = "UP", } -Config.ClientNotification = function(msg, type) +Config.ClientNotification = function(msg) ESX.ShowNotification(msg, false, false, 140) end -Config.ServerNotification = function(msg, type, player) +Config.ServerNotification = function(msg, player) TriggerClientEvent("esx:showNotification", player, msg) end diff --git a/server-data/resources/[phone]/esx-radio/server.lua b/server-data/resources/[phone]/esx-radio/server.lua index 36d1e6a63..466b67ea8 100644 --- a/server-data/resources/[phone]/esx-radio/server.lua +++ b/server-data/resources/[phone]/esx-radio/server.lua @@ -11,7 +11,7 @@ if Config.Item.Require then TriggerClientEvent("esx-radio:use", source) end) - ESX.RegisterServerCallback("esx-radio:server:GetItem", function(source, cb, item) + ESX.RegisterServerCallback("esx-radio:server:GetItem", function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) local RadioItem = xPlayer.getInventoryItem(Config.Item.name).count cb(RadioItem >= 1) diff --git a/server-data/resources/[phone]/pma-voice/server/main.lua b/server-data/resources/[phone]/pma-voice/server/main.lua index be4c96333..7c6c98af8 100644 --- a/server-data/resources/[phone]/pma-voice/server/main.lua +++ b/server-data/resources/[phone]/pma-voice/server/main.lua @@ -1,157 +1,145 @@ -voiceData = {} -radioData = {} -callData = {} - +local voiceData, radioData, callData = {}, {}, {} local mappedChannels = {} -function firstFreeChannel() - for i = 1, 2048 do - if not mappedChannels[i] then - return i - end - end - - return 0 + +function FirstFreeChannel() + for i = 1, 2048 do + if not mappedChannels[i] then + return i + end + end + + return 0 end -function defaultTable(source) - handleStateBagInitilization(source) - return { - radio = 0, - call = 0, - lastRadio = 0, - lastCall = 0 - } +function DefaultTable(source) + HandleStateBagInitilization(source) + return { + radio = 0, + call = 0, + lastRadio = 0, + lastCall = 0, + } end -function handleStateBagInitilization(source) - local plyState = Player(source).state - if not plyState.pmaVoiceInit then - plyState:set('radio', GetConvarInt('voice_defaultRadioVolume', 30), true) - plyState:set('call', GetConvarInt('voice_defaultCallVolume', 60), true) - plyState:set('submix', nil, 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 - - local assignedChannel = firstFreeChannel() - plyState:set('assignedChannel', assignedChannel, true) - if assignedChannel ~= 0 then - mappedChannels[assignedChannel] = source - logger.verbose('[reuse] Assigned %s to channel %s', source, assignedChannel) - else - logger.error('[reuse] Failed to find a free channel for %s', source) - end +function HandleStateBagInitilization(source) + local plyState = Player(source).state + if not plyState.pmaVoiceInit then + plyState:set("radio", GetConvarInt("voice_defaultRadioVolume", 30), true) + plyState:set("call", GetConvarInt("voice_defaultCallVolume", 60), true) + plyState:set("submix", nil, 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 + + local assignedChannel = FirstFreeChannel() + plyState:set("assignedChannel", assignedChannel, true) + if assignedChannel ~= 0 then + mappedChannels[assignedChannel] = source + logger.verbose("[reuse] Assigned %s to channel %s", source, assignedChannel) + else + logger.error("[reuse] Failed to find a free channel for %s", source) + end end CreateThread(function() - local plyTbl = GetPlayers() - for i = 1, #plyTbl do - local ply = tonumber(plyTbl[i]) - voiceData[ply] = defaultTable(plyTbl[i]) - end - - Wait(5000) - - local nativeAudio = GetConvar('voice_useNativeAudio', 'not-set') - local _3dAudio = GetConvar('voice_use3dAudio', 'not-set') - local _2dAudio = GetConvar('voice_use2dAudio', 'not-set') - local sendingRangeOnly = GetConvar('voice_useSendingRangeOnly', 'not-set') - local gameVersion = GetConvar('gamename', 'fivem') - - -- handle no convars being set (default drag n' drop) - if - nativeAudio == 'not-set' - and _3dAudio == 'not-set' - and _2dAudio == 'not-set' - then - SetConvarReplicated('voice_useNativeAudio', 'true') - if sendingRangeOnly == 'not-set' then - SetConvarReplicated('voice_useSendingRangeOnly', 'true') - logger.info( - 'No convars detected for voice mode, defaulting to \'setr voice_useNativeAudio true\' and \'setr voice_useSendingRangeOnly true\'') - else - logger.info('No voice mod detected, defaulting to \'setr voice_useNativeAudio true\'') - end - elseif sendingRangeOnly == 'not-set' then - logger.warn( - "It's recommended to have 'voice_useSendingRangeOnly' set to true, you can do that with 'setr voice_useSendingRangeOnly true', this prevents players who directly join the mumble server from broadcasting to players.") - end - - local radioVolume = GetConvarInt("voice_defaultRadioVolume", 30) - local callVolume = GetConvarInt("voice_defaultCallVolume", 60) - - -- When casted to an integer these get set to 0 or 1, so warn on these values that they don't work - if - radioVolume == 0 or radioVolume == 1 or - callVolume == 0 or callVolume == 1 - then - SetConvarReplicated("voice_defaultRadioVolume", 30) - SetConvarReplicated("voice_defaultCallVolume", 60) - for i = 1, 5 do - Wait(5000) - logger.warn( - "`voice_defaultRadioVolume` or `voice_defaultCallVolume` have their value set as a float, this is going to automatically be fixed but please update your convars.") - end - end + local plyTbl = GetPlayers() + for i = 1, #plyTbl do + local ply = tonumber(plyTbl[i]) + voiceData[ply] = DefaultTable(plyTbl[i]) + end + + Wait(5000) + + local nativeAudio = GetConvar("voice_useNativeAudio", "not-set") + local _3dAudio = GetConvar("voice_use3dAudio", "not-set") + local _2dAudio = GetConvar("voice_use2dAudio", "not-set") + local sendingRangeOnly = GetConvar("voice_useSendingRangeOnly", "not-set") + local gameVersion = GetConvar("gamename", "fivem") + + -- handle no convars being set (default drag n' drop) + if nativeAudio == "not-set" and _3dAudio == "not-set" and _2dAudio == "not-set" then + SetConvarReplicated("voice_useNativeAudio", "true") + if sendingRangeOnly == "not-set" then + SetConvarReplicated("voice_useSendingRangeOnly", "true") + logger.info("No convars detected for voice mode, defaulting to 'setr voice_useNativeAudio true' and 'setr voice_useSendingRangeOnly true'") + else + logger.info("No voice mod detected, defaulting to 'setr voice_useNativeAudio true'") + end + elseif sendingRangeOnly == "not-set" then + logger.warn("It's recommended to have 'voice_useSendingRangeOnly' set to true, you can do that with 'setr voice_useSendingRangeOnly true', this prevents players who directly join the mumble server from broadcasting to players.") + end + + local radioVolume = GetConvarInt("voice_defaultRadioVolume", 30) + local callVolume = GetConvarInt("voice_defaultCallVolume", 60) + + -- When casted to an integer these get set to 0 or 1, so warn on these values that they don't work + if radioVolume == 0 or radioVolume == 1 or callVolume == 0 or callVolume == 1 then + SetConvarReplicated("voice_defaultRadioVolume", 30) + SetConvarReplicated("voice_defaultCallVolume", 60) + for i = 1, 5 do + Wait(5000) + logger.warn("`voice_defaultRadioVolume` or `voice_defaultCallVolume` have their value set as a float, this is going to automatically be fixed but please update your convars.") + end + end end) -AddEventHandler('playerJoining', function() - if not voiceData[source] then - voiceData[source] = defaultTable(source) - end +AddEventHandler("playerJoining", function() + if not voiceData[source] then + voiceData[source] = DefaultTable(source) + end end) AddEventHandler("playerDropped", function() - local source = source - local mappedChannel = Player(source).state.assignedChannel + local source = source + local mappedChannel = Player(source).state.assignedChannel - if voiceData[source] then - local plyData = voiceData[source] + if voiceData[source] then + local plyData = voiceData[source] - if plyData.radio ~= 0 then - removePlayerFromRadio(source, plyData.radio) - end + if plyData.radio ~= 0 then + removePlayerFromRadio(source, plyData.radio) + end - if plyData.call ~= 0 then - removePlayerFromCall(source, plyData.call) - end + if plyData.call ~= 0 then + RemovePlayerFromCall(source, plyData.call) + end - voiceData[source] = nil - end + voiceData[source] = nil + end - if mappedChannel then - mappedChannels[mappedChannel] = nil - logger.verbose('[reuse] Unassigned %s from channel %s', source, mappedChannel) - end + if mappedChannel then + mappedChannels[mappedChannel] = nil + logger.verbose("[reuse] Unassigned %s from channel %s", source, mappedChannel) + end end) -if GetConvarInt('voice_externalDisallowJoin', 0) == 1 then - AddEventHandler('playerConnecting', function(_, _, deferral) - deferral.defer() - Wait(0) - deferral.done('This server is not accepting connections.') - end) +if GetConvarInt("voice_externalDisallowJoin", 0) == 1 then + AddEventHandler("playerConnecting", function(_, _, deferral) + deferral.defer() + Wait(0) + deferral.done("This server is not accepting connections.") + end) end -- only meant for internal use so no documentation -function isValidPlayer(source) - return voiceData[source] +function IsValidPlayer(source) + return voiceData[source] end -exports('isValidPlayer', isValidPlayer) +exports("isValidPlayer", IsValidPlayer) -function getPlayersInRadioChannel(channel) - local returnChannel = radioData[channel] - if returnChannel then - return returnChannel - end - -- channel doesnt exist - return {} +function GetPlayersInRadioChannel(channel) + local returnChannel = radioData[channel] + if returnChannel then + return returnChannel + end + -- channel doesnt exist + return {} end -exports('getPlayersInRadioChannel', getPlayersInRadioChannel) -exports('GetPlayersInRadioChannel', getPlayersInRadioChannel) +exports("getPlayersInRadioChannel", GetPlayersInRadioChannel) +exports("GetPlayersInRadioChannel", GetPlayersInRadioChannel) diff --git a/server-data/resources/[phone]/pma-voice/server/module/phone.lua b/server-data/resources/[phone]/pma-voice/server/module/phone.lua index ac6412137..cfb1b7a5e 100644 --- a/server-data/resources/[phone]/pma-voice/server/module/phone.lua +++ b/server-data/resources/[phone]/pma-voice/server/module/phone.lua @@ -1,76 +1,78 @@ --- removes a player from the call for everyone in the call. ---@param source number the player to remove from the call ---@param callChannel number the call channel to remove them from -function removePlayerFromCall(source, callChannel) - logger.verbose('[call] Removed %s from call %s', source, callChannel) - callData[callChannel] = callData[callChannel] or {} - for player, _ in pairs(callData[callChannel]) do - TriggerClientEvent('pma-voice:removePlayerFromCall', player, source) - end - callData[callChannel][source] = nil - voiceData[source] = voiceData[source] or defaultTable(source) - voiceData[source].call = 0 +function RemovePlayerFromCall(source, callChannel) + logger.verbose("[call] Removed %s from call %s", source, callChannel) + + callData[callChannel] = callData[callChannel] or {} + for player, _ in pairs(callData[callChannel]) do + TriggerClientEvent("pma-voice:removePlayerFromCall", player, source) + end + callData[callChannel][source] = nil + voiceData[source] = voiceData[source] or DefaultTable(source) + voiceData[source].call = 0 end --- adds a player to a call ---@param source number the player to add to the call ---@param callChannel number the call channel to add them to function addPlayerToCall(source, callChannel) - logger.verbose('[call] Added %s to call %s', source, callChannel) - -- check if the channel exists, if it does set the varaible to it - -- if not create it (basically if not callData make callData) - callData[callChannel] = callData[callChannel] or {} - for player, _ in pairs(callData[callChannel]) do - -- don't need to send to the source because they're about to get sync'd! - if player ~= source then - TriggerClientEvent('pma-voice:addPlayerToCall', player, source) - end - end - callData[callChannel][source] = true - voiceData[source] = voiceData[source] or defaultTable(source) - voiceData[source].call = callChannel - TriggerClientEvent('pma-voice:syncCallData', source, callData[callChannel]) + logger.verbose("[call] Added %s to call %s", source, callChannel) + -- check if the channel exists, if it does set the varaible to it + -- if not create it (basically if not callData make callData) + callData[callChannel] = callData[callChannel] or {} + for player, _ in pairs(callData[callChannel]) do + -- don't need to send to the source because they're about to get sync'd! + if player ~= source then + TriggerClientEvent("pma-voice:addPlayerToCall", player, source) + end + end + callData[callChannel][source] = true + voiceData[source] = voiceData[source] or DefaultTable(source) + voiceData[source].call = callChannel + TriggerClientEvent("pma-voice:syncCallData", source, callData[callChannel]) end --- set the players call channel ---@param source number the player to set the call off ---@param _callChannel number the channel to set the player to (or 0 to remove them from any call channel) function setPlayerCall(source, _callChannel) - if GetConvarInt('voice_enableCalls', 1) ~= 1 then return end - voiceData[source] = voiceData[source] or defaultTable(source) - local isResource = GetInvokingResource() - local plyVoice = voiceData[source] - local callChannel = tonumber(_callChannel) - if not callChannel then - -- only full error if its sent from another server-side resource - if isResource then - error(("'callChannel' expected 'number', got: %s"):format(type(_callChannel))) - else - return logger.warn("%s sent a invalid call, 'callChannel' expected 'number', got: %s", source, - type(_callChannel)) - end - end - if isResource then - -- got set in a export, need to update the client to tell them that their call - -- changed - TriggerClientEvent('pma-voice:clSetPlayerCall', source, callChannel) - end + if GetConvarInt("voice_enableCalls", 1) ~= 1 then + return + end + voiceData[source] = voiceData[source] or DefaultTable(source) + local isResource = GetInvokingResource() + local plyVoice = voiceData[source] + local callChannel = tonumber(_callChannel) + if not callChannel then + -- only full error if its sent from another server-side resource + if isResource then + error(("'callChannel' expected 'number', got: %s"):format(type(_callChannel))) + else + return logger.warn("%s sent a invalid call, 'callChannel' expected 'number', got: %s", source, type(_callChannel)) + end + end + if isResource then + -- got set in a export, need to update the client to tell them that their call + -- changed + TriggerClientEvent("pma-voice:clSetPlayerCall", source, callChannel) + end - Player(source).state.callChannel = callChannel + Player(source).state.callChannel = callChannel - if callChannel ~= 0 and plyVoice.call == 0 then - addPlayerToCall(source, callChannel) - elseif callChannel == 0 then - removePlayerFromCall(source, plyVoice.call) - elseif plyVoice.call > 0 then - removePlayerFromCall(source, plyVoice.call) - addPlayerToCall(source, callChannel) - end + if callChannel ~= 0 and plyVoice.call == 0 then + addPlayerToCall(source, callChannel) + elseif callChannel == 0 then + RemovePlayerFromCall(source, plyVoice.call) + elseif plyVoice.call > 0 then + RemovePlayerFromCall(source, plyVoice.call) + addPlayerToCall(source, callChannel) + end end -exports('setPlayerCall', setPlayerCall) +exports("setPlayerCall", setPlayerCall) -RegisterNetEvent('pma-voice:setPlayerCall', function(callChannel) - setPlayerCall(source, callChannel) +RegisterNetEvent("pma-voice:setPlayerCall", function(callChannel) + setPlayerCall(source, callChannel) end) diff --git a/server-data/resources/[phone]/pma-voice/server/module/radio.lua b/server-data/resources/[phone]/pma-voice/server/module/radio.lua index 576c170cb..4aa1a72bc 100644 --- a/server-data/resources/[phone]/pma-voice/server/module/radio.lua +++ b/server-data/resources/[phone]/pma-voice/server/module/radio.lua @@ -67,7 +67,7 @@ function addPlayerToRadio(source, radioChannel) for player, _ in pairs(radioData[radioChannel]) do TriggerClientEvent('pma-voice:addPlayerToRadio', player, source, plyName) end - voiceData[source] = voiceData[source] or defaultTable(source) + voiceData[source] = voiceData[source] or DefaultTable(source) voiceData[source].radio = radioChannel radioData[radioChannel][source] = false TriggerClientEvent('pma-voice:syncRadioData', source, radioData[radioChannel], @@ -85,7 +85,7 @@ function removePlayerFromRadio(source, radioChannel) TriggerClientEvent('pma-voice:removePlayerFromRadio', player, source) end radioData[radioChannel][source] = nil - voiceData[source] = voiceData[source] or defaultTable(source) + voiceData[source] = voiceData[source] or DefaultTable(source) voiceData[source].radio = 0 end @@ -95,7 +95,7 @@ end ---@param _radioChannel number the radio channel to set them to (or 0 to remove them from radios) function setPlayerRadio(source, _radioChannel) if GetConvarInt('voice_enableRadios', 1) ~= 1 then return end - voiceData[source] = voiceData[source] or defaultTable(source) + voiceData[source] = voiceData[source] or DefaultTable(source) local isResource = GetInvokingResource() local plyVoice = voiceData[source] local radioChannel = tonumber(_radioChannel) @@ -135,7 +135,7 @@ end) ---@param talking boolean sets if the palyer is talking. function setTalkingOnRadio(talking) if GetConvarInt('voice_enableRadios', 1) ~= 1 then return end - voiceData[source] = voiceData[source] or defaultTable(source) + voiceData[source] = voiceData[source] or DefaultTable(source) local plyVoice = voiceData[source] local radioTbl = radioData[plyVoice.radio] if radioTbl then diff --git a/server-data/resources/[phone]/pma-voice/server/mute.js b/server-data/resources/[phone]/pma-voice/server/mute.js index 61b45ffed..6f1b5e7f4 100644 --- a/server-data/resources/[phone]/pma-voice/server/mute.js +++ b/server-data/resources/[phone]/pma-voice/server/mute.js @@ -1,10 +1,10 @@ -let mutedPlayers = {} +const mutedPlayers = {}; // this is implemented in JS due to Lua's lack of a ClearTimeout // muteply instead of mute because mute conflicts with rp-radio RegisterCommand('muteply', (source, args) => { - const mutePly = parseInt(args[0]) - const duration = parseInt(args[1]) || 900 - if (mutePly && exports[GetCurrentResourceName()].isValidPlayer(mutePly)) { + const mutePly = parseInt(args[0]); + const duration = parseInt(args[1]) || 900; + if (mutePly && exports[GetCurrentResourceName()].IsValidPlayer(mutePly)) { const isMuted = !MumbleIsPlayerMuted(mutePly); Player(mutePly).state.muted = isMuted; MumbleSetPlayerMuted(mutePly, isMuted); @@ -13,14 +13,14 @@ RegisterCommand('muteply', (source, args) => { // that they're currently muted, so we'll clear the timeout and unmute if (mutedPlayers[mutePly]) { clearTimeout(mutedPlayers[mutePly]); - MumbleSetPlayerMuted(mutePly, isMuted) + MumbleSetPlayerMuted(mutePly, isMuted); Player(mutePly).state.muted = isMuted; return; } mutedPlayers[mutePly] = setTimeout(() => { - MumbleSetPlayerMuted(mutePly, !isMuted) + MumbleSetPlayerMuted(mutePly, !isMuted); Player(mutePly).state.muted = !isMuted; - delete mutedPlayers[mutePly] - }, duration * 1000) + delete mutedPlayers[mutePly]; + }, duration * 1000); } -}, true) +}, true);