MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides

Homepage Register FAQ Members Mark Forums Read Advertise Marketplace FPSowned
Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > WoW Emulator Server > Emulator Server Guides
Reload this Page LUA: Understanding Gossip Menus
Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE]

Reply
 
LinkBack Thread Tools
LUA: Understanding Gossip Menus
(#1)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,968
Join Date: Oct 2007
Wow Guides LUA: Understanding Gossip Menus - 05-19-2008

In this guide, you will learn to use Gossip Menus correctly. I will be using the WarpNPC LUA script as my example. You will need to read my guide on Basic LUA before you move on to this guide, as I call it, my LUA 1.5 guide before the advanced guide is released.
Prerisque: [Only registered and activated users can see links. ]

This guide is currently being revamped - meaning its being rewritten in a better format. I will be doing guards in LUA as my example.

Ok, lets get started!

First, your going to need the patch for this. I recommend that you do not use it as it does not work with the latest OpenAscent or Ascent revisions. I would simply recommend that you use LUA++'s LUA folder, which has all these cool LUA patches applied. For those of you who can compile, here is their SVN address: [Only registered and activated users can see links. ]. For those of you who can't, here is it in .ZIP format: [Only registered and activated users can see links. ]. Simply replace this LUAScripting folder with the current one.

Second, we need to look at the commands that are included that we will need to create our Gossip Menu.
Here they are:
:GossipCreateMenu
:GossipMenuAddItem
:GossipSendMenu
:GossipComplete
:GossipSendPOI


Second, it is time to start our script off with the usual "function" line.
Example:
Quote:
function On_Gossip (pUnit, event, player)
Third, we must create our Gossip Menu.
Quote:
pUnit:GossipCreateMenu(100, player)
Next, it is time to add the actual menus and lines.
Quote:
pUnit:GossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
Third, Make sure that you are labeling the "" part with the Menu's name and then the number following that, the number of the menu.

Fourth, we need to send the menu with the function :GossipSendMenu.
Code:
pUnit::GossipSendMenu(player)

Fifth, we need to end that function. So it should look something like this:
Quote:
function On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
pUnit:GossipSendMenu(player)
end
Now to start on the submenus! Start it off with function line:
Quote:
function Gossip_Submenus (pUnit, event, player, id, intid, code)
Sixth, we need to declare that we are using the menu 1, or "Horde Cities". We will do this by using this statement:
Quote:
if(intid == 1) then
This says that if the menu number is 1, then we will recall the following until we hit the "end" statement.

Now, we need to add our submenus for "Horde Cities". We also need to add the :GossipSendMenu to the bottom.
Quote:
pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Orgrimmar", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Undercity", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Thunder Bluff", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "Silvermoon", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu
Take note that the 99 is 1 number less than the 100 we used in the first function. This is consistant for all submenus. Now add the "end" statement to the end of that group of Menus and you should have something like this:
Quote:
function On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipGossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipGossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
pUnit:GossipSendMenu(player)
end
function Gossip_Submenus (pUnit, event, player, id, intid, code)
if(intid == 1) then
pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Orgrimmar", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Undercity", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Thunder Bluff", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "Silvermoon", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end

Seventh, its time to do the submenu for the number 2, or "Alliance Cities". We have to use the "if" statement again to recall this menu.
Quote:
if(intid == 2) then
Now guess what? Thats right, we have to add the submenus.
So repeat the steps from step six, exept this time we need to change the numbers after the Menu name because they will be recalled later. It should look something like this:
Quote:
pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Stormwind", 14, 0)
pUnit:GossipMenuAddItem(player, 5, "Ironforge", 15, 0)
pUnit:GossipMenuAddItem(player, 5, "Darnassus", 16, 0)
pUnit:GossipMenuAddItem(player, 5, "Exodar", 17, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:MenuSendToPlayer(player)
end
Eighth, we need to add the locations for the teleporting. Use this format and simply repeat. After the == signs, add the number after the submenu name for the teleportion. Of course the format is (Map, X, Y, Z).
Quote:
if(intid == 10) then
player:Teleport(1, 1371.068970, -4370.801758, 26.052483)
end
Now just repeat this until your done adding all the submenu's teleport locations.

Then you should add this line at the end of all your teleports:
Quote:
intid = 0
end
Finally, register the events:
Quote:
RegisterGossipEvent(32000 , 1, "On_Gossip")(32000 , 2,"Gossip_Submenus")
For 32000, you simply put the NPC ID. You will then need to create an NPC with the flags set to gossip flags, or 1.

Here is my TeleportNPC:
[Only registered and activated users can see links. ]

If your having trouble see this guide: [Only registered and activated users can see links. ]

I hope this guide helped you and will keep you busy until my LUA: For Advanced Users guide is released. I will, in the meantime, be doing some XML and LUA tutorials related to WoW addons. So if you wanna check those out feel free.

-SectorSeven

Credits: To whoever has the time to find the coords. for these places...

Last edited by SectorSeven; 05-31-2008 at 03:21 PM.
Reply With Quote

Donate to remove ads.
(#2)
Old
Exona is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 2
Reputation: 1
Exona is an unknown quantity at this point
 
Posts: 11
Join Date: Jan 2007
Location: Norway
05-19-2008

Would you mind going into detail about what each part does, like in your first tut, and have lists of available options etc. Otherwise, great guide
Reply With Quote
(#3)
Old
Creepfold's Avatar
Creepfold is Offline
Contributor
Rep Power: 3
Reputation: 158
Creepfold has a spectacular aura aboutCreepfold has a spectacular aura about
 
Posts: 494
Join Date: Jul 2007
Location: Behind You!
05-19-2008

SectorSeven, you are realy good in LUA it seems like this script, can i talk to you through MSN? you need to learn me some stuff and i want to ask you some stuff to
I wish to get more advanced with LUA's
add me : [Only registered and activated users can see links. ]


EDIT : i made a small version of this myself, i dont know if it works or not but :

Code:
 function WarpNPC_On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipMenuAddItem(player, 0, "Horde Locations", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Locations", 2, 0)
pUnit:GossipSendMenu(player)
end

function WarpNPC_Submenus (pUnit, event, player, id, intid, code)
if(intid == 1) then
pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Mall", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Leveling Road", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Custom Instances", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end

if(intid == 2) then
pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Mall", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Leveling Road", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Custom Instances", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:MenuSendToPlayer(player)
end

if(intid == 10) then
player:Teleport(1, -1657.646973, 3096.333008, 32.558029)
end

if(intid == 11) then
player:Teleport(580, 1713.559937, 600.632690, 29.677027)
end

function WarpNPC_Submenus2 (pUnit, event, player, id, intid, code)
if(intid == 12) then
pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Malygos' Lair(10-15Man)", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "Scarlet Monastery(5-10Man)", 14, 0)
pUnit:GossipMenuAddItem(player, 5, "The Deadmines(10Man)", 15, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end

if(intid == 13) then
player:Teleport(530, 3099.646729, 1513.975342, 192.195267)
end

if(intid == 14) then
player:Teleport(0, 2888.867188, -810.674438, 162.649765)
end

if(intid == 15) then
player:Teleport(0, -11211.107422, 1661.814087, 26.746098)
end

RegisterGossipEvent(32000 , 1, "WarpNPC_On_Gossip")(32000 , 2,"WarpNPC_Submenus")(32000 , 2,"WarpNPC_Submenus2")
Should this work or? and also is there any way to test the LUA's on if they work or not without hosting an actual server?


Creepfold

Last edited by Creepfold; 05-19-2008 at 02:38 PM.
Reply With Quote
(#4)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,968
Join Date: Oct 2007
05-19-2008

I'll look at it later.
Added to MSN.
Sorry its exam week so im studying alot!
Reply With Quote
(#5)
Old
mager1794's Avatar
mager1794 is Offline
Contributor
Rep Power: 1
Reputation: 113
mager1794 will become famous soon enoughmager1794 will become famous soon enough
 
Posts: 303
Join Date: Feb 2008
05-19-2008

Hey SectorSeven i'd love to speak to you a bit to help me learn a bit more LUA im pretty advanced at it but theres alot you can teach me i believe (also i wanna ask something about ABD)

my msn is

[Only registered and activated users can see links. ]

i dont have MSN messenger on this comp and my other one is broke ok dude but i'll get on this one soon : )

+rep btw nice guide


Reply With Quote
(#6)
Old
pachuco55's Avatar
pachuco55 is Offline
Master Sergeant
Rep Power: 1
Reputation: 12
pachuco55 is on a distinguished road
 
Posts: 78
Join Date: Mar 2008
Location: Texas
05-21-2008

Right before you begin your if statements, you have a function. Wouldn't you need two end's in order to close both the last if statement and then the function?

btw +rep
Reply With Quote
(#7)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,968
Join Date: Oct 2007
05-21-2008

True that. My mistake...it was 3 in the morning
Reply With Quote
These are the codes to the cities
(#8)
Old
degoscar is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 1
Reputation: 1
degoscar is an unknown quantity at this point
 
Posts: 9
Join Date: Apr 2008
These are the codes to the cities - 05-22-2008

Orgrimmar 1 1484 -4417 25

Undercity 0 1831 238 60

Thunder Bluff 1 -1277 118 131

Silvermoon 530 9413 -7277 14



Stormwind 0 -8951 524 96

Ironforge 0 -4981 -881 501

Exodar 530 -3826 -11686 -107

Darnassus 1 9948 2413 1327


In case anyone cares to have the loc's here they are.


Joe
Reply With Quote
(#9)
Old
controlsx2 is Offline
Sergeant Major
Rep Power: 2
Reputation: 7
controlsx2 is an unknown quantity at this point
 
Posts: 142
Join Date: Jun 2007
05-22-2008

[Only registered and activated users can see links. ]. Simply replace this LUAScripting folder with the current one.

I cant find a folder called LUAScripting. how do i do it?
Reply With Quote
(#10)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,968
Join Date: Oct 2007
05-22-2008

You have to compile your own ascent.
Reply With Quote
(#11)
Old
pachuco55's Avatar
pachuco55 is Offline
Master Sergeant
Rep Power: 1
Reputation: 12
pachuco55 is on a distinguished road
 
Posts: 78
Join Date: Mar 2008
Location: Texas
05-22-2008

Quote:
Third, we must create our Gossip Menu.
Code:
pUnit:GossipCreateMenu(100, player)
Will the first number always be 100? What does it represent?
Reply With Quote
(#12)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,968
Join Date: Oct 2007
05-22-2008

No, but the numbers after it (99 in this case) has to be 1 lower
Reply With Quote
(#13)
Old
pachuco55's Avatar
pachuco55 is Offline
Master Sergeant
Rep Power: 1
Reputation: 12
pachuco55 is on a distinguished road
 
Posts: 78
Join Date: Mar 2008
Location: Texas
05-22-2008

Since I am only having one menu button in my menu, then I wouldn't need to worry about that, correct?

Also, does there need to be an OnGossipTalk function? I don't remember where I learned that but I think it was from another warp npc code.
Reply With Quote
(#14)
Old
imsosorrygms is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 1
Reputation: 2
imsosorrygms is an unknown quantity at this point
 
Posts: 21
Join Date: Apr 2008
05-23-2008

Sector... When i try to replace the luascripting folder and then compile the scripts i get alot of errors... could u help me?
Reply With Quote
(#15)
Old
imsosorrygms is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 1
Reputation: 2
imsosorrygms is an unknown quantity at this point
 
Posts: 21
Join Date: Apr 2008
05-23-2008

Code:
3>SpellHandlers - 0 error(s), 1 warning(s)
5>------ Build started: Project: LUAScripting, Configuration: Release Win32 ------
5>Compiling...
5>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
5>LUAEngine.cpp
4>Setup.cpp
5>..srcluascriptingLUAEngine.cpp(4) : fatal error C1083: Cannot open include file: 'ScriptSetup.h': No such file or directory
5>Build log was saved at "file://c:UsersChrilleDesktopNy mappsrcscriptsprojects2008_int_release_LUAScriptingBuildLog.htm"
5>LUAScripting - 1 error(s), 1 warning(s)
Reply With Quote
Reply


Donate to remove ads.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On




Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253