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

@@ -17,6 +17,11 @@ config = {
"872921520719142932" "872921520719142932"
}, },
-- These are admins roles that will give a user permission to admin commands and more.
adminRoles = {
"872921520719142932"
},
-- Discord Rich presence -- Discord Rich presence
enableRichPresence = true, enableRichPresence = true,
updateIntervall = 60, -- how many seconds of delay until it updates status. updateIntervall = 60, -- how many seconds of delay until it updates status.

View File

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

View File

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