Show player name and not steam name, fixes #354

This commit is contained in:
ElPumpo
2020-01-05 15:49:00 +01:00
parent e83801cf42
commit feaf842420
2 changed files with 89 additions and 82 deletions
+33 -11
View File
@@ -301,21 +301,27 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
sourceXPlayer.showNotification(_U('imp_invalid_amount'))
end
elseif type == 'item_weapon' then
if not targetXPlayer.hasWeapon(itemName) then
sourceXPlayer.removeWeapon(itemName)
targetXPlayer.addWeapon(itemName, itemCount)
if sourceXPlayer.hasWeapon(itemName) then
local weaponLabel = ESX.GetWeaponLabel(itemName)
if itemCount > 0 then
sourceXPlayer.showNotification(_U('gave_weapon_withammo', weaponLabel, itemCount, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon_withammo', weaponLabel, itemCount, sourceXPlayer.name))
if not targetXPlayer.hasWeapon(itemName) then
local _,weapon = xPlayer.getWeapon(itemName)
itemCount = weapon.ammo
sourceXPlayer.removeWeapon(itemName)
targetXPlayer.addWeapon(itemName, itemCount)
if itemCount > 0 then
sourceXPlayer.showNotification(_U('gave_weapon_withammo', weaponLabel, itemCount, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon_withammo', weaponLabel, itemCount, sourceXPlayer.name))
else
sourceXPlayer.showNotification(_U('gave_weapon', weaponLabel, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon', weaponLabel, sourceXPlayer.name))
end
else
sourceXPlayer.showNotification(_U('gave_weapon', weaponLabel, targetXPlayer.name))
targetXPlayer.showNotification(_U('received_weapon', weaponLabel, sourceXPlayer.name))
sourceXPlayer.showNotification(_U('gave_weapon_hasalready', targetXPlayer.name, weaponLabel))
targetXPlayer.showNotification(_U('received_weapon_hasalready', sourceXPlayer.name, weaponLabel))
end
else
sourceXPlayer.showNotification(_U('gave_weapon_hasalready', targetXPlayer.name, weaponLabel))
targetXPlayer.showNotification(_U('received_weapon_hasalready', sourceXPlayer.name, weaponLabel))
end
elseif type == 'item_ammo' then
if sourceXPlayer.hasWeapon(itemName) then
@@ -482,6 +488,22 @@ ESX.RegisterServerCallback('esx:getOtherPlayerData', function(source, cb, target
})
end)
ESX.RegisterServerCallback('esx:getPlayerNames', function(source, cb, players)
players[source] = nil
for playerId,v in pairs(players) do
local xPlayer = ESX.GetPlayerFromId(playerId)
if xPlayer then
players[playerId] = xPlayer.getName()
else
players[playerId] = nil
end
end
cb(players)
end)
TriggerEvent("es:addGroup", "jobmaster", "user", function(group) end)
ESX.StartDBSync()