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"
|
"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.
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user