| | Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE] |  | 
06-10-2009
|  | Knight-Lieutenant | | | Join Date: Jan 2009 Location: Denmark
Posts: 316
Reputation: 19 Level up: 31%, 345 Points needed |  | | [Guide] Lua Gossip on Items (Average) Hello!
It's time for my first guide evooor o.O
I've been looking around and I didn't find any guides regarind this subject. So I thought I would make an easy guide on how to apply some Gossip Lua on an item! (NOTE: This guide is easy, for the average Lua scripter. Not a Newbie guide. Before you do this I suggest you make sure that you know how to work with Lua Gossip Menus first as it's not that different from that) Let's get started.
First we set up our usual menu, when working with Gossip scripts (But adds a few modifications!): Code: function Item_Trigger(item, event, player)
Item_menu(item, player)
end
function Item_menu(item, player)
if (player:IsInCombat() == true) then
player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
else
item:GossipCreateMenu(XXX, player, 0)
item:GossipMenuAddItem(Y, "Mall", 1, 0)
item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
item:GossipSendMenu(player)
end
end
Ok, lets break it down. Code: function Item_Trigger(item, event, player)
Item_menu(item, player)
end
When making Lua Scripts for Items which includes Gossip this function is essential. It defines that we want a menu to show up, as if you were talking with an NPC! Remember we work with items here so we wont use pUnit or Unit. We use item. (item, player) Code: function Item_menu(item, player)
if (player:IsInCombat() == true) then
player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
else
This function above should be pretty obvious. It checks if the player is in combat, and if he/she is then it wont work and give him or her the message that it wont work before he or she gets out of combat. Code: item:GossipCreateMenu(XXX, player, 0)
item:GossipMenuAddItem(Y, "Mall", 1, 0)
item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
item:GossipSendMenu(player)
end
end
So now we have the all familiar Gossip Menu, but with a twist. We use item:Gossip instead of pUnit- or Unit:Gossip, since it's an item and not a unit. The red X's is just the number that has to be unique on every single Gossip Script you ever make that is put into the same Script Folder. The red Y's is just Icons. I don't have a list for that. So the "body" of our Gossip Menu is now created. Now we have to "Linkt" those options to actions. Code: function OnSelect(item, event, player, id, intid, code)
Now we need the function above. A Gossip always got at least two functions to register. This is no different. There is one difference tho. I am sure you can spot it. Code: function OnSelect(item, event, player, id, intid, code)
if (intid == 1) then
player:Teleport(mapid,x,y,z,o)
See. Here we don't need the item to do it for us. We continue. Code: function OnSelect(item, event, player, id, intid, code)
if (intid == 1) then
player:Teleport(mapid,x,y,z,o)
else
if (intid == 2) then
player:CastSpell(1908) -- Uber Heal Over time
else
if (intid == 3) then
player:LearnSpell(15007) -- Learns Ressurection Sickness
player:UnlearnSpell(15007) -- Unlearns Ressurection Sickness
player:SendAreaTriggerMessage("Good as new!")
player:SendBroadcastMessage("Good as new!")
end
Now we are almost done. We just need the last two functions that will register this. Code: RegisterItemGossipEvent(ITEM ID,1,"Item_Trigger")
RegisterItemGossipEvent(ITEM ID,2,"OnSelect")
Remember that we have to use RegisterItemGossipEvent since this is not a Unit. The 1 is OnTalk (Which basically is pressing the item in this case) and 2 is OnSelect. Which is when we choose one of the stated options. The Result should look like this: Code: function Item_Trigger(item, event, player)
Item_menu(item, player)
end
function Item_menu(item, player)
if (player:IsInCombat() == true) then
player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
else
item:GossipCreateMenu(XXX, player, 0)
item:GossipMenuAddItem(Y, "Mall", 1, 0)
item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
item:GossipSendMenu(player)
end
end
function OnSelect(item, event, player, id, intid, code)
if (intid == 1) then
player:Teleport(mapid,x,y,z,o)
else
if (intid == 2) then
player:CastSpell(1908) -- Uber Heal Over time
else
if (intid == 3) then
player:LearnSpell(15007) -- Learns Ressurection Sickness
player:UnlearnSpell(15007) -- Unlearns Ressurection Sickness
player:SendAreaTriggerMessage("Good as new!")
player:SendBroadcastMessage("Good as new!")
end
RegisterItemGossipEvent(ITEM ID,1,"Item_Trigger")
RegisterItemGossipEvent(ITEM ID,2,"OnSelect")
Now all you need to do, is having an item which can be right-clicked already. Else it wont work. Look around in your Database and check for like...Polar Bear Pet or something. Check what type or class the item is, and see if you can get the same right click function.
I hope this can be used! | Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
06-12-2009
|  | Knight-Lieutenant | | | Join Date: Jan 2009 Location: Denmark
Posts: 316
Reputation: 19 Level up: 31%, 345 Points needed |  | | | My last post was removed?
Anyway..29 views yet still no comments -.-' | 
06-14-2009
| | New User | | | Join Date: Sep 2008
Posts: 17
Reputation: 2 Level up: 64%, 145 Points needed | | | First post  I like this thanks +rep !!!You know i am new in lua and i like something like this! | 
06-14-2009
|  | Knight-Lieutenant | | | Join Date: Jan 2009 Location: Denmark
Posts: 316
Reputation: 19 Level up: 31%, 345 Points needed |  | | | Thank you =) | 
06-14-2009
|  | Knight-Lieutenant | | | Join Date: Feb 2009 Location: Sweden
Posts: 357
Reputation: 37 | | This is good AngelSandy | 
06-14-2009
|  | Sergeant Major | | | Join Date: Mar 2009 Location: Ohio
Posts: 147
Reputation: 69 Level up: 83%, 88 Points needed |  | | | Repost, should probably check your forums. Although it's nice.. Please look.
__________________ Need help with your PS (private server) well PM me and I'll do the best I can to help you out. ~-L0sT-~ | 
06-18-2009
|  | Knight-Lieutenant | | | Join Date: Jan 2009 Location: Denmark
Posts: 316
Reputation: 19 Level up: 31%, 345 Points needed |  | | | Is it a repost?
I checked the forums and the "suggestions" it shows also =/ | 
06-18-2009
|  | Site Donator | | | Join Date: Mar 2009 Location: at my PC
Posts: 25
Reputation: 4 Level up: 50%, 201 Points needed | | | | it's a repost yes but this is a way better guide than most of the others. | 
06-20-2009
|  | Knight-Lieutenant | | | Join Date: Jan 2009 Location: Denmark
Posts: 316
Reputation: 19 Level up: 31%, 345 Points needed |  | | Quote:
Originally Posted by Death_Master ...but this is a way better guide than most of the others. | Why thank you ^^ |  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 08:00 AM. |