forked from JaredScar/DiscordWeaponPerms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
53 lines (48 loc) · 1.77 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-------------------------------
-- ImprovedDiscordWeaponPerms -
--------IC-Technologies--------
-------------------------------
RegisterNetEvent("ImprovedDiscordWeaponPerms:CheckPerms")
AddEventHandler("ImprovedDiscordWeaponPerms:CheckPerms", function()
local src = source
local userRoles = nil
for k, v in ipairs(GetPlayerIdentifiers(src)) do
if string.sub(v, 1, string.len("discord:")) == "discord:" then
identifierDiscord = v
end
end
if identifierDiscord then
local roleIDs = exports.Badger_Discord_API:GetDiscordRoles(src)
if not (roleIDs == false) then
userRoles = {}
for i = 1, #roleIDs do
for role, PEDs in pairs(Config.WeaponRestrictions) do
if exports.Badger_Discord_API:CheckEqual(role, roleIDs[i]) then
userRoles[role] = true;
DebugPrint(GetPlayerName(src) .. " has received permission for role: " .. tostring(role) );
if Config.InheritanceEnabled then
local inheritedRoles = Config.Inheritances[role];
if inheritedRoles ~= nil then
--There are inherited roles
for j = 1, #inheritedRoles do
userRoles[ inheritedRoles[j] ] = true;
DebugPrint(GetPlayerName(src) .. " has inherited role: " .. tostring(inheritedRoles[j]));
end
end
end
end
end
end
else
DebugPrint(GetPlayerName(src) .. " has not gotten their permissions because roleIDs == false")
end
elseif identifierDiscord == nil then
DebugPrint(GetPlayerName(src) .. " did not recieve permissions because they do not have a discord identifier.")
end
TriggerClientEvent('ImprovedDiscordWeaponPerms:CheckPerms:Return', src, userRoles)
end)
function DebugPrint(message)
if Config.debugMode then
print("[ImprovedDiscordWeaponPerms] " .. message)
end
end