test in es_exteded 1.1, 1.2 and v1 final … work perfect
Where is this going? In a new script or an already created one?
Can you help me out. I have no errors on the console. but the animation isn’t working
can you show your code?
CLIENT:
function loadAnimDict(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Citizen.Wait(1)
end
end
RegisterNetEvent('esx:giveAnimation')
AddEventHandler('esx:giveAnimation', function()
local playerPed = PlayerPedId()
loadAnimDict('mp_common')
TaskPlayAnim(playerPed, "mp_common", "givetake1_a", 8.0, 8.0, 2000, 50, 0, false, false, false)
end)
`Server:`
RegisterNetEvent('esx:giveInventoryItem')
AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCount)
local playerId = source
local sourceXPlayer = ESX.GetPlayerFromId(playerId)
local targetXPlayer = ESX.GetPlayerFromId(target)
if type == 'item_standard' then
local sourceItem = sourceXPlayer.getInventoryItem(itemName)
if itemCount > 0 and sourceItem.count >= itemCount then
if targetXPlayer.canCarryItem(itemName, itemCount) then
sourceXPlayer.removeInventoryItem(itemName, itemCount)
targetXPlayer.addInventoryItem (itemName, itemCount)
sourceXPlayer.showNotification(_U('gave_item', itemCount, sourceItem.label, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_item', itemCount, sourceItem.label, sourceXPlayer.name))
sourceXPlayer.triggerEvent('esx:giveAnimation')
targetXPlayer.triggerEvent('esx:giveAnimation')
else
sourceXPlayer.showNotification(_U('ex_inv_lim', targetXPlayer.name))
end
else
sourceXPlayer.showNotification(_U('imp_invalid_quantity'))
end
elseif type == 'item_account' then
if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then
sourceXPlayer.removeAccountMoney(itemName, itemCount)
targetXPlayer.addAccountMoney (itemName, itemCount)
sourceXPlayer.showNotification(_U('gave_account_money', ESX.Math.GroupDigits(itemCount), Config.Accounts[itemName], targetXPlayer.name))
targetXPlayer.showNotification(_U('received_account_money', ESX.Math.GroupDigits(itemCount), Config.Accounts[itemName], sourceXPlayer.name))
sourceXPlayer.triggerEvent('esx:giveAnimation')
targetXPlayer.triggerEvent('esx:giveAnimation')
else
sourceXPlayer.showNotification(_U('imp_invalid_amount'))
end
elseif type == 'item_weapon' then
if sourceXPlayer.hasWeapon(itemName) then
local weaponLabel = ESX.GetWeaponLabel(itemName)
if not targetXPlayer.hasWeapon(itemName) then
local _, weapon = sourceXPlayer.getWeapon(itemName)
local _, weaponObject = ESX.GetWeapon(itemName)
itemCount = weapon.ammo
sourceXPlayer.removeWeapon(itemName)
targetXPlayer.addWeapon(itemName, itemCount)
if weaponObject.ammo and itemCount > 0 then
local ammoLabel = weaponObject.ammo.label
sourceXPlayer.showNotification(_U('gave_weapon_withammo', weaponLabel, itemCount, ammoLabel, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon_withammo', weaponLabel, itemCount, ammoLabel, sourceXPlayer.name))
sourceXPlayer.triggerEvent('esx:giveAnimation')
targetXPlayer.triggerEvent('esx:giveAnimation')
else
sourceXPlayer.showNotification(_U('gave_weapon', weaponLabel, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon', weaponLabel, sourceXPlayer.name))
sourceXPlayer.triggerEvent('esx:giveAnimation')
targetXPlayer.triggerEvent('esx:giveAnimation')
end
else
sourceXPlayer.showNotification(_U('gave_weapon_hasalready', targetXPlayer.name, weaponLabel))
targetXPlayer.showNotification(_U('received_weapon_hasalready', sourceXPlayer.name, weaponLabel))
end
end
elseif type == 'item_ammo' then
if sourceXPlayer.hasWeapon(itemName) then
local weaponNum, weapon = sourceXPlayer.getWeapon(itemName)
if targetXPlayer.hasWeapon(itemName) then
local _, weaponObject = ESX.GetWeapon(itemName)
if weaponObject.ammo then
local ammoLabel = weaponObject.ammo.label
if weapon.ammo >= itemCount then
sourceXPlayer.removeWeaponAmmo(itemName, itemCount)
targetXPlayer.addWeaponAmmo(itemName, itemCount)
sourceXPlayer.showNotification(_U('gave_weapon_ammo', itemCount, ammoLabel, weapon.label, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon_ammo', itemCount, ammoLabel, weapon.label, sourceXPlayer.name))
sourceXPlayer.triggerEvent('esx:giveAnimation')
targetXPlayer.triggerEvent('esx:giveAnimation')
end
end
else
sourceXPlayer.showNotification(_U('gave_weapon_noweapon', targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon_noweapon', sourceXPlayer.name, weapon.label))
end
end
end
end)
I even tried
sourceXPlayer.triggerEvent(‘esx:giveAnimation’, playerPed)
targetXPlayer.triggerEvent(‘esx:giveAnimation’, playerPed)
Thanks for the code pic. But I am already using the same code you have shown in picture… Can you show me client.lua code to see if it matches with mine?
I am going to try this one out… The code is the same however I was using anim givetake1_a earlier. now changed it to givetake2_a. Let me check and revert back to you.
It’s still not working bro. I don’t know what is the mistake I am making
mmm i don’t know bro, this cfg work for me in esx 1.2 and 1.1
it’s work for me . but the player is not freeze when giving item . they can just walk away haha