Skip to content

Commit

Permalink
Update v1.3
Browse files Browse the repository at this point in the history
* Fix for ESX 1.8.5 and above
  • Loading branch information
Musiker15 committed Feb 25, 2023
1 parent d3f2936 commit e8d41c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.3
12 changes: 2 additions & 10 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
ESX = exports["es_extended"]:getSharedObject()

local isPlayerLoaded = false

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
isPlayerLoaded = true
end)

CreateThread(function()
while true do
local sleep = 100 -- Please don't touch otherwise you will break the Script

if isPlayerLoaded then
if ESX.IsPlayerLoaded() then
local playerPed = PlayerPedId()

if IsPedArmed(playerPed, 4) then
Expand All @@ -35,7 +28,7 @@ CreateThread(function()
while true do
local sleep = 0 -- Please don't touch otherwise you will break the Script

if isPlayerLoaded then
if ESX.IsPlayerLoaded() then
local playerPed = PlayerPedId()

if IsPedArmed(playerPed, 4) and IsPedShooting(playerPed) then
Expand All @@ -44,7 +37,6 @@ CreateThread(function()
for k, item in pairs(Config.Ammunition) do
for i=1, #item do
if hash == GetHashKey(item[i]) then
--print('DEBUG isShooting', hash, GetHashKey(item[i]), item[i])
TriggerServerEvent('msk_weaponammoitem:updateWeaponAmmo', k, item[i], true)
end
end
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_weaponammoitems'
description 'Weapon Ammunition with Items'
version '1.2'
version '1.3'

lua54 'yes'

Expand Down
5 changes: 2 additions & 3 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ AddEventHandler('msk_weaponammoitem:updateWeaponAmmo', function(item, weaponName
if xPlayer then
if hasItem and hasItem.count > 0 then
if isShooting then
--print('[DEBUG]', item, hasItem.count, weaponName, isShooting)
xPlayer.removeInventoryItem(item, 1)
end

xPlayer.updateWeaponAmmo(weaponName, hasItem.count)
xPlayer.triggerEvent('esx:setWeaponAmmo', weaponName, hasItem.count)
SetPedAmmo(GetPlayerPed(xPlayer.source), joaat(weaponName), hasItem.count)
else
xPlayer.updateWeaponAmmo(weaponName, 0)
xPlayer.triggerEvent('esx:setWeaponAmmo', weaponName, 0)
SetPedAmmo(GetPlayerPed(xPlayer.source), joaat(weaponName), 0)
end
end
end)
Expand Down

0 comments on commit e8d41c1

Please sign in to comment.