Skip to content

Commit

Permalink
2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FAXES authored Sep 17, 2020
1 parent 12aead1 commit 5e100bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 42 deletions.
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# DiscordVehicleWhitelist
A Discord vehicle white-list script for FiveM
**Discord Vehicle Whitelist- By FAXES**
### 📠 [Discord Vehicle Whitelist][5mlink] 📠

## [Support Discord](https://faxes.zone/discord)
[![Discord](https://faxes.zone/i/9wkr3.png)](https://faxes.zone/discord)

**About**
Hello all. For my 40th release here on the forums, I thought let's make it something cool(ish)? So I introduce to you a Discord (role) Vehicle Whitelist! This is a nice simple script, easy to set up (for people that can read). It allows you to guess? Make a vehicle whitelist based on a users role in Discord. This has been requested a few times so here she is, for you!
----

**Features**
- Vehicle whitelist, based on Discord roles
- Easy config (just read...)
- Checks for role updates every player respawn
This is a nice simple script, easy to set up (for people that can read). It allows you to guess? Make a vehicle whitelist based on a users role in Discord.

**Requirements**
@IllusiveTea's [Discord Role For Permission Script](https://forum.fivem.net/t/discord-roles-for-permissions-im-creative-i-know/233805) - **Ensure that it is the one from the master branch!**
**Documentation:**
- [FAXES Documentation Site](https://docs.faxes.zone/docs)
- [FAXES ACE Permission Documentation](https://docs.faxes.zone/docs/aceperms)
- [Getting Your Steam Hexadecimal](https://docs.faxes.zone/docs/getting-your-steam-hex)

**Installation**
https://docs.faxes.zone/docs/discord-vehicle-whitelist-setup/
**Credits:**
- FAXES
- Astra
- IllusiveTea

<hr>
<br />

**Credits**
@IllusiveTea for his resource
[![FiveM](https://faxes.zone/i/r5byi.png)][5mlink]

If you have any issues or comments please put them below. :newspaper:
[5mlink]: https://forum.cfx.re/t/521569
4 changes: 3 additions & 1 deletion client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
--- Discord Vehicle Whitelist, Made by FAXES ---
------------------------------------------------

-- VIEW THE DOCS - https://docs.faxes.zone/docs/discord-vehicle-whitelist-setup

--- Config ---

-- List of vehicle classes: https://runtime.fivem.net/doc/natives/?_0x29439776AAA00A62
Expand All @@ -22,7 +24,7 @@ end)
RegisterNetEvent("FaxDisVeh:CheckPermission:Return")
AddEventHandler("FaxDisVeh:CheckPermission:Return", function(havePerms, error)
if error then
print("^1No Discord identifier was found! ^rPermissions set to false. See this link for a debugging process - docs.faxes.zone/docs/debugging-discord")
print("^1No Discord identifier/guild was found! ^rPermissions set to false. See this link for a debugging process - docs.faxes.zone/docs/debugging-discord")
end
if havePerms then
cHavePerms = true
Expand Down
31 changes: 8 additions & 23 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,23 @@ local whitelistRoles = { -- Role(s) needed to bypass the Discord vehicle whiteli
RegisterServerEvent("FaxDisVeh:CheckPermission")
AddEventHandler("FaxDisVeh:CheckPermission", function()
local src = source
local passAuth = false

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
usersRoles = exports.discord_perms:GetRoles(src)
local function has_value(table, val)
if table then
for index, value in ipairs(table) do
if value == val then
return true
end
end
end
return false
end
for index, valueReq in ipairs(whitelistRoles) do
if has_value(usersRoles, valueReq) then
passAuth = true
exports['discordroles']:isRolePresent(src, whitelistRoles, function(hasRole, roles)
if not roles then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, true)
end
if next(whitelistRoles,index) == nil then
if passAuth == true then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false)
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, false)
end
if hasRole then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false)
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, false)
end
end
end)
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, true)
end
Expand Down

0 comments on commit 5e100bb

Please sign in to comment.