-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
87 lines (74 loc) · 2.95 KB
/
Copy pathmain.lua
File metadata and controls
87 lines (74 loc) · 2.95 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
82
83
84
85
86
87
local ResourceName = GetCurrentResourceName()
local disable = false
Citizen.CreateThread(function()
local isAiming = false
local last = disable
while true do
local player = PlayerPedId()
disable = not IsPedInAnyVehicle(player, true)
if disable then
if IsControlJustPressed(0, 25) then
isAiming = true
end
if IsControlJustReleased(0, 25) then
isAiming = false
end
disable = not isAiming
if disable then
if Config.UnarmedOnly then
disable = GetSelectedPedWeapon(player) == GetHashKey('WEAPON_UNARMED')
else
local currentWeapon = GetSelectedPedWeapon(player)
local weaponInList = isWeaponInList(currentWeapon, Config.ArmedWeaponList)
if Config.ArmedWeaponListBlacklisted then
disable = weaponInList
else
disable = not weaponInList
end
end
end
if disable then
DisableControlAction(0, 24, true) -- Attack
DisableControlAction(0, 140, true) -- Melee Attack Light
DisableControlAction(0, 141, true) -- Melee Attack Heavy
DisableControlAction(0, 142, true) -- Melee Attack Alternate
DisableControlAction(0, 257, true) -- Attack 2
DisableControlAction(0, 263, true) -- Melee Attack 1
DisableControlAction(0, 264, true) -- Melee Attack 2
if IsDisabledControlJustPressed(0, 24) or
IsDisabledControlJustPressed(0, 140) or
IsDisabledControlJustPressed(0, 141) or
IsDisabledControlJustPressed(0, 142) or
IsDisabledControlJustPressed(0, 257) or
IsDisabledControlJustPressed(0, 263) or
IsDisabledControlJustPressed(0, 264)
then
TriggerEvent(ResourceName .. ':attackFailed')
end
end
if last ~= disable then
TriggerEvent(ResourceName .. ':attackStateChange', disable)
end
last = disable
end
Wait(0)
end
end)
function isWeaponInList(weapon, list)
for i = 1, #list do
if GetHashKey(list[i]) == weapon then
return true
end
end
return false
end
exports('isDisabled', function()
return disable
end)
-- example for api call
-- AddEventHandler("that_safeAttack:attackStateChange", function(disable)
-- TriggerEvent('esx:showNotification', "attack disabled: " .. tostring(disable))
-- end)
-- AddEventHandler("that_safeAttack:attackFailed", function()
-- TriggerEvent('esx:showNotification', "You cannot attack")
-- end)