Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Client.lua
- ~~~~~~~~~~~~~~~~~~~~~
- ------------------------------------------------
- --- Discord Vehicle Whitelist, Made by FAXES ---
- ------------------------------------------------
- --- Config ---
- restrictedVehicles = {
- {"blazer5", "technical", "pounder2", "oppressor2", "menacer", "monster", "brutus", "monster3", "monster4", "monster5", "meneacer", "marshall", "insurgent3", "insurgent2", "insurgent", "dune5", "dune4", "dune3", "dune2", "caracara", "brutus3", "brutus2", "brutus1", "bruiser3", "bruiser2", "bruiser", "bralzer5", "technical3", "technical2", "technical1", "rcbandito", "nightshark", "bulldozer", "molotok", "seasparrow", "hauler2", "mule4", "speedo4", "hauler2", "cutter", "dump", "handler", "forklift", "tractor", "boxville2", "boxville5", "brickade", "pbus2", "rallytruck", "wasterlander", "phantom2", "cerberus", "cerberus2", "cerberus3", "issi3", "issi4", "issi5", "issi6", "cog552", "limo2", "clique", "deviant", "dominator4", "dominator5", "dominator6", "prototipo", "autarch", "Le7b", "deveste", "sheava", "tezeract", "vagner", "dukes2", "impaler", "impaler2", "impaler3", "impaler4", "imperator", "imperator2", "imperator3", "ruiner", "toros", "ruiner2", "ruiner3", "sabregt2", "slamvan4", "slamvan5", "slamvan6", "tampa3", "tulip", "vamos", "ardent", "deluxo", "stromberg", "italigto", "kuruma2", "revolter", "schlagen", "zr380", "zr3802", "zr3803", "deathbike", "deathbike2", "deathbike3", "oppressor", "oprressor2", "shotaro", "avenger2", "blimp", "blimp2", "blimp3", "bombushka", "cargoplane", "mogul", "nokota", "pyro", "rogue", "starling", "strikeforce", "tula", "volatol", "akula", "hunter", "savage", "valkyrie", "valkyrie2", "submersible", "submersible2", "tug", "policeold1", "policeold2", "vigilante", "voltic2", "scramjet", "adder", "banshee2", "bullet", "cheetah", "cyclone", "entityXF", "entity2", "fmj", "gp1", "infernus", "ItaliGTB", "ItaliGTB2", "nero", "nero2", "osiris", "penetrator", "pfister811", "reaper", "sc1", "sultanRS", "t20", "taipan", "tempesta", "turismor", "tyrus", "vacca", "visione", "voltic", "xa21", "zentorno",}, -- This relates to the first item in the roleList (Civ)
- {"mammatus"}, --
- {"stunt", "cuban800", "dodo", "duster", "velum", "velum2", "vestra"}, --
- {"buzzard2", "frogger", "frogger2", "maverick", "supervolito2", "swift", "swift2", "volatus"}, --
- {"supervolito"}, --
- {"polmav"}, --
- {"jet", "luxor", "luxor2", "miljet", "nimbus", "shamal", "739", "747sp", "767300", "779x", "788", "a321neo", "a330neo", "a343", "a350"}, --
- {"cargoplane", "skylift"}, --
- {"cargobob", "cargobob2", "cargobob3", "cargobob4", "titan", "emb145", "falcon7x", "firehawk", "pavehawk", "buzzard", "valkyrie", "valkyrie2", "annihilator", "savage"}, --
- {"a10t", "f22t", "lazer", "hydra", "f16cas", "f16vista", "flankerf", "samson", "besra"}, --
- {"f15c"}, --
- }
- --- Code ---
- AddEventHandler('playerSpawned', function()
- local src = source
- TriggerServerEvent("FaxDisVeh:CheckPermission", src)
- end)
- allowedList = {}
- RegisterNetEvent("FaxDisVeh:CheckPermission:Return")
- AddEventHandler("FaxDisVeh:CheckPermission:Return", function(allowedVehicles, error)
- if error then
- print("[FAX DISCORD VEHICLE WHITELIST ERROR] No Discord identifier was found! Permissions set to false")
- end
- allowedList = allowedVehicles
- end)
- local function has_value (tab, val)
- for index, value in ipairs(tab) do
- if value == val then
- return true
- end
- end
- return false
- end
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(400)
- local ped = PlayerPedId()
- local veh = nil
- if IsPedInAnyVehicle(ped, false) then
- veh = GetVehiclePedIsUsing(ped)
- else
- veh = GetVehiclePedIsTryingToEnter(ped)
- end
- if veh and DoesEntityExist(veh) then
- local model = GetEntityModel(veh)
- local driver = GetPedInVehicleSeat(veh, -1)
- -- Check if it has one of the restricted vehicles
- local endLoop = false
- local requiredPerm = nil
- for i = 1, #restrictedVehicles do
- for j = 1, #restrictedVehicles[i] do
- if GetHashKey(restrictedVehicles[i][j]) == model then
- -- It requires a permission
- requiredPerm = i
- endLoop = true
- --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "Requires perm = " .. tostring(i)}}) -- TODO debug - get rid of
- break
- end
- end
- if endLoop then
- break
- end
- end
- local hasPerm = false
- if requiredPerm ~= nil then
- --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "RequiredPerm != nil"}}) -- TODO debug - get rid of
- if has_value(allowedList, requiredPerm) then
- --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "hasPerm = true"}}) -- TODO debug - get rid of
- hasPerm = true
- end
- end
- --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "Value of hasPerm = " .. tostring(hasPerm)}}) -- TODO debug - get rid of
- -- If doesn't have permission, it's a restricted vehicle to them
- if not hasPerm and (requiredPerm ~= nil) then
- if driver == ped then
- ShowInfo("~r~Restricted Vehicle Model.")
- DeleteEntity(veh)
- ClearPedTasksImmediately(ped)
- end
- end
- end
- -- local src = source
- -- TriggerServerEvent("FaxDisVeh:CheckPermission", src)
- end
- end)
- --- Functions ---
- function ShowInfo(text)
- SetNotificationTextEntry("STRING")
- AddTextComponentSubstringPlayerName(text)
- DrawNotification(false, false)
- end
- function DeleteE(entity)
- Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
- end
- Server.lua
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ------------------------------------------------
- --- Discord Vehicle Whitelist, Made by FAXES ---
- ------------------------------------------------
- --- Config ---
- --[[
- REPLACE THE '1's WITH YOUR DISCORD ROLES' IDs
- ]]
- -- THESE NEED TO BE THE RESPECTIVE ROLE IDs OF YOUR DISCORD ROLES:
- roleList = {
- 590349760745963521, -- Civ
- 592075470984708101, -- Trusted Civ
- 594459263125159947, -- Trusted Civ
- 590639169261273088, -- Trusted Civ
- 592577315691823104, -- Trusted Civ
- 590651120020619275, -- Trusted Civ
- 590639367840858112, -- Trusted Civ
- 592075862669525004, -- Trusted Civ
- 592075844286021683, -- Trusted Civ
- 592282240491323426, -- Trusted Civ
- 592952561523490828, -- Trusted Civ
- }
- --- Code ---
- RegisterServerEvent("FaxDisVeh:CheckPermission")
- AddEventHandler("FaxDisVeh:CheckPermission", function(_source)
- local src = source
- local allowedVehicles = {}
- for k, v in ipairs(GetPlayerIdentifiers(src)) do
- if string.sub(v, 1, string.len("discord:")) == "discord:" then
- identifierDiscord = v
- end
- end
- -- TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false)
- if identifierDiscord then
- local roles = exports.discord_perms:GetRoles(src)
- if not (roles == false) then
- for i = 1, #roles do
- for j = 1, #roleList do
- print("roles[i] " .. tostring(roles[i]) .. " equal to roleList[j] " .. tostring(roleList[j]) .. " ? ")
- if tonumber(roles[i]) == tonumber(roleList[j]) then
- -- Return the index back to the Client script
- table.insert(allowedVehicles, j)
- end
- end
- end
- else
- print(GetPlayerName(src) .. " did not receive permissions because roles == false")
- end
- elseif identifierDiscord == nil then
- print("identifierDiscord == nil")
- end
- -- Trigger client event
- TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, allowedVehicles, true)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement