mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user