Files
Elite-Gaming-FiveM/resources/[EGRP-Discord-Integration]/Discord-WepRestriction/client.lua
T
Jacob c39103e896 Safe Zone air vehicles whitelist, updated holograms and scripts.
+ Updated Safe-Zones to whitelist air vehicles from being stopped.
+ Latest version of wl_wars2x police radar.
+ Updated weapon restrictions.
+ Fire-Scripts updated to latest version.
2022-01-16 16:06:50 +00:00

82 lines
4.6 KiB
Lua

--------------------------
--- DiscordWeaponPerms ---
--------------------------
restrictedWeapons = {
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 1
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 3
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 4
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 5
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 6
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 7
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 8
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 9
{"WEAPON_PROXMINE", "WEAPON_GRENADELAUNCHER", "WEAPON_RPG", "WEAPON_MINIGUN", "WEAPON_FIREWORK", "WEAPON_RAILGUN", "WEAPON_HOMINGLAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_COMPACTLAUNCHER", "WEAPON_RAYPISTOL", "WEAPON_RAYCARBINE", "WEAPON_RAYMINIGUN", "WEAPON_PIPEBOMB",}, -- 10
{}, -- 11
{}, -- 12
{}, -- 13
{}, -- 14
{}, -- 15
}
--[[
Weapon components list: https://wiki.rage.mp/index.php?title=Weapons_Components
Weapon list: https://runtime.fivem.net/doc/natives/#_0xBF0FD6E56C964FCB
]]--
isAllowed = {}
RegisterNetEvent('DiscordWeaponPerms:CheckPerms:Return')
AddEventHandler('DiscordWeaponPerms:CheckPerms:Return', function(hasPerms)
isAllowed = hasPerms
end)
function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
alreadyRan = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
if not alreadyRan then
TriggerServerEvent("DiscordWeaponPerms:CheckPerms")
alreadyRan = true
end
--TriggerServerEvent("Print:PrintDebug", "It gets here 1") -- DEBUG - GET RID OF
local ped = GetPlayerPed(-1)
local weapon = GetSelectedPedWeapon(ped)
local restrictedStr = ""
local requiredPerm = nil
for i=1, #restrictedWeapons do
local weaponArr = restrictedWeapons[i]
for j=1, #weaponArr do
-- Check if the weapon is restricted and for what group, or if it's the attachment
if weapon == GetHashKey(weaponArr[j]) then
-- This weapon is restricted unless they have this role perm
requiredPerm = i
restrictedStr = weaponArr[j]
break
elseif (HasPedGotWeaponComponent(ped, weapon, GetHashKey(weaponArr[j]))) then
-- It's restricted unless they have this role perm
requiredPerm = i
restrictedStr = weaponArr[j]
break
end
end
end
--TriggerServerEvent("Print:PrintDebug", "It gets here 2") -- DEBUG - GET RID OF
-- Check their perms
if not has_value(isAllowed, requiredPerm) and requiredPerm ~= nil then
-- Does not have perms to use this
RemoveWeaponFromPed(ped, weapon)
DisplayNotification("~r~Weapon Restricted! \n~w~You aren't a high enough rank to use this!\n" .. restrictedStr)
end
--TriggerServerEvent("Print:PrintDebug", "It gets here 3") -- DEBUG - GET RID OF
end
end)
function DisplayNotification( text )
SetNotificationTextEntry( "STRING" )
AddTextComponentString( text )
DrawNotification( false, false )
end