Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(client): fire event on mounting weapon components #1553

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ local function useSlot(slot)

if success then
GiveWeaponComponentToPed(playerPed, currentWeapon.hash, component)
TriggerEvent('ox_inventory:updateWeaponComponents', "added", currentWeapon, component)
end
end
end)
Expand Down Expand Up @@ -1542,6 +1543,7 @@ RegisterNUICallback('removeComponent', function(data, cb)

if success then
RemoveWeaponComponentFromPed(playerPed, currentWeapon.hash, component)
TriggerEvent('ox_inventory:updateWeaponComponents', "removed", currentWeapon, component)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ox_inventory:updateWeaponComponent.
Use ' rather than " (i.e. 'removed', 'added').
Send the item name of the component being used (not just the hash).
Don't think there's much need to send currentWeapon at all.

Copy link
Contributor Author

@mikigoalie mikigoalie Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in latest commit, but double check it. I'll also PR 3095 weapons and components later

E: Do you want me to add hashes as 2nd arg? I didn't think of a case where you would need to get the exact hash of the item, so I haven't added it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TriggerEvent('ox_inventory:updateWeaponComponent', action --[['removed' | 'added']], component --[[hash]], componentItem --[[string]])

end

break
Expand Down