if not ESX then local exportExists, obj = pcall(function() return exports.es_extended:getSharedObject() end) if exportExists then ESX = obj else TriggerEvent('esx:getSharedObject', function(esx) ESX = esx end) while not ESX do Wait(100) end end end ---Checks if the player has the weapon item specified ---@param source string ---@param weaponHash integer ---@return boolean hasWeapon function HasWeapon(source, weaponHash) local xPlayer = ESX.GetPlayerFromId(source) if not xPlayer then warn("Could not get player data checking for weapon item") return false end local itemName = Config.AllowedWeapons[weaponHash].name local _loadoutNum, weapon = xPlayer.getWeapon(string.upper(itemName)) return weapon ~= nil end ---Removes the weapon from the player ---@param source string ---@param weaponHash integer ---@param playerPed integer ---@return boolean success function RemoveWeapon(source, weaponHash, playerPed) local xPlayer = ESX.GetPlayerFromId(source) if not xPlayer then warn("Could not get player data when removing a weapon") return false end local weaponName = Config.AllowedWeapons[weaponHash]?.name weaponName = weaponName and string.upper(weaponName) or nil if not weaponName then warn(string.format("Could not get weapon name when removing a weapon with hash %s", weaponHash)) return false end xPlayer.removeWeapon(weaponName) return true end ---Reduces durability for the weapon ---@param source string ---@param weaponHash integer ---@param playerPed integer ---@return boolean removedWeapon If the weapon was removed due to durability going below 0 function ReduceDurabilityForWeapon(source, weaponHash, playerPed) -- This is just a void function that does nothing, I don't believe esx has any support for item durability. return false end