Implemented weapon tint support (desc), closes #477

- Implemented two new xPlayer functions:
  - .getWeaponTint(weaponName)
  - .setWeaponTint(weaponName, weaponTintIndex)

Thanks to @profex1999 for co authoring this!

Co-Authored-By: Andrea Passarini <profex1999@users.noreply.github.com>
This commit is contained in:
ElPumpo
2020-02-11 21:11:54 +01:00
parent 8e13cf6613
commit baa9ca3afc
13 changed files with 194 additions and 37 deletions
+26 -1
View File
@@ -375,7 +375,8 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, c
name = weaponName,
ammo = ammo,
label = weaponLabel,
components = {}
components = {},
tintIndex = 0
})
self.triggerEvent('esx:addWeapon', weaponName, ammo)
@@ -408,6 +409,30 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, c
end
end
self.setWeaponTint = function(weaponName, weaponTintIndex)
local loadoutNum, weapon = self.getWeapon(weaponName)
if weapon then
local weaponNum, weaponObject = ESX.GetWeapon(weaponName)
if weaponObject.tints and weaponObject.tints[weaponTintIndex] then
self.loadout[loadoutNum].tintIndex = weaponTintIndex
self.triggerEvent('esx:setWeaponTint', weaponName, weaponTintIndex)
self.triggerEvent('esx:addInventoryItem', weaponObject.tints[weaponTintIndex], false, true)
end
end
end
self.getWeaponTint = function(weaponName)
local loadoutNum, weapon = self.getWeapon(weaponName)
if weapon then
return weapon.tintIndex
end
return 0
end
self.removeWeapon = function(weaponName, ammo)
local weaponLabel