Likes: 0
Results 1 to 3 of 3
Thread: Npc Teleport
-
07-07-09, 02:10 PM #1
Npc Teleport
Register to remove this adOk guys this is my 1st tutorial on the matter at hand: Lua Npc Teleporter Script,
I will only be covering the actual script not the npc itself.
Okay 1st you need to start off with this:
Code:local npcid = 0 function WarpNPC_OnGossipTalk(pUnit, event, player, pMisc)
pUnit = I dont really get this one so...
Event = This will be the Name of the text that you select
player = By going off the code i thin the Player is the Menu.
pMisc = I don't really know this one so i always left it 0 and it worked
To make it fair for Gankers or PVP we will add this snipet of code in
Code:if (player:IsInCombat() == true) then player:SendAreaTriggerMessage("You are in combat!") else
Now we are on to the part i Like... Actualy making the freakin menus [IMG]http://www.************/forums/images/smilies/tongue.gif[/IMG]
Code:pUnit:GossipCreateMenu(3544, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0)
now for pUnit:GossipMenuAddItem(3, "Name of Menu", #, 0) # will go up with each time you make another Menuadditem like this
Code:pUnit:GossipCreateMenu(3544, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end end
now heres the next snipet of code
Code:function WarpNPC_OnGossipSelect(pUnit, event, player, id, intid, code, pMisc) if(intid == 999) then pUnit:GossipCreateMenu(99, player, 0)
2nd line is defining what happens when you soon to be Back button (in submenus) will take you back here
now under that put
Code:pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end
so far we have:
Code:local npcid = 0 function WarpNPC_OnGossipTalk(pUnit, event, player, pMisc) if (player:IsInCombat() == true) then player:SendAreaTriggerMessage("You are in combat!") else pUnit:GossipCreateMenu(3544, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end end function WarpNPC_OnGossipSelect(pUnit, event, player, id, intid, code, pMisc) if(intid == 999) then pUnit:GossipCreateMenu(99, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end
Code:if(intid == 1) then pUnit:GossipCreateMenu(99, player, 0) pUnit:GossipMenuAddItem(3, "Sub Menu", 4, 0) pUnit:GossipMenuAddItem(3, "Sub Menu", 5, 0)
Now to make one of the "Sub Menu" be a teleport set it up like so
Code:if(intid == 4) then player:Teleport(Map, X, Y, Z) pUnit:GossipComplete(player) end
Notice the Intid changed from a 1 to a 4, that is because it is determining whether Menu item 1 was pressed or 4, 1 will open up the sub menu so you can get to 4 to teleport
At the end of the script have this:
Code:intid = 0 end RegisterUnitGossipEvent(Npc ID, 1, "WarpNPC_OnGossipTalk") RegisterUnitGossipEvent(Npc ID, 2, "WarpNPC_OnGossipSelect")
The script now is
Code:local npcid = 0 function WarpNPC_OnGossipTalk(pUnit, event, player, pMisc) if (player:IsInCombat() == true) then player:SendAreaTriggerMessage("You are in combat!") else pUnit:GossipCreateMenu(3544, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end end function WarpNPC_OnGossipSelect(pUnit, event, player, id, intid, code, pMisc) if(intid == 999) then pUnit:GossipCreateMenu(99, player, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 1, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 2, 0) pUnit:GossipMenuAddItem(3, "Name of Menu", 3, 0) pUnit:GossipSendMenu(player) end if(intid == 1) then pUnit:GossipCreateMenu(99, player, 0) pUnit:GossipMenuAddItem(3, "Sub Menu", 4, 0) pUnit:GossipMenuAddItem(3, "Sub Menu", 5, 0) pUnit:GossipMenuAddItem(0, "[Back]", 999, 0) if(intid == 4) then player:Teleport(Map, X, Y, Z) pUnit:GossipComplete(player) end intid = 0 end RegisterUnitGossipEvent(Npc ID, 1, "WarpNPC_OnGossipTalk") RegisterUnitGossipEvent(Npc ID, 2, "WarpNPC_OnGossipSelect")
› See More: Npc TeleportLast edited by b14d3r11; 07-07-09 at 02:17 PM.
-
07-07-09, 02:13 PM #2
Nice tutorial =D from me
-
07-07-09, 02:17 PM #3
Register to remove this ad
Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread
Visitors found this page by searching for:
Nobody landed on this page from a search engine, yet!
SEO Blog