Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 3 of 3

Thread: Npc Teleport

  1. #1
    Beginner

    Join Date
    Jul 2009
    Posts
    1
    Post Thanks / Like
    Rep Power
    16
    Reputation
    4

    Npc Teleport


    Register to remove this ad
    Ok 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)
    This code is telling how the whole parts following are going to work.
    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
    This is making sure the player isnt in combat, and if the player is it will display the message "You are in Combat!"

    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)
    This is kinda self Explanitory, but if you dont get it... pUnit:GossipCreateMenu will create the menu and pUnit:GossipMenuAddItem will make the text to click

    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
    the # going up will define a new menu

    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)
    the 1st line is saying when you actualy select one of those menus
    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
    This is just saying whats gonna happen when you select it

    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
    This will define the basic menu; like when you go and talk to a NPC it will show 3 choices and when u click nothing will happen. so to make something happen or to add submenus do this
    Code:
     if(intid == 1) then
    pUnit:GossipCreateMenu(99, player, 0)
    pUnit:GossipMenuAddItem(3, "Sub Menu", 4, 0)
    pUnit:GossipMenuAddItem(3, "Sub Menu", 5, 0)
    This is saying if you click on the "Name of Menu", 1 then it will open up a sub menu with 2 items but notice the "player" slot changed and went up 1 from the previous menu.

    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
    This will teleport you to the provided location.

    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")
    This will finish the script when everythings is pressed and done with, the NPC Id will be the Id of the NPC you make for your script.

    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")
    Well this is what I know and I hope you guys have learned something from this, I learned all of this from looking at other scripts and realizing what they did. So have fun guys [IMG]http://************/forums/images/*******/misc/progress.gif[/IMG] [IMG]http://************/forums/images/*******/buttons/edit.gif[/IMG]




    › See More: Npc Teleport
    Last edited by b14d3r11; 07-07-09 at 02:17 PM.



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Scout

    Join Date
    Jul 2009
    Posts
    20
    Post Thanks / Like
    Rep Power
    16
    Reputation
    40
    Nice tutorial =D from me

  4. #3
    Contributor
    Onlykl's Avatar
    Join Date
    Jan 2009
    Location
    127.0.0.1
    Posts
    247
    Post Thanks / Like
    Rep Power
    19
    Reputation
    244

    Register to remove this ad
    Quote Originally Posted by mager1794 View Post
    Nice tutorial =D from me
    same from me

 

 

Visitors found this page by searching for:

Nobody landed on this page from a search engine, yet!
SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 09:49 PM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org