From dc96be53d76d0a8245bca718de3285e615d4f76c Mon Sep 17 00:00:00 2001 From: FAXES <31368070+FAXES@users.noreply.github.com> Date: Sun, 16 Jun 2019 21:42:25 +1000 Subject: [PATCH] 1.1 Update --- client.lua | 25 +++++++++++++------------ server.lua | 17 +++++++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/client.lua b/client.lua index 634faa2..62f223f 100644 --- a/client.lua +++ b/client.lua @@ -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() @@ -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 @@ -73,3 +71,6 @@ function ShowInfo(text) AddTextComponentSubstringPlayerName(text) DrawNotification(false, false) end +function DeleteE(entity) + Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity)) +end diff --git a/server.lua b/server.lua index 2b100f9..8e18120 100644 --- a/server.lua +++ b/server.lua @@ -4,7 +4,11 @@ --- 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 --- @@ -12,7 +16,6 @@ roleNeeded = "ROLE_NAME_HERE" -- Role needed to bypass the Discord vehicle white 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 @@ -20,10 +23,12 @@ AddEventHandler("FaxDisVeh:CheckPermission", function(_source) 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)