From e8d41c1cc354d48e3faf6de76eb753bb085a4e9e Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Sat, 25 Feb 2023 15:16:45 +0100 Subject: [PATCH] Update v1.3 * Fix for ESX 1.8.5 and above --- VERSION | 2 +- client.lua | 12 ++---------- fxmanifest.lua | 2 +- server.lua | 5 ++--- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index ea710ab..a58941b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2 \ No newline at end of file +1.3 \ No newline at end of file diff --git a/client.lua b/client.lua index 1011c7c..cfcff99 100644 --- a/client.lua +++ b/client.lua @@ -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 @@ -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 @@ -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 diff --git a/fxmanifest.lua b/fxmanifest.lua index 1dcdb1e..0dd0c8f 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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' diff --git a/server.lua b/server.lua index 2e8d6c4..8752e95 100644 --- a/server.lua +++ b/server.lua @@ -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)