Closed NoSkills7 closed 1 year ago
I've checked your changes and applied it to my local instance but I'm noticing the tint doesn't "stick". It's in the weapondata.info, but the tint doesn't apply when pulling it out. Am I missing something?
Hi there, I have found a solution!!!
In qb-inventory > client > main.lua,
Search for: RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool)
inside event, replace ...
else
TriggerEvent('weapons:client:DrawWeapon', nil)
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
local ammo = tonumber(weaponData.info.ammo) or 0
by ...
else
TriggerEvent('weapons:client:DrawWeapon', nil)
TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool)
local ammo = tonumber(weaponData.info.ammo) or 0
local tint = tonumber(weaponData.info.tint) or 0
and replace ...
GiveWeaponToPed(ped, weaponHash, ammo, false, false)
SetPedAmmo(ped, weaponHash, ammo)
SetCurrentPedWeapon(ped, weaponHash, true)
by...
GiveWeaponToPed(ped, weaponHash, ammo, false, false)
SetPedAmmo(ped, weaponHash, ammo)
SetCurrentPedWeapon(ped, weaponHash, true)
SetPedWeaponTintIndex(ped, weaponHash, tint)
In qb-weapons> client > main.lua, replace...
RegisterNetEvent('weapons:client:EquipTint', function(tint)
local player = PlayerPedId()
local weapon = GetSelectedPedWeapon(player)
SetPedWeaponTintIndex(player, weapon, tint)
end)
by...
RegisterNetEvent('weapons:client:EquipTint', function(tint)
local player = PlayerPedId()
local weapon = GetSelectedPedWeapon(player)
SetPedWeaponTintIndex(player, weapon, tint)
TriggerServerEvent("weapons:server:ApplyTint", CurrentWeaponData, tint)
end)
In qb-weapons> server> main.lua, add...
RegisterNetEvent('weapons:server:ApplyTint', function(data, tint)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local WeaponSlot = Player.PlayerData.items[data.slot]
WeaponSlot.info.tint = tint
Player.Functions.SetInventory(Player.PlayerData.items, true)
end)
Near the bottom.
Any help, ask me on discord RayaanUddin#6541.
@NoSkills7 can you re-work on it a little bit? The idea is nice but need a little more work to get it fully working
This PR has had 60 days of inactivity & will close within 7 days
Describe Pull request This is a PR to make weapon tints stick to the weapons and not having to re-apply them every time you pull a gun out. Followed the same logic that it uses for weapon ammo. Just a self-learning newbie trying, so double check it and take it easy one me lmao. This PR also needs the following change in qb-inventory : Under where QBCore.Functions.TriggerCallback("weapon:server:GetWeaponAmmo", function(result) ends, add the following :
QBCore.Functions.TriggerCallback("weapon:server:GetWeaponTint", function(result) local tint = tonumber(result) SetPedWeaponTintIndex(ped, currentWeapon, tint) print(tint) currentWeapon = weaponName end, CurrentWeaponData)
Fix for issue #101
Questions (please complete the following information):