Skip to content

Commit

Permalink
Weapon attachment rework
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed Nov 3, 2023
1 parent 02695ab commit fbc05f6
Show file tree
Hide file tree
Showing 42 changed files with 969 additions and 1,998 deletions.
53 changes: 30 additions & 23 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,18 @@ end
---@return table attachments
local function FormatWeaponAttachments(itemdata)
local attachments = {}
itemdata.name = itemdata.name:upper()
if itemdata.info.attachments ~= nil and next(itemdata.info.attachments) ~= nil then
for _, v in pairs(itemdata.info.attachments) do
if exports['qb-weapons']:getConfigWeaponAttachments(itemdata.name) then
for key, value in pairs(exports['qb-weapons']:getConfigWeaponAttachments(itemdata.name)) do
if value.component == v.component then
local item = value.item
attachments[#attachments + 1] = {
attachment = key,
label = QBCore.Shared.Items[item].label
--label = value.label
}
end
local weaponName = itemdata.name
local WeaponAttachments = exports['qb-weapons']:getConfigWeaponAttachments()
for attachmentType, weapons in pairs(WeaponAttachments) do
local componentHash = weapons[weaponName]
if componentHash then
for _, attachmentData in pairs(itemdata.info.attachments) do
if attachmentData.component == componentHash then
local label = QBCore.Shared.Items[attachmentType] and QBCore.Shared.Items[attachmentType].label or 'Unknown'
attachments[#attachments + 1] = {
attachment = attachmentType,
label = label
}
end
end
end
Expand Down Expand Up @@ -588,6 +587,10 @@ RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool)
end
end

if weaponData.info.tint then
SetPedWeaponTintIndex(ped, weaponHash, weaponData.info.tint)
end

currentWeapon = weaponName
end
end)
Expand Down Expand Up @@ -784,19 +787,23 @@ end)

RegisterNUICallback('RemoveAttachment', function(data, cb)
local ped = PlayerPedId()
local WeaponData = QBCore.Shared.Items[data.WeaponData.name]
local Attachment = exports['qb-weapons']:getConfigWeaponAttachments(WeaponData.name:upper())[data.AttachmentData.attachment]
local WeaponData = data.WeaponData
local allAttachments = exports['qb-weapons']:getConfigWeaponAttachments()
local Attachment = allAttachments[data.AttachmentData.attachment][WeaponData.name]

QBCore.Functions.TriggerCallback('weapons:server:RemoveAttachment', function(NewAttachments)
if NewAttachments ~= false then
local Attachies = {}
RemoveWeaponComponentFromPed(ped, joaat(data.WeaponData.name), joaat(Attachment.component))
RemoveWeaponComponentFromPed(ped, joaat(WeaponData.name), joaat(Attachment))

for _, v in pairs(NewAttachments) do
for _, pew in pairs(exports['qb-weapons']:getConfigWeaponAttachments(WeaponData.name:upper())) do
if v.component == pew.component then
local item = pew.item
for attachmentType, weapons in pairs(allAttachments) do
local componentHash = weapons[WeaponData.name]
if componentHash and v.component == componentHash then
local label = QBCore.Shared.Items[attachmentType] and QBCore.Shared.Items[attachmentType].label or 'Unknown'
Attachies[#Attachies + 1] = {
attachment = pew.item,
label = QBCore.Shared.Items[item].label,
attachment = attachmentType,
label = label,
}
end
end
Expand All @@ -807,10 +814,10 @@ RegisterNUICallback('RemoveAttachment', function(data, cb)
}
cb(DJATA)
else
RemoveWeaponComponentFromPed(ped, joaat(data.WeaponData.name), joaat(Attachment.component))
RemoveWeaponComponentFromPed(ped, joaat(WeaponData.name), joaat(Attachment))
cb({})
end
end, data.AttachmentData, data.WeaponData)
end, data.AttachmentData, WeaponData)
end)

RegisterNUICallback('getCombineItem', function(data, cb)
Expand Down
4 changes: 1 addition & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fx_version 'cerulean'
game 'gta5'

lua54 'yes'
description 'QB-Inventory'
version '1.2.4'

Expand Down Expand Up @@ -34,5 +34,3 @@ files {
}

dependency 'qb-weapons'

lua54 'yes'
Binary file added html/images/advscope_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/barrel_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/bellend_muzzle_brake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/boomcamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/brushcamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added html/images/comp_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/digicamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added html/images/fat_end_muzzle_brake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added html/images/flat_muzzle_brake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/geocamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/grip_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/heavy_duty_muzzle_brake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/holoscope_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/largescope_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/leopardcamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/medscope_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/nvscope_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/patriotcamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/perseuscamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/precision_muzzle_brake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/sessantacamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/skullcamo_attachment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added html/images/slanted_muzzle_brake.png
Binary file added html/images/smallscope_attachment.png
Binary file removed html/images/smg_scope.png
Diff not rendered.
Binary file removed html/images/snspistol_part_1.png
Diff not rendered.
Binary file removed html/images/snspistol_part_2.png
Diff not rendered.
Binary file removed html/images/snspistol_part_3.png
Diff not rendered.
Binary file added html/images/split_end_muzzle_brake.png
Binary file added html/images/squared_muzzle_brake.png
File renamed without changes
Binary file added html/images/tactical_muzzle_brake.png
Binary file added html/images/thermalscope_attachment.png
Binary file added html/images/woodcamo_attachment.png
Binary file added html/images/zebracamo_attachment.png
Loading

0 comments on commit fbc05f6

Please sign in to comment.