tweak: get player discord info

This commit is contained in:
Andyyy7666
2022-11-30 03:36:38 +01:00
parent 93e704832f
commit 2534282d2a

View File

@@ -29,15 +29,6 @@ AddEventHandler("playerConnecting", function(name, setKickReason, deferrals)
end end
end) end)
-- Creating database tables
AddEventHandler("onResourceStart", function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
MySQL.query("CREATE TABLE IF NOT EXISTS characters ( `character_id` INT(10) NOT NULL AUTO_INCREMENT, `license` VARCHAR(200) NOT NULL DEFAULT '0', `first_name` VARCHAR(50) NULL DEFAULT NULL, `last_name` VARCHAR(50) NULL DEFAULT NULL, `dob` VARCHAR(50) NULL DEFAULT NULL, `gender` VARCHAR(50) NULL DEFAULT NULL,`twt` VARCHAR(50) NULL DEFAULT NULL, `job` VARCHAR(50) NULL DEFAULT NULL, `cash` INT(10) NULL DEFAULT '0', `bank` INT(10) NULL DEFAULT '0', `phone_number` VARCHAR(20) NULL DEFAULT NULL, `groups` LONGTEXT NULL DEFAULT '[]', `last_location` LONGTEXT NULL DEFAULT '[]', `clothing` LONGTEXT NULL DEFAULT '[]', PRIMARY KEY (`character_id`) USING BTREE);")
print('^4ND_Core ^0Database structure validated!')
end)
-- Getting all the characters the player has and returning them to the client. -- Getting all the characters the player has and returning them to the client.
RegisterNetEvent("ND:GetCharacters", function() RegisterNetEvent("ND:GetCharacters", function()
local player = source local player = source
@@ -91,8 +82,27 @@ AddEventHandler("playerDropped", function()
character = nil character = nil
end) end)
-- Update the characters clothes. -- Get player discord info on join.
RegisterNetEvent("ND:updateClothes", function(clothing) AddEventHandler("playerJoining", function()
local player = source local src = source
NDCore.Functions.UpdateClothes(NDCore.Players[player].id, clothing)
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", src):gsub("discord:", "")
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
NDCore.PlayersDiscordInfo[src] = discordInfo
end) end)
AddEventHandler("onResourceStart", function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
Wait(1000)
if not next(NDCore.PlayersDiscordInfo) then
for _, playerId in ipairs(GetPlayers()) do
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", playerId):gsub("discord:", "")
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
NDCore.PlayersDiscordInfo[tonumber(playerId)] = discordInfo
end
end
end)