mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
feat: admin perms
This commit is contained in:
@@ -17,6 +17,11 @@ config = {
|
||||
"872921520719142932"
|
||||
},
|
||||
|
||||
-- These are admins roles that will give a user permission to admin commands and more.
|
||||
adminRoles = {
|
||||
"872921520719142932"
|
||||
},
|
||||
|
||||
-- Discord Rich presence
|
||||
enableRichPresence = true,
|
||||
updateIntervall = 60, -- how many seconds of delay until it updates status.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
NDCore = {}
|
||||
NDCore.Players = {}
|
||||
NDCore.Functions = {}
|
||||
NDCore.Commands = {}
|
||||
NDCore.PlayersDiscordInfo = {}
|
||||
NDCore.Config = config
|
||||
|
||||
function GetCoreObject()
|
||||
@@ -31,3 +33,7 @@ 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
|
||||
Reference in New Issue
Block a user