Merge pull request #42 from Hakkodevelopment/wip-2.0.0

fix: Discord Convars causing config to break
This commit is contained in:
Andy
2023-12-03 16:45:31 +01:00
committed by GitHub

View File

@@ -15,8 +15,8 @@ Config = {
discordActionText2 = GetConvar("core:discordActionText2", "STORE"), discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"), discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
characterIdentifier = GetConvar("core:characterIdentifier", "license"), characterIdentifier = GetConvar("core:characterIdentifier", "license"),
discordGuildId = GetConvar("core:discordGuildId"), discordGuildId = GetConvar("core:discordGuildId", "false"),
discordBotToken = GetConvar("core:discordBotToken"), discordBotToken = GetConvar("core:discordBotToken", "false"),
randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30), randomUnlockedVehicleChance = GetConvarInt("core:randomUnlockedVehicleChance", 30),
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1, disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1, useInventoryForKeys = GetConvarInt("core:useInventoryForKeys", 1) == 1,
@@ -68,7 +68,7 @@ AddEventHandler("playerJoining", function(oldId)
end) end)
local function checkDiscordIdentifier(identifiers) local function checkDiscordIdentifier(identifiers)
if not Config.discordBotToken or not Config.discordGuildId then return end if Config.discordBotToken == "false" or Config.discordGuildId == "false" then return end
local discordIdentifier = identifiers["discord"] local discordIdentifier = identifiers["discord"]
if not discordIdentifier then return end if not discordIdentifier then return end
@@ -77,13 +77,13 @@ local function checkDiscordIdentifier(identifiers)
end end
AddEventHandler("onResourceStart", function(name) AddEventHandler("onResourceStart", function(name)
if name ~= resourceName or not Config.discordBotToken or not Config.discordGuildId then return end if name ~= resourceName then return end
for _, playerId in ipairs(GetPlayers()) do for _, playerId in ipairs(GetPlayers()) do
local src = tonumber(playerId) local src = tonumber(playerId)
local identifiers = getIdentifierList(src) local identifiers = getIdentifierList(src)
PlayersInfo[src] = { PlayersInfo[src] = {
identifiers = identifiers, identifiers = identifiers,
discord = checkDiscordIdentifier(identifiers) discord = checkDiscordIdentifier(identifiers) or {}
} }
Wait(65) Wait(65)
end end
@@ -98,7 +98,7 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
deferrals.defer() deferrals.defer()
Wait(0) Wait(0)
if mainIdentifier then if mainIdentifier and Config.discordBotToken ~= "false" and Config.discordGuildId ~= "false" and not discordInfo then
discordInfo = checkDiscordIdentifier(identifiers) discordInfo = checkDiscordIdentifier(identifiers)
if not discordInfo then if not discordInfo then
deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite)) deferrals.done(("Your discord was not found, join our discord here: %s."):format(Config.discordInvite))