Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FAXES authored May 18, 2020
1 parent 45f6bf4 commit 34ec724
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
6 changes: 1 addition & 5 deletions License.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
12 changes: 12 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -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'
42 changes: 28 additions & 14 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 34ec724

Please sign in to comment.