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 21, 2020
1 parent 14d07e2 commit b416d63
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 31 deletions.
7 changes: 2 additions & 5 deletions License.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ Therefore, responsibility for any damages caused by this product or its misuse r

- Do not take credit for product. Removing credits from inside the products file(s) is prohibited

### Summary
### 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.

#### Further Help
http://faxes.zone/discord

![alt text](http://faxes.zone/TOSlogos/FAXES%20ToUSML.png "FAXES ToU Icon")
![alt text](https://faxes.zone/TOSlogos/FAXES%20ToUSML.png "FAXES ToU Icon")
34 changes: 19 additions & 15 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

--- Config ---

-- List of vehicle classes: https://runtime.fivem.net/doc/natives/?_0x29439776AAA00A62
blacklistedVehicles = {
"POLICE",
"POLICE2",
"POLICE", -- This blacklists a vehicle model.
19, -- This restricts the millitary vehicle class.
"POLICE3",
}

Expand All @@ -21,9 +22,8 @@ end)
RegisterNetEvent("FaxDisVeh:CheckPermission:Return")
AddEventHandler("FaxDisVeh:CheckPermission:Return", function(havePerms, error)
if error then
print("[FAX DISCORD VEHICLE WHITELIST ERROR] No Discord identifier was found! Permissions set to false")
print("^1No Discord identifier 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
else
Expand All @@ -34,11 +34,9 @@ end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(400)

if not cHavePerms then
local ped = PlayerPedId()
local veh = nil

if IsPedInAnyVehicle(ped, false) then
veh = GetVehiclePedIsUsing(ped)
else
Expand All @@ -50,26 +48,32 @@ Citizen.CreateThread(function()
local driver = GetPedInVehicleSeat(veh, -1)
if driver == ped then
for i = 1, #blacklistedVehicles do
local restrictedVehicleModel = GetHashKey(blacklistedVehicles[i])
if (model == restrictedVehicleModel) then
ShowInfo("~r~Restricted Vehicle Model.")
DeleteEntity(veh)
ClearPedTasksImmediately(ped)
if type(blacklistedVehicles[i]) == "number" then
if GetVehicleClass(veh) == blacklistedVehicles[i] then
ShowInfo("~r~Restricted vehicle model.")
DeleteEntity(veh)
ClearPedTasksImmediately(ped)
end
elseif type(blacklistedVehicles[i]) == "string" then
local restrictedVehicleModel = GetHashKey(blacklistedVehicles[i])
if (model == restrictedVehicleModel) then
ShowInfo("~r~Restricted vehicle model.")
DeleteEntity(veh)
ClearPedTasksImmediately(ped)
end
end
end
end
end
end
-- local src = source
-- TriggerServerEvent("FaxDisVeh:CheckPermission", src)
end
end)

--- Functions ---
function ShowInfo(text)
SetNotificationTextEntry("STRING")
BeginTextCommandThefeedPost("STRING")
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
EndTextCommandThefeedPostTicker(false, false)
end
function DeleteE(entity)
Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
Expand Down
10 changes: 10 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
----------------------------------------
--- Discord Whitelist, Made by FAXES ---
----------------------------------------

fx_version 'bodacious'
game 'gta5'
author 'FAXES'

server_script 'server.lua'
client_script 'client.lua'
38 changes: 27 additions & 11 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,49 @@

--- Config ---

roles = { -- Role(s) needed to bypass the Discord vehicle whitelist (be able to use the listed vehicles).
"Role1",
"Role2",
"Role3",
local whitelistRoles = { -- Role(s) needed to bypass the Discord vehicle whitelist (be able to use the listed vehicles).
"DISCORD_ROLE_ID",
}


--- Code ---

RegisterServerEvent("FaxDisVeh:CheckPermission")
AddEventHandler("FaxDisVeh:CheckPermission", function(_source)
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
for i = 1, #roles do
if exports.discord_perms:IsRolePresent(src, roles[i]) then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false) -- They have perms DEV: (perms pass, err pass)
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, false)
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
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
end
end
elseif identifierDiscord == nil then
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, true)
end
end)

0 comments on commit b416d63

Please sign in to comment.