Author Topic: Finding what item a player is holding.  (Read 453 times)

Hi
I've been trying to make script that does stuff when the player has a certain item out, but I can't find what function you need to use to get the item the player is holding. So far, i've tried the getMountedImage function for detecting the item, but it returns true if the player holds anything, not just the renderman detector.
Code: [Select]
if(!%this.getMountedImage(0) == "RenderDetectorImage") {
Help :(

Hi.

  • == is only for numbers. Use $=.
  • Instead of prepending the condition with an exclamation point, merge it with the comparison method. Use !$=.
  • The function you are using returns an object ID, not an object name. Compare it to nameToID("renderDetectorImage") instead.

So far, i've tried the getMountedImage function for detecting the item, but it returns true if the player holds anything, not just the renderman detector.

getMountedImage does not return true or false depending on whether the player is holding "the renderman detector", it returns the object ID of the image datablock in a specific slot.

Hi.

  • == is only for numbers. Use $=.
  • Instead of prepending the condition with an exclamation point, merge it with the comparison method. Use !$=.
  • The function you are using returns an object ID, not an object name. Compare it to nameToID("renderDetectorImage") instead.

getMountedImage does not return true or false depending on whether the player is holding "the renderman detector", it returns the object ID of the image datablock in a specific slot.
Oh, okay. Thanks