diff --git a/License.md b/License.md new file mode 100644 index 0000000..7b937c6 --- /dev/null +++ b/License.md @@ -0,0 +1,26 @@ +## Terms of Use + +(Below the term "product" is used to describe the script / modification) + +This product is freeware and is not to be exploited for personal, financial or commercial gain. This product is provided without any form of warranty. +Therefore, responsibility for any damages caused by this product or its misuse rest solely with the user, as the author(s) will accept no liability. + +- This copy of terms must remain in its original state and must not be modified in anyway + +- These terms must be alongside the product at all times + +- Do not re-release with out permission (just ask for permission) + +- Do not redistribute to any other sites. This product is only to be published on verified sites by FAXES + +- Editing / abusing these terms will result in action + +- Do not take credit for product. Removing credits from inside the products file(s) is prohibited + +### Summary +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") diff --git a/__resource.lua b/__resource.lua new file mode 100644 index 0000000..5123ce4 --- /dev/null +++ b/__resource.lua @@ -0,0 +1,8 @@ +------------------------------------------------ +--- Discord Vehicle Whitelist, Made by FAXES --- +------------------------------------------------ + +resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937" + +client_script "client.lua" +server_script "server.lua" \ No newline at end of file diff --git a/client.lua b/client.lua new file mode 100644 index 0000000..a654e7a --- /dev/null +++ b/client.lua @@ -0,0 +1,78 @@ +------------------------------------------------ +--- Discord Vehicle Whitelist, Made by FAXES --- +------------------------------------------------ + +--- Config --- + +blacklistedVehicles = { + "POLICE", + "POLICE2", + "POLICE3", +} + +--- Code --- +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) + + if not cHavePerms then + 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) + + 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 + -- 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 diff --git a/server.lua b/server.lua new file mode 100644 index 0000000..2b100f9 --- /dev/null +++ b/server.lua @@ -0,0 +1,31 @@ +------------------------------------------------ +--- Discord Vehicle Whitelist, Made by FAXES --- +------------------------------------------------ + +--- Config --- + +roleNeeded = "ROLE_NAME_HERE" -- Role needed to bypass the Discord vehicle whitelist (be able to use the listed vehicles). + + +--- 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) + end + elseif identifierDiscord == nil then + TriggerClientEvent("FaxDisVeh:CheckPermission:Return", src, false, true) + end +end) \ No newline at end of file