Forum > Serverside Modding
[QUESTION] [WotLk] [ELUNA/LUA] Event for item purchase.
(1/2) > >>
ruben381:
Is there any way to hook into an event for an item purchase?
I'm trying to make a vendor where some items can only be purchased if certain conditions are met. There doesn't seem to be an 'item purchased' hook anywhere, but I'm wondering if anyone has done this in a more hacky way?
Ideally, I'd like to be able to do this:
function itemPurchased(event, player, item) local arbitraryCondition = GetPointsFor(player) local itemID = item:GetEntry() if(itemID == VENDOR_ITEM_1) then if(arbitraryCondition >= 3000)then return true; else player:SendBroadcastMessage("Requires 3000 arbitrary condition points dumbass") return false; (or, like, player:RemoveItem(itemID, 1)) end end end
Obviously, I'm using LUA. If anyone has any insight on this it would be greatly appreciated. Thanks guys.
Grymskvll:
Don't think there's an existing hook for it. I guess you could try to add it or request it. Regardless, wouldn't it be more elegant to use the Blizzlike currency system? I guess that might require a client-side patch for new entries in CurrencyType.dbc and maybe CurrencyCategory.dbc, unless you want to reuse an existing currency. You could maybe recycle item ID 37711: [Currency Token Test Token 1], it defaults to the "Miscellaneous" currency category and you could change the name and tooltip of the item server-side. That way, items in the vendor page would also have the right cost displayed. I don't know if that fits your design goal, though.
ruben381:
--- Quote from: "Grymskvll" ---Don't think there's an existing hook for it. I guess you could try to add it or request it. Regardless, wouldn't it be more elegant to use the Blizzlike currency system? I guess that might require a client-side patch for new entries in CurrencyType.dbc and maybe CurrencyCategory.dbc, unless you want to reuse an existing currency. You could maybe recycle item ID 37711: [Currency Token Test Token 1], it defaults to the "Miscellaneous" currency category and you could change the name and tooltip of the item server-side. That way, items in the vendor page would also have the right cost displayed. I don't know if that fits your design goal, though. --- End quote ---
I mean, I could potentially do that. The system is actually for reputations however, so it's not a 'cost', it's just a purchasing condition. The item should still have its normal gold cost, and the reputation shouldn't be 'consumed' on use. For these reasons I think I need a different solution.
Grymskvll:
There already exist items that you can only buy if you meet rep requirements (things like item 30623: [Reservoir Key]). I tried adding such an item to an NPC unrelated to the reputation and it still checked my rep when buying, so I assume any item with a reputation requirement (on the item itself) will have that reputation as a purchasing requirement.
In other words, try just putting a rep requirement on items and it wont let you buy them unless you meet the requirement.
ruben381:
--- Quote from: "Grymskvll" ---There already exist items that you can only buy if you meet rep requirements (things like item 30623: [Reservoir Key]). I tried adding such an item to an NPC unrelated to the reputation and it still checked my rep when buying, so I assume any item with a reputation requirement (on the item itself) will have that reputation as a purchasing requirement.
In other words, try just putting a rep requirement on items and it wont let you buy them unless you meet the requirement. --- End quote ---
Yeah i understand that, but im using a custom reputation system with reputations that dont exist in WoW, and dont really use the WoW reputation system. Its literally juat comparing two numbers and cancelling the purchase or retracting the item if conditions are not met. But, it looks like its not really possible. Thanks for trying to help anyway dude i appreciate it.
Navigation
[0] Message Index
[#] Next page
|