Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.54 KB | None | 0 0
  1. Client.lua
  2. ~~~~~~~~~~~~~~~~~~~~~
  3. ------------------------------------------------
  4. --- Discord Vehicle Whitelist, Made by FAXES ---
  5. ------------------------------------------------
  6.  
  7. --- Config ---
  8.  
  9. restrictedVehicles = {
  10. {"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)
  11. {"mammatus"}, --
  12. {"stunt", "cuban800", "dodo", "duster", "velum", "velum2", "vestra"}, --
  13. {"buzzard2", "frogger", "frogger2", "maverick", "supervolito2", "swift", "swift2", "volatus"}, --
  14. {"supervolito"}, --
  15. {"polmav"}, --
  16. {"jet", "luxor", "luxor2", "miljet", "nimbus", "shamal", "739", "747sp", "767300", "779x", "788", "a321neo", "a330neo", "a343", "a350"}, --
  17. {"cargoplane", "skylift"}, --
  18. {"cargobob", "cargobob2", "cargobob3", "cargobob4", "titan", "emb145", "falcon7x", "firehawk", "pavehawk", "buzzard", "valkyrie", "valkyrie2", "annihilator", "savage"}, --
  19. {"a10t", "f22t", "lazer", "hydra", "f16cas", "f16vista", "flankerf", "samson", "besra"}, --
  20. {"f15c"}, --
  21. }
  22.  
  23. --- Code ---
  24.  
  25. AddEventHandler('playerSpawned', function()
  26. local src = source
  27. TriggerServerEvent("FaxDisVeh:CheckPermission", src)
  28. end)
  29.  
  30. allowedList = {}
  31.  
  32. RegisterNetEvent("FaxDisVeh:CheckPermission:Return")
  33. AddEventHandler("FaxDisVeh:CheckPermission:Return", function(allowedVehicles, error)
  34. if error then
  35. print("[FAX DISCORD VEHICLE WHITELIST ERROR] No Discord identifier was found! Permissions set to false")
  36. end
  37. allowedList = allowedVehicles
  38. end)
  39.  
  40. local function has_value (tab, val)
  41. for index, value in ipairs(tab) do
  42. if value == val then
  43. return true
  44. end
  45. end
  46. return false
  47. end
  48.  
  49. Citizen.CreateThread(function()
  50. while true do
  51. Citizen.Wait(400)
  52.  
  53. local ped = PlayerPedId()
  54. local veh = nil
  55.  
  56. if IsPedInAnyVehicle(ped, false) then
  57. veh = GetVehiclePedIsUsing(ped)
  58. else
  59. veh = GetVehiclePedIsTryingToEnter(ped)
  60. end
  61.  
  62. if veh and DoesEntityExist(veh) then
  63. local model = GetEntityModel(veh)
  64. local driver = GetPedInVehicleSeat(veh, -1)
  65. -- Check if it has one of the restricted vehicles
  66. local endLoop = false
  67. local requiredPerm = nil
  68. for i = 1, #restrictedVehicles do
  69. for j = 1, #restrictedVehicles[i] do
  70. if GetHashKey(restrictedVehicles[i][j]) == model then
  71. -- It requires a permission
  72. requiredPerm = i
  73. endLoop = true
  74. --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "Requires perm = " .. tostring(i)}}) -- TODO debug - get rid of
  75. break
  76. end
  77. end
  78. if endLoop then
  79. break
  80. end
  81. end
  82. local hasPerm = false
  83. if requiredPerm ~= nil then
  84. --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "RequiredPerm != nil"}}) -- TODO debug - get rid of
  85. if has_value(allowedList, requiredPerm) then
  86. --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "hasPerm = true"}}) -- TODO debug - get rid of
  87. hasPerm = true
  88. end
  89. end
  90. --TriggerEvent('chat:addMessage', {color = { 255, 0, 0}, multiline = true, args = {"Me", "Value of hasPerm = " .. tostring(hasPerm)}}) -- TODO debug - get rid of
  91. -- If doesn't have permission, it's a restricted vehicle to them
  92. if not hasPerm and (requiredPerm ~= nil) then
  93. if driver == ped then
  94. ShowInfo("~r~Restricted Vehicle Model.")
  95. DeleteEntity(veh)
  96. ClearPedTasksImmediately(ped)
  97. end
  98. end
  99. end
  100. -- local src = source
  101. -- TriggerServerEvent("FaxDisVeh:CheckPermission", src)
  102. end
  103. end)
  104.  
  105. --- Functions ---
  106. function ShowInfo(text)
  107. SetNotificationTextEntry("STRING")
  108. AddTextComponentSubstringPlayerName(text)
  109. DrawNotification(false, false)
  110. end
  111. function DeleteE(entity)
  112. Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
  113. end
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. Server.lua
  121. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. ------------------------------------------------
  123. --- Discord Vehicle Whitelist, Made by FAXES ---
  124. ------------------------------------------------
  125.  
  126. --- Config ---
  127.  
  128. --[[
  129. REPLACE THE '1's WITH YOUR DISCORD ROLES' IDs
  130. ]]
  131. -- THESE NEED TO BE THE RESPECTIVE ROLE IDs OF YOUR DISCORD ROLES:
  132. roleList = {
  133. 590349760745963521, -- Civ
  134. 592075470984708101, -- Trusted Civ
  135. 594459263125159947, -- Trusted Civ
  136. 590639169261273088, -- Trusted Civ
  137. 592577315691823104, -- Trusted Civ
  138. 590651120020619275, -- Trusted Civ
  139. 590639367840858112, -- Trusted Civ
  140. 592075862669525004, -- Trusted Civ
  141. 592075844286021683, -- Trusted Civ
  142. 592282240491323426, -- Trusted Civ
  143. 592952561523490828, -- Trusted Civ
  144. }
  145.  
  146.  
  147. --- Code ---
  148.  
  149. RegisterServerEvent("FaxDisVeh:CheckPermission")
  150. AddEventHandler("FaxDisVeh:CheckPermission", function(_source)
  151. local src = source
  152. local allowedVehicles = {}
  153. for k, v in ipairs(GetPlayerIdentifiers(src)) do
  154. if string.sub(v, 1, string.len("discord:")) == "discord:" then
  155. identifierDiscord = v
  156. end
  157. end
  158. -- TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, true, false)
  159. if identifierDiscord then
  160. local roles = exports.discord_perms:GetRoles(src)
  161. if not (roles == false) then
  162. for i = 1, #roles do
  163. for j = 1, #roleList do
  164. print("roles[i] " .. tostring(roles[i]) .. " equal to roleList[j] " .. tostring(roleList[j]) .. " ? ")
  165. if tonumber(roles[i]) == tonumber(roleList[j]) then
  166. -- Return the index back to the Client script
  167. table.insert(allowedVehicles, j)
  168. end
  169. end
  170. end
  171. else
  172. print(GetPlayerName(src) .. " did not receive permissions because roles == false")
  173. end
  174. elseif identifierDiscord == nil then
  175. print("identifierDiscord == nil")
  176. end
  177. -- Trigger client event
  178. TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, allowedVehicles, true)
  179. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement