mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
update: discord identifier & player info
This commit is contained in:
@@ -74,6 +74,27 @@ AddEventHandler("playerJoining", function(oldId)
|
|||||||
tempPlayersInfo[oldId] = nil
|
tempPlayersInfo[oldId] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function checkDiscordIdentifier(identifiers)
|
||||||
|
if not Config.discordBotToken or not Config.discordGuildId then return end
|
||||||
|
|
||||||
|
local discordIdentifier = identifiers["discord"]
|
||||||
|
if not discordIdentifier then return end
|
||||||
|
|
||||||
|
return getDiscordInfo(discordIdentifier:gsub("discord:", ""))
|
||||||
|
end
|
||||||
|
|
||||||
|
AddEventHandler("onResourceStart", function(name)
|
||||||
|
if name ~= resourceName or not Config.discordBotToken or not Config.discordGuildId then return end
|
||||||
|
for _, playerId in ipairs(GetPlayers()) do
|
||||||
|
local src = tonumber(playerId)
|
||||||
|
local identifiers = getIdentifierList(src)
|
||||||
|
PlayersInfo[src] = {
|
||||||
|
identifiers = identifiers,
|
||||||
|
discord = checkDiscordIdentifier(identifiers)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
||||||
local tempSrc = source
|
local tempSrc = source
|
||||||
local identifiers = getIdentifierList(tempSrc)
|
local identifiers = getIdentifierList(tempSrc)
|
||||||
@@ -83,14 +104,12 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
|
|||||||
deferrals.defer()
|
deferrals.defer()
|
||||||
Wait(0)
|
Wait(0)
|
||||||
|
|
||||||
if mainIdentifier and Config.discordBotToken and Config.discordGuildId then
|
if mainIdentifier then
|
||||||
local discordIdentifier = identifiers["discord"]
|
discordInfo = checkDiscordIdentifier(identifiers)
|
||||||
if not discordIdentifier 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))
|
||||||
Wait(0)
|
Wait(0)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
discordInfo = getDiscordInfo(discordIdentifier:gsub("discord:", ""))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
deferrals.update("Connecting...")
|
deferrals.update("Connecting...")
|
||||||
|
|||||||
Reference in New Issue
Block a user