From 3de6402b6e813eebcbf3353655e56aabbcd54345 Mon Sep 17 00:00:00 2001 From: RickyBGamez Date: Tue, 10 Dec 2024 17:52:15 -0700 Subject: [PATCH 1/6] localize across the board and fix anything that i forgot to localize. --- sv_ace_perms.lua | 10 ++++++---- sv_chat_tags.lua | 8 +++++--- sv_deferrals.lua | 4 +++- sv_discord_api.lua | 7 ++++--- sv_utility.lua | 4 +++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sv_ace_perms.lua b/sv_ace_perms.lua index 949d39d..d95fb6b 100644 --- a/sv_ace_perms.lua +++ b/sv_ace_perms.lua @@ -3,6 +3,8 @@ if not Config.AcePermsEnabled then return end local pairs = pairs local tostring = tostring +local _GetIdentifiersTable = GetIdentifiersTable +local _getRoles = getRoles local _ExecuteCommand = ExecuteCommand local _GetPlayerName = GetPlayerName @@ -18,7 +20,7 @@ local permissionAdd = "add_ace identifier.%s \"%s\" allow" local permissionRemove = "remove_ace identifier.%s \"%s\" allow" local function applyPermissions(source) - local identifiers = GetIdentifiersTable(source) + local identifiers = _GetIdentifiersTable(source) local license, discord = identifiers.license, identifiers.discord for _, v in pairs(groupsToRemove) do @@ -31,7 +33,7 @@ local function applyPermissions(source) if not discord then return end - local roles = getRoles(source) + local roles = _getRoles(source) if roles == nil then return end local name = _GetPlayerName(source) or "" @@ -41,14 +43,14 @@ local function applyPermissions(source) local permissionInformation = permissions[tostring(v)] if not groupInformation then goto skipGroupInformation end - ExecuteCommand(groupAdd:format(license, groupInformation)) + _ExecuteCommand(groupAdd:format(license, groupInformation)) Log("Granted \"" .. groupInformation.. "\" to " .. name .. " (" .. license .. ").") ::skipGroupInformation:: if not permissionInformation then goto skipPermissionInformation end Log("Granting permission set for role ID: " .. v .. ".") for _, v2 in pairs(permissionInformation) do - ExecuteCommand(permissionAdd:format(license, v2)) + _ExecuteCommand(permissionAdd:format(license, v2)) Log("Granted \"" .. v2.. "\" to " .. name .. " (" .. license .. ") due to them having the role ID: " .. v .. ".") end ::skipPermissionInformation:: diff --git a/sv_chat_tags.lua b/sv_chat_tags.lua index 982d9a9..117e059 100644 --- a/sv_chat_tags.lua +++ b/sv_chat_tags.lua @@ -6,6 +6,8 @@ local tonumber = tonumber local find = string.find local insert = table.insert +local _GetIdentifiersTable = GetIdentifiersTable +local _getRoles = getRoles local _IsPlayerAceAllowed = IsPlayerAceAllowed local _TriggerClientEvent = TriggerClientEvent @@ -17,14 +19,14 @@ local playerSelectedRole = {} local playerStaffChatStatus = {} local function syncTags(source) - local identifiers = GetIdentifiersTable(source) + local identifiers = _GetIdentifiersTable(source) local rolesAllowed = {} local highestRole, highestRoleIndex = nil, nil local roles = nil if identifiers.discord then - roles = getRoles(source) + roles = _getRoles(source) end for i = 1, #RoleList do @@ -48,7 +50,7 @@ local function syncTags(source) end local function sendMessage(source, message) - TriggerClientEvent("chat:addMessage", source, { + _TriggerClientEvent("chat:addMessage", source, { color = {255, 0, 0}, multiline = true, args = {"Server", tostring(message)} diff --git a/sv_deferrals.lua b/sv_deferrals.lua index abf71cd..dae224f 100644 --- a/sv_deferrals.lua +++ b/sv_deferrals.lua @@ -1,12 +1,14 @@ if not Config.DiscordRequired then return end +local _GetIdentifiersTable = GetIdentifiersTable + local GuildRequired = Config.GuildRequired AddEventHandler("playerConnecting", function(_, _, deferrals) deferrals.defer() Wait(0) - local identifiers = GetIdentifiersTable(source) + local identifiers = _GetIdentifiersTable(source) local discord = identifiers.discord if not discord then diff --git a/sv_discord_api.lua b/sv_discord_api.lua index efda5a3..b32dbfd 100644 --- a/sv_discord_api.lua +++ b/sv_discord_api.lua @@ -5,6 +5,7 @@ local tostring = tostring local encode = json.encode local decode = json.decode +local _GetIdentifiersTable = GetIdentifiersTable local _PerformHttpRequest = PerformHttpRequest local _Wait = Citizen.Wait @@ -34,7 +35,7 @@ local function DiscordRequest(endpoint, method, jsondata) end function isInGuild(user) - local identifiers = GetIdentifiersTable(user) + local identifiers = _GetIdentifiersTable(user) if not identifiers.discord then return false end local endpoint = ("guilds/%s/members/%s"):format(GuildID, identifiers.discord) @@ -44,7 +45,7 @@ function isInGuild(user) end function getRoles(user) - local identifiers = GetIdentifiersTable(user) + local identifiers = _GetIdentifiersTable(user) if not identifiers.discord then return {} end local endpoint = ("guilds/%s/members/%s"):format(GuildID, identifiers.discord) @@ -56,7 +57,7 @@ function getRoles(user) end function isRolePresent(user, role) - local identifiers = GetIdentifiersTable(user) + local identifiers = _GetIdentifiersTable(user) if not identifiers.discord then return false end local endpoint = ("guilds/%s/members/%s"):format(GuildID, identifiers.discord) diff --git a/sv_utility.lua b/sv_utility.lua index 707d2ee..2dcb322 100644 --- a/sv_utility.lua +++ b/sv_utility.lua @@ -7,6 +7,8 @@ local gsub = string.gsub local gmatch = string.gmatch local insert = table.insert +local _GetPlayerIdentifiers = GetPlayerIdentifiers + cachedIdentifiers = {} function Log(message) @@ -17,7 +19,7 @@ function GetIdentifiersTable(player) if cachedIdentifiers[player] then return cachedIdentifiers[player] end local data = {} - for _, v in pairs(GetPlayerIdentifiers(player))do + for _, v in pairs(_GetPlayerIdentifiers(player))do if sub(v, 1, len("license:")) == "license:" then data.license = v elseif sub(v, 1, len("discord:")) == "discord:" then From e58aeb81b4f5e10dd6827e116aaf6f0bb52a84d9 Mon Sep 17 00:00:00 2001 From: RickyBGamez Date: Tue, 10 Dec 2024 21:21:35 -0700 Subject: [PATCH 2/6] more localization. --- sv_ace_perms.lua | 7 ++++--- sv_deferrals.lua | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sv_ace_perms.lua b/sv_ace_perms.lua index d95fb6b..5e992ee 100644 --- a/sv_ace_perms.lua +++ b/sv_ace_perms.lua @@ -7,6 +7,7 @@ local _GetIdentifiersTable = GetIdentifiersTable local _getRoles = getRoles local _ExecuteCommand = ExecuteCommand local _GetPlayerName = GetPlayerName +local _Log = Log local groups = Config.Groups local permissions = Config.Permissions @@ -44,14 +45,14 @@ local function applyPermissions(source) if not groupInformation then goto skipGroupInformation end _ExecuteCommand(groupAdd:format(license, groupInformation)) - Log("Granted \"" .. groupInformation.. "\" to " .. name .. " (" .. license .. ").") + _Log("Granted \"" .. groupInformation.. "\" to " .. name .. " (" .. license .. ").") ::skipGroupInformation:: if not permissionInformation then goto skipPermissionInformation end - Log("Granting permission set for role ID: " .. v .. ".") + _Log("Granting permission set for role ID: " .. v .. ".") for _, v2 in pairs(permissionInformation) do _ExecuteCommand(permissionAdd:format(license, v2)) - Log("Granted \"" .. v2.. "\" to " .. name .. " (" .. license .. ") due to them having the role ID: " .. v .. ".") + _Log("Granted \"" .. v2.. "\" to " .. name .. " (" .. license .. ") due to them having the role ID: " .. v .. ".") end ::skipPermissionInformation:: end diff --git a/sv_deferrals.lua b/sv_deferrals.lua index dae224f..992218d 100644 --- a/sv_deferrals.lua +++ b/sv_deferrals.lua @@ -1,6 +1,7 @@ if not Config.DiscordRequired then return end local _GetIdentifiersTable = GetIdentifiersTable +local _isInGuild = isInGuild local GuildRequired = Config.GuildRequired @@ -16,7 +17,7 @@ AddEventHandler("playerConnecting", function(_, _, deferrals) return end - if GuildRequired and not isInGuild(source) then + if GuildRequired and not _isInGuild(source) then deferrals.done("You must be in the Discord server to join this server.") return end From 6a4498cfe89b8319de9d785f1a5e3fd5c5542d99 Mon Sep 17 00:00:00 2001 From: Ricky Bhatti <8051561+RickyBhatti@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:10:06 -0700 Subject: [PATCH 3/6] Update fxmanifest.lua --- fxmanifest.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/fxmanifest.lua b/fxmanifest.lua index 0823ee2..9801a87 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -14,6 +14,7 @@ client_scripts { server_scripts { "sv_config.lua", + "sv_utility.lua", "**/sv_*.lua" } From dda882ad8f7a902fb732884578b07bde54129939 Mon Sep 17 00:00:00 2001 From: Ricky Bhatti <8051561+RickyBhatti@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:14:57 -0700 Subject: [PATCH 4/6] Update fxmanifest.lua --- fxmanifest.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/fxmanifest.lua b/fxmanifest.lua index 9801a87..a52d873 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -15,6 +15,7 @@ client_scripts { server_scripts { "sv_config.lua", "sv_utility.lua", + "sv_discord_api.lua", "**/sv_*.lua" } From c9cf7a12a418daf6161c51b581dece2fde767e2b Mon Sep 17 00:00:00 2001 From: Ricky Bhatti <8051561+RickyBhatti@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:16:39 -0700 Subject: [PATCH 5/6] Update fxmanifest.lua --- fxmanifest.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index a52d873..ce3bf99 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -16,7 +16,9 @@ server_scripts { "sv_config.lua", "sv_utility.lua", "sv_discord_api.lua", - "**/sv_*.lua" + "sv_ace_perms.lua", + "sv_chat_tags.lua", + "sv_deferrals.lua" } server_exports { From dd079b6b8e64ebd79f4c332ae903edc8ba743340 Mon Sep 17 00:00:00 2001 From: Ricky Bhatti <8051561+RickyBhatti@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:23:29 -0700 Subject: [PATCH 6/6] Update fxmanifest.lua --- fxmanifest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index ce3bf99..70b218b 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ game "gta5" name "DiscordAPI" description "An all one in solution for Discord API, that controls chat tags, permissions." author "ricky" -version "v2.2.1" +version "v2.2.2" lua54 "yes"