[Pointshop] Adding an option to the menu for a specific item
4 replies, posted
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:
[CODE]
if Item.Name == "Jihad Bomb Sound 2" then
menu:AddOption('Sound Preview', function()
surface.PlaySound("jihadsound/sound2.mp3")
end)
end
[/CODE]
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:
[CODE]
[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
[/CODE]
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 [CODE]self.Data.Name[/CODE] instead of [CODE]Item.Name[/CODE]?
When switching [i]Item.Name[/i] to [i]self.Data.Name[/i], as shown below, it now works. Thanks for the help.
[CODE]
if self.Data.Name == "Jihad Bomb Sound 2" then
menu:AddOption('Sound Preview', function()
surface.PlaySound("jihadsound/sound2.mp3")
end)
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.