SHARE
TWEET

Untitled

a guest Nov 14th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -----------------------------------
  2. --- Discord ACE Perms by Badger ---
  3. -----------------------------------
  4.  
  5. --- Code ---
  6.  
  7. roleList = {
  8. {642761616219439115, "group.statepolice"}, --[[ State-Police --- ]]
  9. {641776762581155862, "group.bronzetier"}, --[[ Bronze-Tier --- ]]
  10. {641776666045186078, "group.silvertier"}, --[[ Silver-Tier --- ]]
  11. {641776521216000010, "group.goldtier"}, --[[ Gold-Tier --- ]]
  12. {631860880895901711, "group.staffteam"}, --[[ Staff-Team --- ]]
  13. {586651829325266986, "group.tmod"}, --[[ Trial-Moderator --- ]]
  14. {586651930433028097, "group.moderator"}, --[[ Moderator --- ]]
  15. {586651734139469828, "group.admin"}, --[[ Admin --- ]]
  16. {627532142724775936, "group.management"}, --[[ Management --- ]]
  17. }
  18. local function has_value (tab, val)
  19.     for index, value in ipairs(tab) do
  20.         if value == val then
  21.             return true
  22.         end
  23.     end
  24.  
  25.     return false
  26. end
  27. function PlayerIdentifier(type, id)
  28.     local identifiers = {}
  29.     local numIdentifiers = GetNumPlayerIdentifiers(id)
  30.  
  31.     for a = 0, numIdentifiers do
  32.         table.insert(identifiers, GetPlayerIdentifier(id, a))
  33.     end
  34.  
  35.     for b = 1, #identifiers do
  36.         if string.find(identifiers[b], type, 1) then
  37.             return identifiers[b]
  38.         end
  39.     end
  40.     return false
  41. end
  42. function stringsplit(inputstr, sep)
  43.     if sep == nil then
  44.         sep = "%s"
  45.     end
  46.     local t={} ; i=1
  47.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  48.         t[i] = str
  49.         i = i + 1
  50.     end
  51.     return t
  52. end
  53.  
  54. hasPermsAlready = {}
  55.  
  56. AddEventHandler('playerConnecting', function()
  57.     local src = source
  58.     local hex = string.sub(tostring(PlayerIdentifier("steam", src)), 7)
  59.     permAdd = "add_principal identifier.steam:" .. hex .. " "
  60.     for k, v in ipairs(GetPlayerIdentifiers(src)) do
  61.             if string.sub(v, 1, string.len("discord:")) == "discord:" then
  62.                 identifierDiscord = v
  63.             end
  64.     end
  65.     if identifierDiscord then
  66.         if not has_value(hasPermsAlready, GetPlayerName(src)) then
  67.             local roleIDs = exports.discord_perms:GetRoles(src)
  68.             if not (roleIDs == false) then
  69.                 for i = 1, #roleList do
  70.                     for j = 1, #roleIDs do
  71.                         if (tostring(roleList[i][1]) == tostring(roleIDs[j])) then
  72.                             print("Added " .. GetPlayerName(src) .. " to role group " .. roleList[i][2] .. " with discordRole ID: " .. roleIDs[j])
  73.                             ExecuteCommand(permAdd .. roleList[i][2])
  74.                         end
  75.                     end
  76.                 end
  77.                 table.insert(hasPermsAlready, GetPlayerName(src))
  78.             else
  79.                 print(GetPlayerName(src) .. " has not gotten their permissions cause roleIDs == false")
  80.             end
  81.         end
  82.     end
  83. end)
  84.  
  85. RegisterServerEvent("DiscordAcePerms:GivePerms")
  86. AddEventHandler("DiscordAcePerms:GivePerms", function(_source)
  87.     -- Deprecated
  88. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top