diff --git a/License.md b/License.md index b812497..2af50c3 100644 --- a/License.md +++ b/License.md @@ -20,8 +20,4 @@ Therefore, responsibility for any damages caused by this product or its misuse r ### Summery So basically you can edit anything with the product (except the terms), but you can not release the product nor release the edited version without written permission from FAXES. -Terms are also available at -[www.faxes.zone/scripts/terms](http://faxes.zone/scripts/terms) - - -![alt text](http://faxes.zone/TOSlogos/FAXES%20ToUSML.png "FAXES ToU Icon") +![alt text](https://faxes.zone/TOSlogos/FAXES%20ToUSML.png "FAXES ToU Icon") diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..605f86b --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,12 @@ +---------------------------------------- +--- Discord Whitelist, Made by FAXES --- +---------------------------------------- + +fx_version 'bodacious' +game 'gta5' +server_only 'yes' + +author 'FAXES' +description 'Hate updating those ACE Permission white-lists? Well just use Discord! Now you can thanks to this script, and @IllusiveTeas. So keep white lists easy and breezy. This script checks the connecting players Discord roles and checks whether they have the specified role.' + +server_script 'server.lua' \ No newline at end of file diff --git a/server.lua b/server.lua index 13feeb5..f0538cf 100644 --- a/server.lua +++ b/server.lua @@ -2,23 +2,23 @@ --- Discord Whitelist, Made by FAXES --- ---------------------------------------- +-- Documentation: https://docs.faxes.zone/docs/discord-whitelist-setup --- Config --- -notWhitelisted = "You are not whitelisted for this server." -- Message displayed when they are not whitelist with the role -noDiscord = "You must have Discord open to join this server." -- Message displayed when discord is not found +notWhitelistedMessage = "You are not whitelisted for this server." -- Message displayed when they are not whitelist with the role -roles = { -- Role nickname(s) needed to pass the whitelist - "Role1", - "Role2", - "Role3", +whitelistRoles = { -- Role nickname(s) needed to pass the whitelist + "DISCORD_ROLE_ID", + "DISCORD_ROLE_ID", + "DISCORD_ROLE_ID", } - --- Code --- AddEventHandler("playerConnecting", function(name, setCallback, deferrals) local src = source + local passAuth = false deferrals.defer() - deferrals.update("Checking Permissions") + deferrals.update("Checking Permissions...") for k, v in ipairs(GetPlayerIdentifiers(src)) do if string.sub(v, 1, string.len("discord:")) == "discord:" then @@ -27,14 +27,28 @@ AddEventHandler("playerConnecting", function(name, setCallback, deferrals) end if identifierDiscord then - for i = 1, #roles do - if exports.discord_perms:IsRolePresent(src, roles[i]) then - deferrals.done() - else - deferrals.done(notWhitelisted) + usersRoles = exports.discord_perms:GetRoles(src) + local function has_value(table, val) + for index, value in ipairs(table) do + if value == val then + return true + end + end + return false + end + for index, valueReq in ipairs(whitelistRoles) do + if has_value(usersRoles, valueReq) then + passAuth = true + end + if next(whitelistRoles,index) == nil then + if passAuth == true then + deferrals.done() + else + deferrals.done(notWhitelistedMessage) + end end end else - deferrals.done(noDiscord) + deferrals.done("Discord was not detected. Please make sure Discord is running and installed. If it is make sure it's not Discord PTB. See the below link for a debugging process. docs.faxes.zone/docs/debugging-discord") end end) \ No newline at end of file