Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------
- --- Discord ACE Perms by Badger ---
- -----------------------------------
- --- Code ---
- roleList = {
- {642761616219439115, "group.statepolice"}, --[[ State-Police --- ]]
- {641776762581155862, "group.bronzetier"}, --[[ Bronze-Tier --- ]]
- {641776666045186078, "group.silvertier"}, --[[ Silver-Tier --- ]]
- {641776521216000010, "group.goldtier"}, --[[ Gold-Tier --- ]]
- {631860880895901711, "group.staffteam"}, --[[ Staff-Team --- ]]
- {586651829325266986, "group.tmod"}, --[[ Trial-Moderator --- ]]
- {586651930433028097, "group.moderator"}, --[[ Moderator --- ]]
- {586651734139469828, "group.admin"}, --[[ Admin --- ]]
- {627532142724775936, "group.management"}, --[[ Management --- ]]
- }
- local function has_value (tab, val)
- for index, value in ipairs(tab) do
- if value == val then
- return true
- end
- end
- return false
- end
- function PlayerIdentifier(type, id)
- local identifiers = {}
- local numIdentifiers = GetNumPlayerIdentifiers(id)
- for a = 0, numIdentifiers do
- table.insert(identifiers, GetPlayerIdentifier(id, a))
- end
- for b = 1, #identifiers do
- if string.find(identifiers[b], type, 1) then
- return identifiers[b]
- end
- end
- return false
- end
- function stringsplit(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={} ; i=1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- return t
- end
- hasPermsAlready = {}
- AddEventHandler('playerConnecting', function()
- local src = source
- local hex = string.sub(tostring(PlayerIdentifier("steam", src)), 7)
- permAdd = "add_principal identifier.steam:" .. hex .. " "
- 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
- if not has_value(hasPermsAlready, GetPlayerName(src)) then
- local roleIDs = exports.discord_perms:GetRoles(src)
- if not (roleIDs == false) then
- for i = 1, #roleList do
- for j = 1, #roleIDs do
- if (tostring(roleList[i][1]) == tostring(roleIDs[j])) then
- print("Added " .. GetPlayerName(src) .. " to role group " .. roleList[i][2] .. " with discordRole ID: " .. roleIDs[j])
- ExecuteCommand(permAdd .. roleList[i][2])
- end
- end
- end
- table.insert(hasPermsAlready, GetPlayerName(src))
- else
- print(GetPlayerName(src) .. " has not gotten their permissions cause roleIDs == false")
- end
- end
- end
- end)
- RegisterServerEvent("DiscordAcePerms:GivePerms")
- AddEventHandler("DiscordAcePerms:GivePerms", function(_source)
- -- Deprecated
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement