Skip to content

Commit

Permalink
1.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
FAXES authored Jun 16, 2019
1 parent d59a510 commit dc96be5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
25 changes: 13 additions & 12 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,25 @@ cHavePerms = false

AddEventHandler('playerSpawned', function()
local src = source
-- print("THIS?") -- DEBUGGING
TriggerServerEvent("FaxDisVeh:CheckPermission", src)
end)

RegisterNetEvent("FaxDisVeh:CheckPermission:Return")
AddEventHandler("FaxDisVeh:CheckPermission:Return", function(havePerms, error)
-- print("TRIGGERED") -- DEBUGGING
if error then
print("[FAX DISCORD VEHICLE WHITELIST ERROR] No Discord identifier was found! Permissions set to false")
end

if havePerms then
cHavePerms = true
-- print("true") -- DEBUGGING
else
cHavePerms = false
-- print("false") -- DEBUGGING
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(500)
Citizen.Wait(400)

if not cHavePerms then
local ped = PlayerPedId()
Expand All @@ -51,13 +47,15 @@ Citizen.CreateThread(function()

if veh and DoesEntityExist(veh) then
local model = GetEntityModel(veh)

for i = 1, #blacklistedVehicles do
local restrictedVehicleModel = GetHashKey(blacklistedVehicles[i])
if (model == restrictedVehicleModel) then
ShowInfo("~r~Restricted Vehicle Model.")
DeleteEntity(veh)
ClearPedTasksImmediately(ped)
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)
end
end
end
end
Expand All @@ -73,3 +71,6 @@ function ShowInfo(text)
AddTextComponentSubstringPlayerName(text)
DrawNotification(false, false)
end
function DeleteE(entity)
Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
end
17 changes: 11 additions & 6 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@

--- Config ---

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


--- Code ---

RegisterServerEvent("FaxDisVeh:CheckPermission")
AddEventHandler("FaxDisVeh:CheckPermission", function(_source)
local src = source
-- print("SERVER TRIG") -- DEBUGGING
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
if exports.discord_perms:IsRolePresent(src, roleNeeded) then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false) -- They have perms DEV: (perms pass, err pass)
else
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, false)
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)
end
end
elseif identifierDiscord == nil then
TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, true)
Expand Down

0 comments on commit dc96be5

Please sign in to comment.