mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #1111 from btwlouis/remove-weapon-rpc
Remove weapon using rpc
This commit is contained in:
@@ -332,9 +332,7 @@ if not Config.OxInventory then
|
||||
|
||||
RegisterNetEvent('esx:removeWeapon')
|
||||
AddEventHandler('esx:removeWeapon', function(weapon)
|
||||
local playerPed = ESX.PlayerData.ped
|
||||
RemoveWeaponFromPed(playerPed, joaat(weapon))
|
||||
SetPedAmmo(ESX.PlayerData.ped, joaat(weapon), 0)
|
||||
print("[^1ERROR^7] event ^5'esx:removeWeapon'^7 Has Been Removed. Please use ^5xPlayer.removeWeapon^7 Instead!")
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:removeWeaponComponent')
|
||||
|
||||
@@ -460,7 +460,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
end
|
||||
|
||||
function self.removeWeapon(weaponName)
|
||||
local weaponLabel
|
||||
local weaponLabel, playerPed = nil, GetPlayerPed(self.source)
|
||||
|
||||
if not playerPed then
|
||||
return print("[^1ERROR^7] xPlayer.removeWeapon ^5invalid^7 player ped!")
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.loadout) do
|
||||
if v.name == weaponName then
|
||||
@@ -469,6 +473,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
for _, v2 in ipairs(v.components) do
|
||||
self.removeWeaponComponent(weaponName, v2)
|
||||
end
|
||||
|
||||
local weaponHash = joaat(v.name)
|
||||
|
||||
RemoveWeaponFromPed(playerPed, weaponHash)
|
||||
SetPedAmmo(playerPed, weaponHash, 0)
|
||||
|
||||
table.remove(self.loadout, k)
|
||||
break
|
||||
@@ -476,7 +485,6 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
end
|
||||
|
||||
if weaponLabel then
|
||||
self.triggerEvent('esx:removeWeapon', weaponName)
|
||||
self.triggerEvent('esx:removeInventoryItem', weaponLabel, false, true)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user