feat: admin perms

This commit is contained in:
Andyyy7666
2022-11-30 03:32:52 +01:00
parent 2fb940fe7e
commit 44d1351a5c
3 changed files with 19 additions and 4 deletions

View File

@@ -364,10 +364,14 @@ function NDCore.Functions.SetPlayerData(player, key, value)
TriggerClientEvent("ND:updateCharacter", player, NDCore.Players[player])
end
-- Saves player inventory to the database.
function NDCore.Functions.SaveInventory(player)
local inventory = NDCore.Players[player].inventory
MySQL.query("UPDATE `characters` SET inventory = ? WHERE character_id = ?", {json.encode(inventory), NDCore.Players[player].id})
function NDCore.Functions.IsPlayerAdmin(src)
local discordInfo = NDCore.PlayersDiscordInfo[src]
if not discordInfo or not discordInfo.roles then return end
for _, adminRole in pairs(config.adminRoles) do
for _, role in pairs(discordInfo.roles) do
if role == adminRole then return true end
end
end
end
function NDCore.Functions.VersionChecker(expectedResourceName, resourceName, downloadLink, rawGithubLink)

View File

@@ -3,6 +3,8 @@
NDCore = {}
NDCore.Players = {}
NDCore.Functions = {}
NDCore.Commands = {}
NDCore.PlayersDiscordInfo = {}
NDCore.Config = config
function GetCoreObject()
@@ -30,4 +32,8 @@ AddEventHandler("onResourceStart", function(resourceName)
end)
if GetResourceState("ox_inventory") == "started" then
SetConvarReplicated("inventory:framework", "nd")
end
for _, roleid in pairs(config.adminRoles) do
ExecuteCommand("add_principal identifier.discord:" .. roleid .. " group.admin")
end