diff --git a/License.md b/License.md index 7b937c6..2af50c3 100644 --- a/License.md +++ b/License.md @@ -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") diff --git a/client.lua b/client.lua index 62f223f..9fa0d89 100644 --- a/client.lua +++ b/client.lua @@ -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", } @@ -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 @@ -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 @@ -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)) diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..370428b --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,10 @@ +---------------------------------------- +--- Discord Whitelist, Made by FAXES --- +---------------------------------------- + +fx_version 'bodacious' +game 'gta5' +author 'FAXES' + +server_script 'server.lua' +client_script 'client.lua' diff --git a/server.lua b/server.lua index 8e18120..5d81008 100644 --- a/server.lua +++ b/server.lua @@ -4,18 +4,18 @@ --- 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 @@ -23,14 +23,30 @@ AddEventHandler("FaxDisVeh:CheckPermission", function(_source) 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) \ No newline at end of file