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

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

merged 4 commits into from
Dec 22, 2023

Conversation

mikigoalie
Copy link
Contributor

No description provided.

@mikigoalie mikigoalie changed the title update(client): fire event on components update(client): fire event on mounting weapon components Dec 13, 2023
@thelindat
Copy link
Member

Technically can just use ox_inventory:updateInventory or ox_inventory:currentWeapon events fwiw

@thelindat
Copy link
Member

First triggers on any update event. Second when the current weapon or its metadata changes; which gives you what you need.

@mikigoalie
Copy link
Contributor Author

mikigoalie commented Dec 13, 2023

Yeah, for my needs it is pretty much sufficient, although I think it would be easier to work with the event in this pr in future. If this feat is not wanted, feel free to close it

client.lua Outdated
@@ -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

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]])

@thelindat thelindat merged commit 73fc372 into overextended:main Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants