-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.lua
More file actions
64 lines (51 loc) · 1.63 KB
/
client.lua
File metadata and controls
64 lines (51 loc) · 1.63 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
ESX = exports["es_extended"]:getSharedObject()
RegisterNetEvent('msk_weaponammoitem:checkAmmo')
AddEventHandler('msk_weaponammoitem:checkAmmo', function(item, data)
local playerPed = PlayerPedId()
local hash = GetSelectedPedWeapon(playerPed)
if IsPedArmed(playerPed, 4) then
if hash then
if not Config.AmmoPacks[item] then return print(('[ITEM] [Add Ammo] Item ^3%s^0 is not configured in config.lua'):format(item)) end
local weapon = ESX.GetWeaponFromHash(hash)
TriggerServerEvent('msk_weaponammoitem:addWeaponAmmo', weapon.name, item, data)
end
end
end)
CreateThread(function()
while true do
local sleep = 100 -- Please don't touch otherwise you will break the Script
if ESX.IsPlayerLoaded() then
local playerPed = PlayerPedId()
if IsPedArmed(playerPed, 4) then
local hash = GetSelectedPedWeapon(playerPed)
for k, item in pairs(Config.Ammunition) do
for i=1, #item do
if hash == GetHashKey(item[i]) then
TriggerServerEvent('msk_weaponammoitem:updateWeaponAmmo', k, item[i])
end
end
end
end
end
Wait(sleep)
end
end)
CreateThread(function()
while true do
local sleep = 0 -- Please don't touch otherwise you will break the Script
if ESX.IsPlayerLoaded() then
local playerPed = PlayerPedId()
if IsPedArmed(playerPed, 4) and IsPedShooting(playerPed) then
local hash = GetSelectedPedWeapon(playerPed)
for k, item in pairs(Config.Ammunition) do
for i=1, #item do
if hash == GetHashKey(item[i]) then
TriggerServerEvent('msk_weaponammoitem:updateWeaponAmmo', k, item[i], true)
end
end
end
end
end
Wait(sleep)
end
end)