Hello today i will be teaching you the some advanced things with lua like intid and such this is very muched used in almost all servers with teleporters.
First you have to start it off as if any other lua.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Second you are going to create the gossip menu.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
TextID = Usually 100 you can find others in your db or just use 100
player = Means that it sends it to the player you must keep this.
0 = Unknown (Works if you just leave it)
Third you need to add a menu item.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", [intid], extra)
Icon = Usually 0 or 1 it is the icon that is next to the option like a cog or wings.
MenuName = What you would like the option to say.
[intid] = In this case it is going to be the intid so id say 1 - infinite depending how many options.
extra = Usually un-used so just leave it as 0.
Fourth you need to send the menu to the player and end this part of the script.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", extra)
Unit:GossipSendMenu(player)
end
player = Sends the menu to player must leave it for it to work
Fifth you need to put the intid to work you will declare that anything beyond the point of declaration and the next "end" will happen when you choose the option.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", extra)
Unit:GossipSendMenu(player)
end
if (intid == [intid]) then
Sixth we are going to make the option do something in this case we are going to make it have a song play.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", extra)
Unit:GossipSendMenu(player)
end
if (intid == [intid]) then
Unit:PlaySoundToSet(SoundID)
Seventh you must complete the gossip and end the whole script.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", extra)
Unit:GossipSendMenu(player)
end
if (intid == [intid]) then
Unit:PlaySoundToSet(SoundID)
player:GossipComplete()
end
end
Last but definetly not least we must register the lua event.
Code:
function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
Unit:GossipCreateMenu(TextID, player, 0)
Unit:GossipMenuAddItem(Icon, "MenuName", extra)
Unit:GossipSendMenu(player)
end
if (intid == [intid]) then
Unit:PlaySoundToSet(SoundID)
player:GossipComplete()
end
end
RegisterUnitGossipEvent(EntryID, 1, "firstname_secondname")
EntryID = The id of the npc you wish to talk.
1 = First Gossip event goes up everytime you register a new event.
firstname_secondname = Replace with your name.
Then you must make sure that your npc can be used for gossip the flag id is 1 .
Then you must save the script as a lua and put it in script_bin for it to work. To add more menu items repeast adding menu item and making options .
Hope this helps.
Bai :wave: