Alright. I’ve been looking around for a nice guide on creating Lua Gossips and I couldn’t find one. So I decided to take the time to make a nice simple guide to creating a teleport NPC. It’s a pretty simple NPC in reality, and I feel the best way to learn is to do it yourself. So this guide will largely force you to do the work. When it comes to learning these sorts of scripts you should look at other people’s work so that you can get an idea of how these sorts of things work. This doesn’t mean copy and paste! That helps no one…
So here we go. We are going to start with this little piece of our script. I’ll break it down right now. The local npcid is stating which NPC will use this script. The function is… well… what your script is going to do. pUnit:CreateGossipMenuForPlayer creates the gossip menu for player. The pUnit:MenuAddItem adds an item to the menu. Then there is the self-explanatory “end” line.
Code:
local npcid = 100000
function warp_on_gossip_talk(unit, event, player)
pUnit:CreateGossipMenuForPlayer(3543, player)
pUnit:MenuAddItem(player, 0, "First Gossip Lua", 1, 0)
pUnit:MenuSendToPlayer(player)
end
So now that we have this little set up we can move on to creating something worthwhile. We need to create the next part of our script. So we are going to add this to the script.
Code:
if(intid == 1) then
player:Teleport(0, x, y, z)
end
We are going to add this little bit of Lua to the bottom of our script. This is stating that if someone selected “First Gossip Lua” (You can see the intid == 1, just need a little reasoning to figure this one out), then you will be teleported to this location. The 0 is stating the mapid. Now the important part. x, y, z coordinates are a must. Go in game. Find a place you want this to port you too. Simply type .gps and bam! You’ve got your coordinates. Always, I repeat ALWAYS round your Z coordinate up to avoid falling through the world when being ported. Now to finish our script.
Code:
RegisterGossipEvent(100000 , 1, "warp_on_gossip_talk")
RegisterGossipEvent(100000 , 2, "warp_on_gossip_select")
Well that sums up our script. If you forget that final part then, well your whole script won’t work. Make sure you’re local npcid == the number in the registering part of your script. So now your script should look like this.
Code:
local npcid ==100000
function warp_on_gossip_talk(unit, event, player)
pUnit:CreateGossipMenuForPlayer(3543, player)
pUnit:MenuAddItem(player, 0, “First Gossip Lua”, 1, 0)
pUnit:MenuSendToPlayer(player)
end
if(intid == 1) then
player:Teleport(0, YOUR X COORD, YOUR Y COORD, YOUR Z COORD)
end
RegisterGossipEvent(100000, 1, “warp_on_gossip_talk”)
RegisterGossipEvent(100000, 2, “warp_on_gossip_select”)
There you go! I’ll be back to add more. Up next… Morph NPC! Hopefully this helped someone out. If not... well it was fun writing it.