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.
Second you are going to create the gossip menu.Code:function firstname_secondname(Unit, Event, player, id, intid, code, pMisc)
TextID = Usually 100 you can find others in your db or just use 100Code:function firstname_secondname(Unit, Event, player, id, intid, code, pMisc) Unit:GossipCreateMenu(TextID, player, 0)
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.
Icon = Usually 0 or 1 it is the icon that is next to the option like a cog or wings.Code:function firstname_secondname(Unit, Event, player, id, intid, code, pMisc) Unit:GossipCreateMenu(TextID, player, 0) Unit:GossipMenuAddItem(Icon, "MenuName", [intid], extra)
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.
player = Sends the menu to player must leave it for it to workCode:function firstname_secondname(Unit, Event, player, id, intid, code, pMisc) Unit:GossipCreateMenu(TextID, player, 0) Unit:GossipMenuAddItem(Icon, "MenuName", extra) Unit:GossipSendMenu(player) end
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.
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
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)
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
EntryID = The id of the npc you wish to talk.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")
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:

![[Guide] How to Advanced Lua.](https://www.ownedcore.com/forums/./ocpbanners/3/6/6/2/4/2/5c4835331063f7e21bc14db43840c51b.png)
![TradeSafe Middleman [Guide] How to Advanced Lua.](https://www.ownedcore.com/assets/mm/images/wits.png)
![CoreCoins [Guide] How to Advanced Lua.](https://www.ownedcore.com/forums/images/styles/OwnedCoreFX/addimg/wicc.png)



Reply With Quote![[Guide] How to Advanced Lua.](https://www.ownedcore.com/images/ba/g/b2.gif)



I'm only commenting now because I'm sure some people are leeching this.

i will use this to add to my collection of guides, if you dont mind i will give you the credit itl just be a compilation


