[Pointshop] Adding an option to the menu for a specific item

Hello.

I am currently trying to get only a specific pointshop item to have an extra menu option. By menu option, I mean when you click on an item in the Pointshop it pops up a menu that says “Buy” or if you’ve already bought it, “Sell” and “Holster”. I know how to add a menu option, but I only want the menu option on a specific pointshop item, not all of them.

The code I currently have is:



if Item.Name == "Jihad Bomb Sound 2" then
	menu:AddOption('Sound Preview', function()
		surface.PlaySound("jihadsound/sound2.mp3")
	end)
end


This for some reason does not work. I may be overlooking something very simple, but I’m not sure. I believe that “Item” is undefined, but I’m unsure how to get the specific item’s name from pointshop/items/jihadbombs/sound2.lua (Item.Name).

I get this error:



[ERROR] addons/pointshop/lua/pointshop/vgui/dpointshopitem.lua:59: attempt to index global 'Item' (a nil value)
  1. DoClick - addons/pointshop/lua/pointshop/vgui/dpointshopitem.lua:59
   2. DoClick - addons/pointshop/lua/pointshop/vgui/dpointshopitem.lua:107
    3. unknown - lua/vgui/dlabel.lua:204


I referenced the Pointshop Documentation, but that didn’t appear to be much of a help.

Any help is greatly appreciated.

Thanks,
Icee2199

this happened to me aswell, everytime i added a pointshop item, after i restarted all my errors went away

Yes, but I’m attempting to add a menu option, not a pointshop item.

Shouldn’t you be using


self.Data.Name

instead of


Item.Name

?

When switching Item.Name to self.Data.Name, as shown below, it now works. Thanks for the help.



if self.Data.Name == "Jihad Bomb Sound 2" then
	menu:AddOption('Sound Preview', function()
		surface.PlaySound("jihadsound/sound2.mp3")
	end)
end