Merge pull request #2 from nlmarcio/master

Add Weapon pickup
This commit is contained in:
Jérémie N'gadi
2017-08-12 23:10:20 +02:00
committed by GitHub
3 changed files with 20 additions and 1 deletions
@@ -373,4 +373,13 @@ if Config.DisableWantedLevel then
end
end)
end
end
-- Pickup Weapon
RegisterNetEvent('esx:pickupWeapon')
AddEventHandler('esx:pickupWeapon', function(weaponPickup, weaponName)
local ped = GetPlayerPed(-1)
local playerPedPos = GetEntityCoords(ped, true)
CreateAmbientPickup(GetHashKey(weaponPickup), playerPedPos.x + 2.0, playerPedPos.y, playerPedPos.z + 0.5, 0, 999, 1, false, true)
end)
@@ -7,3 +7,4 @@ Config.ShowDotAbovePlayer = false
Config.DisableWantedLevel = true
Config.RemoveInventoryItemDelay = 5 * 60000
Config.Locale = 'fr'
Config.EnableWeaponPickup = false
@@ -479,17 +479,26 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
elseif type == 'item_weapon' then
local xPlayer = ESX.GetPlayerFromId(source)
local weaponLabel = itemName
local weaponName = nil
local weaponPickup = nil
for i=1, #Config.Weapons, 1 do
if Config.Weapons[i].name == itemName then
weaponLabel = Config.Weapons[i].label
weaponName = Config.Weapons[i].name
weaponPickup = 'PICKUP_'..weaponName
break
end
end
SetTimeout(Config.RemoveInventoryItemDelay, function()
xPlayer.removeWeapon(itemName)
if Config.EnableWeaponPickup then
TriggerClientEvent('esx:pickupWeapon', _source, weaponPickup, weaponName)
end
TriggerClientEvent('esx:showNotification', _source, 'Vous avez ~r~jeté~s~ x1 ' .. ' ~g~' .. weaponLabel)
end)