-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient.lua
More file actions
81 lines (80 loc) · 3.16 KB
/
client.lua
File metadata and controls
81 lines (80 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--------------------------
--- DiscordWeaponPerms ---
--------------------------
restrictedWeapons = {
{}, -- Trusted Civ (1)
{}, -- Donator (2)
{}, -- Personal (3)
{"",}, -- Staff (4)
{"",}, -- T-Mod (5)
{"",}, -- Mod (6)
{"WEAPON_RPG",}, -- Admin (7)
{"",}, -- Management (8)
{"WEAPON_GRENADELAUNCHER", "WEAPON_STICKYBOMB", "WEAPON_GRENADE", "WEAPON_HOMINGLAUNCHER", "WEAPON_PROXMINE", "WEAPON_PIPEBOMB",
"WEAPON_COMPACTLAUNCHER", "WEAPON_RAILGUN", "COMPONENT_REVOLVER_MK2_CLIP_INCENDIARY", "COMPONENT_SNSPISTOL_MK2_CLIP_INCENDIARY",
"COMPONENT_PISTOL_MK2_CLIP_INCENDIARY", "COMPONENT_SMG_MK2_CLIP_INCENDIARY","COMPONENT_PUMPSHOTGUN_MK2_CLIP_INCENDIARY", "COMPONENT_PUMPSHOTGUN_MK2_CLIP_EXPLOSIVE",
"COMPONENT_BULLPUPRIFLE_MK2_CLIP_INCENDIARY", "COMPONENT_SPECIALCARBINE_MK2_CLIP_INCENDIARY", "COMPONENT_ASSAULTRIFLE_MK2_CLIP_INCENDIARY", "COMPONENT_CARBINERIFLE_MK2_CLIP_INCENDIARY",
"COMPONENT_COMBATMG_MK2_CLIP_INCENDIARY", "COMPONENT_MARKSMANRIFLE_MK2_CLIP_INCENDIARY", "COMPONENT_HEAVYSNIPER_MK2_CLIP_INCENDIARY", "COMPONENT_HEAVYSNIPER_MK2_CLIP_EXPLOSIVE",}, -- Owner (9)
}
--[[
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(4000)
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~Restricted: ~w~" .. 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