Skip to content

Conversation

@lenzh
Copy link
Contributor

@lenzh lenzh commented Jun 7, 2024

with the new QB updates inventory events now needs to be called different

lenzh added 2 commits June 7, 2024 22:57
events now called ps-inventory
now called ps-inventory
Copy link
Member

@xFutte xFutte left a comment

Choose a reason for hiding this comment

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

Code looks good, just needs to test that everything still works after the renaming.

@lenzh
Copy link
Contributor Author

lenzh commented Jun 7, 2024

if im correct this will be working with all latest qb updates

@MonkeyWhisper
Copy link
Member

What did you approve @Max-Storm-03? You got no clue what is going on.

@FoxThirtySix
Copy link

Hi there! Having a strange issue still with weapon attachments not being able to be viewed in inventory. With the latest core updates and up-to-date dependencies, I am still having this issue. Below are the steps I'm doing to get the error, at the request of Lenzh.

  • Give myself a weapon (any weapon).
  • Give myself a weapon attachment (any attachment).
  • "Use" the weapon attachment on the weapon, attaching it.
  • Click on the weapon in its inventory slot to view attachments, and I receive the following error

psinverror

@xFutte
Copy link
Member

xFutte commented Jun 8, 2024

Hi there! Having a strange issue still with weapon attachments not being able to be viewed in inventory. With the latest core updates and up-to-date dependencies, I am still having this issue. Below are the steps I'm doing to get the error, at the request of Lenzh.

  • Give myself a weapon (any weapon).
  • Give myself a weapon attachment (any attachment).
  • "Use" the weapon attachment on the weapon, attaching it.
  • Click on the weapon in its inventory slot to view attachments, and I receive the following error

psinverror

Is this while testing this PR?

@FoxThirtySix
Copy link

Hi there! Having a strange issue still with weapon attachments not being able to be viewed in inventory. With the latest core updates and up-to-date dependencies, I am still having this issue. Below are the steps I'm doing to get the error, at the request of Lenzh.

  • Give myself a weapon (any weapon).
  • Give myself a weapon attachment (any attachment).
  • "Use" the weapon attachment on the weapon, attaching it.
  • Click on the weapon in its inventory slot to view attachments, and I receive the following error

psinverror

Is this while testing this PR?

I had this before and after, yes.

fixed the NUI callback GetWeaponData error
@lenzh
Copy link
Contributor Author

lenzh commented Jun 10, 2024

issue should now be fixed @FoxThirtySix

weapon: itemData.name,
ItemData: itemData,
}),
function(data) {
Copy link
Member

Choose a reason for hiding this comment

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

Please serialize the data we get through the event to prevent exploits.

Comment on lines +548 to +556
$(".item-info-description").html(
"<p><strong>Serial: </strong><span>" +
itemData.info.serie +
"</span></p><p><strong>Ammo: </strong><span>" +
itemData.info.ammo +
"</span></p><p><strong>Attachments: </strong><span>" +
attachmentString +
"</span></p>"
);
Copy link
Member

@xFutte xFutte Jun 11, 2024

Choose a reason for hiding this comment

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

Inserting html like this directly on an HTML element can be quite dangerous for exploding the code. A better solution would be to build up a couple of elements and then appending them to the item-info-description element. It could look somewhat like this:

const description = document.createElement("p");
const header = document.createElement("strong");
const value = document.createElement("span");

header.innerText = "Serial:";
value.innerText = item.info.ammo;
description.innerHTML = `${header} {value}`

document.querySelector(".item-info-description").appendChild(description)

You can then loop over all the values inside the itemData.info array to output them all. Requires a little fiddling with the code above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was default code from the old ps-inv just made it compat with new qb-core

@MonkeyWhisper MonkeyWhisper merged commit 2b99906 into main Jun 12, 2024
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.

6 participants