mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
Don't give weapon if target already has one, seperate string for weapon without ammo
This commit is contained in:
@@ -1109,7 +1109,11 @@ ESX.ShowInventory = function()
|
||||
for i=1, #players, 1 do
|
||||
if players[i] ~= PlayerId() then
|
||||
foundPlayers = true
|
||||
table.insert(elements, {label = GetPlayerName(players[i]), value = players[i]})
|
||||
|
||||
table.insert(elements, {
|
||||
label = GetPlayerName(players[i]),
|
||||
value = players[i]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1166,8 +1170,7 @@ ESX.ShowInventory = function()
|
||||
|
||||
else -- type: item_standard
|
||||
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give',
|
||||
{
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give', {
|
||||
title = _U('amount')
|
||||
}, function(data3, menu3)
|
||||
local quantity = tonumber(data3.value)
|
||||
@@ -1219,8 +1222,7 @@ ESX.ShowInventory = function()
|
||||
|
||||
else -- type: item_standard
|
||||
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_remove',
|
||||
{
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_remove', {
|
||||
title = _U('amount')
|
||||
}, function(data2, menu2)
|
||||
local quantity = tonumber(data2.value)
|
||||
@@ -1257,8 +1259,7 @@ ESX.ShowInventory = function()
|
||||
if closestPlayer ~= -1 and closestDistance < 3.0 then
|
||||
if pedAmmo > 0 then
|
||||
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give',
|
||||
{
|
||||
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give', {
|
||||
title = _U('amountammo')
|
||||
}, function(data2, menu2)
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ AddEventHandler('esx:addInventoryItem', function(item, count)
|
||||
for i=1, #ESX.PlayerData.inventory, 1 do
|
||||
if ESX.PlayerData.inventory[i].name == item.name then
|
||||
ESX.PlayerData.inventory[i] = item
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,6 +147,7 @@ AddEventHandler('esx:removeInventoryItem', function(item, count)
|
||||
for i=1, #ESX.PlayerData.inventory, 1 do
|
||||
if ESX.PlayerData.inventory[i].name == item.name then
|
||||
ESX.PlayerData.inventory[i] = item
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['br'] = {
|
||||
['noammo'] = 'voce nao tem todas essas muniçoes!',
|
||||
['gave_item'] = 'voce deu ~y~%sx~s~ ~b~%s~s~ para ~y~%s~s~',
|
||||
['received_item'] = 'voce recebeu ~y~%sx~s~ ~b~%s~s~ de ~b~%s~s~',
|
||||
['gave_weapon'] = 'voce deu ~y~1x~s~ ~b~%s~s~ com ~o~%sx~s~ balas para ~y~%s~s~.',
|
||||
['received_weapon'] = 'voce recebeu ~y~1x~s~ ~b~%s~s~ com ~o~%sx~s~ balas de ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'voce deu ~o~%sx~s~ balas para ~y~%s~s~.',
|
||||
['received_ammo'] = 'voce recebeu ~o~%sx~s~ balas de ~b~%s~s~.',
|
||||
['gave_money'] = 'voce deu ~g~$%s~s~ para ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['cs'] = {
|
||||
['noammo'] = 'nemáte dostatek munice!',
|
||||
['gave_item'] = 'dali jste ~y~%sx~s~ ~b~%s~s~ ~y~%s~s~',
|
||||
['received_item'] = 'obdrželi jste ~y~%sx~s~ ~b~%s~s~ od ~b~%s~s~',
|
||||
['gave_weapon'] = 'dali jste ~y~1x~s~ ~b~%s~s~ s ~o~%sx~s~ náboji ~y~%s~s~.',
|
||||
['received_weapon'] = 'obdrželi jste ~y~1x~s~ ~b~%s~s~ s ~o~%sx~s~ náboji od ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'dali jste ~o~%sx~s~ nábojů ~y~%s~s~.',
|
||||
['received_ammo'] = 'obdrželi jste ~o~%sx~s~ nábojů od ~b~%s~s~.',
|
||||
['gave_money'] = 'dali jste ~g~$%s~s~ ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['de'] = {
|
||||
['noammo'] = 'du hast keine munition!',
|
||||
['gave_item'] = 'du gibst ~y~%sx~s~ ~b~%s~s~ zu ~y~%s~s~',
|
||||
['received_item'] = 'to empfängst ~y~%sx~s~ ~b~%s~s~ von ~b~%s~s~',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'you gave ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['received_ammo'] = 'you received ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['gave_money'] = 'du gibst ~g~$%s~s~ zu ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['en'] = {
|
||||
['noammo'] = 'you do not have enough ammo!',
|
||||
['gave_item'] = 'you gave ~y~%sx~s~ ~b~%s~s~ to ~y~%s~s~',
|
||||
['received_item'] = 'you received ~y~%sx~s~ ~b~%s~s~ from ~b~%s~s~',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'you gave ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['received_ammo'] = 'you received ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['gave_money'] = 'you gave ~g~$%s~s~ to ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['fi'] = {
|
||||
['noammo'] = 'sinulla ei ole ammuksia!',
|
||||
['gave_item'] = 'sinä annoit ~y~%sx~s~ ~b~%s~s~ henkilölle ~y~%s~s~',
|
||||
['received_item'] = 'sinä sait ~y~%sx~s~ ~b~%s~s~ henkilöltä ~b~%s~s~',
|
||||
['gave_weapon'] = 'sinä annoit ~y~1x~s~ ~b~%s~s~ jossa oli ~o~%sx~s~ ammuksia henkilölle ~y~%s~s~.',
|
||||
['received_weapon'] = 'sinä sait ~y~1x~s~ ~b~%s~s~ jossa oli ~o~%sx~s~ ammuksia henkilöltä ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'sinä annoit ~o~%sx~s~ ammuksia henkilölle ~y~%s~s~.',
|
||||
['received_ammo'] = 'sinä sait ~o~%sx~s~ ammuksia henkilöltä ~b~%s~s~.',
|
||||
['gave_money'] = 'sinä annoit ~g~$%s~s~ henkilölle ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['fr'] = {
|
||||
['noammo'] = 'tu n\'as pas toutes ces munitions!',
|
||||
['gave_item'] = 'vous avez donné ~y~%sx~s~ ~b~%s~s~ à ~y~%s~s~',
|
||||
['received_item'] = 'vous avez reçu ~y~%sx~s~ ~b~%s~s~ par ~b~%s~s~',
|
||||
['gave_weapon'] = 'vous donnez ~y~1x~s~ ~b~%s~s~ avec ~o~%sx~s~ minitions à ~y~%s~s~.',
|
||||
['received_weapon'] = 'vous recevez ~y~1x~s~ ~b~%s~s~ avec ~o~%sx~s~ munitions de ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'vous donnez ~o~%sx~s~ munitions à ~y~%s~s~.',
|
||||
['received_ammo'] = 'vous recevez ~o~%sx~s~ munitions de ~b~%s~s~.',
|
||||
['gave_money'] = 'vous avez donné ~g~$%s~s~ à ~y~%s~s~',
|
||||
|
||||
+7
-2
@@ -6,14 +6,19 @@ Locales['pl'] = {
|
||||
['give'] = 'daj',
|
||||
['remove'] = 'usuń',
|
||||
['return'] = 'return',
|
||||
['give_to'] = 'give to',
|
||||
['amount'] = 'amount',
|
||||
['giveammo'] = 'give ammo',
|
||||
['amountammo'] = 'ilość amunicji',
|
||||
['noammo'] = 'nie masz wystarczającej ilości amunicji!',
|
||||
['gave_item'] = 'dajesz ~y~%sx~s~ ~b~%s~s~ dla ~y~%s~s~',
|
||||
['received_item'] = 'otrzymujesz ~y~%sx~s~ ~b~%s~s~ od ~b~%s~s~',
|
||||
['gave_weapon'] = 'dajesz ~y~1x~s~ ~b~%s~s~ z ~o~%sx~s~ nabojami dla ~y~%s~s~.',
|
||||
['received_weapon'] = 'otrzymujesz ~y~1x~s~ ~b~%s~s~ z ~o~%sx~s~ nabojami od ~b~%s~s~.',
|
||||
['gave_weapon'] = 'you gave ~y~1x~s~ ~b~%s~s~ to ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'you gave ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets to ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ already have an ~y~%s~s~',
|
||||
['received_weapon'] = 'you received ~y~1x~s~ ~b~%s~s~ from ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'you received ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets from ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ attempted to give you an ~y~%s~s~, but you already have one.',
|
||||
['gave_ammo'] = 'dajesz ~o~%sx~s~ naboje dla ~y~%s~s~.',
|
||||
['received_ammo'] = 'otrzymujesz ~o~%sx~s~ naboje od ~b~%s~s~.',
|
||||
['gave_money'] = 'dajesz ~g~%s$~s~ dla ~y~%s~s~',
|
||||
|
||||
+6
-2
@@ -13,8 +13,12 @@ Locales['sv'] = {
|
||||
['noammo'] = 'du har inte tillräckligt med ammunition!',
|
||||
['gave_item'] = 'du gav ~y~%sx~s~ ~b~%s~s~ till ~y~%s~s~',
|
||||
['received_item'] = 'du tog emot ~y~%sx~s~ ~b~%s~s~ från ~b~%s~s~',
|
||||
['gave_weapon'] = 'du gav ~y~1x~s~ ~b~%s~s~ med ~o~%sx~s~ skott till ~y~%s~s~.',
|
||||
['received_weapon'] = 'du tog emot ~y~1x~s~ ~b~%s~s~ med ~o~%sx~s~ skott från ~b~%s~s~.',
|
||||
['gave_weapon'] = 'du gav ~y~1x~s~ ~b~%s~s~ till ~y~%s~s~.',
|
||||
['gave_weapon_ammo'] = 'du gav ~y~1x~s~ ~b~%s~s~ med ~o~%sx~s~ skott till ~y~%s~s~.',
|
||||
['gave_weapon_hasalready'] = '~y~%s~s~ har redan en ~y~%s~s~',
|
||||
['received_weapon'] = 'du tog emot ~y~1x~s~ ~b~%s~s~ från ~b~%s~s~.',
|
||||
['received_weapon_ammo'] = 'du tog emot ~y~1x~s~ ~b~%s~s~ med ~o~%sx~s~ skott från ~b~%s~s~.',
|
||||
['received_weapon_hasalready'] = '~b~%s~s~ försökte ge dig en ~y~%s~s~, men det har du redan.',
|
||||
['gave_ammo'] = 'du gav ~o~%sx~s~ skott till ~y~%s~s~.',
|
||||
['received_ammo'] = 'du tog emot ~o~%sx~s~ skott från ~b~%s~s~.',
|
||||
['gave_money'] = 'du gav ~g~%s SEK~s~ till ~y~%s~s~',
|
||||
|
||||
+31
-17
@@ -15,11 +15,10 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
|
||||
-- Update user name in DB
|
||||
table.insert(tasks, function(cb)
|
||||
MySQL.Async.execute('UPDATE `users` SET `name` = @name WHERE `identifier` = @identifier',
|
||||
{
|
||||
['@identifier'] = player.getIdentifier(),
|
||||
['@name'] = userData.playerName
|
||||
}, function(rowsChanged)
|
||||
MySQL.Async.execute('UPDATE `users` SET `name` = @name WHERE `identifier` = @identifier', {
|
||||
['@identifier'] = player.getIdentifier(),
|
||||
['@name'] = userData.playerName
|
||||
}, function(rowsChanged)
|
||||
cb()
|
||||
end)
|
||||
end)
|
||||
@@ -291,13 +290,13 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
|
||||
elseif type == 'item_money' then
|
||||
|
||||
if itemCount > 0 and sourceXPlayer.player.get('money') >= itemCount then
|
||||
if itemCount > 0 and sourceXPlayer.getMoney() >= itemCount then
|
||||
|
||||
sourceXPlayer.removeMoney(itemCount)
|
||||
targetXPlayer.addMoney (itemCount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_money', itemCount, targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_money', itemCount, sourceXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_money', ESX.Math.GroupDigits(itemCount), targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_money', ESX.Math.GroupDigits(itemCount), sourceXPlayer.name))
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
@@ -310,21 +309,35 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
sourceXPlayer.removeAccountMoney(itemName, itemCount)
|
||||
targetXPlayer.addAccountMoney (itemName, itemCount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_account_money', itemCount, Config.AccountLabels[itemName], targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_account_money', itemCount, Config.AccountLabels[itemName], sourceXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], sourceXPlayer.name))
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
end
|
||||
|
||||
elseif type == 'item_weapon' then
|
||||
|
||||
sourceXPlayer.removeWeapon(itemName)
|
||||
targetXPlayer.addWeapon(itemName, itemCount)
|
||||
|
||||
local weaponLabel = ESX.GetWeaponLabel(itemName)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon', weaponLabel, itemCount, targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_weapon', weaponLabel, itemCount, sourceXPlayer.name))
|
||||
|
||||
if not targetXPlayer.hasWeapon(itemName) then
|
||||
|
||||
sourceXPlayer.removeWeapon(itemName)
|
||||
targetXPlayer.addWeapon(itemName, itemCount)
|
||||
|
||||
local weaponLabel = ESX.GetWeaponLabel(itemName)
|
||||
|
||||
if itemCount > 0 then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon_ammo', weaponLabel, itemCount, targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_weapon_ammo', weaponLabel, itemCount, sourceXPlayer.name))
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon', weaponLabel, targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_weapon', weaponLabel, sourceXPlayer.name))
|
||||
end
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon_hasalready', targetXPlayer.name, weaponLabel))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('received_weapon_hasalready', sourceXPlayer.name, weaponLabel))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
@@ -345,6 +358,7 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
for i=1, #xPlayer.inventory, 1 do
|
||||
if xPlayer.inventory[i].name == itemName then
|
||||
foundItem = xPlayer.inventory[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user