Need some help with my lua script menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    riizu's Avatar Active Member
    Reputation
    16
    Join Date
    Oct 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need some help with my lua script

    So, while making a current project, I decided to throw in some of my first attempts at Lua. Im aiming for it to do 3 things at the moment.

    -Have a dynamic chat message that greets people within a certain range, and differentiate between GM players and regular players
    -Activate the flight path (Thanks Stoneharry for your excellent guide) via Gossip Scripts
    -Teleport to the coordinates via Gossip Scripts

    [SPOILER]
    Code:
    local Players = GetInRangePlayers()
    
    
    
    function Johnny_McWeaksauce_Greeting(Unit, Event)
        If plr:IsGm() == true then
            Unit:SendChatMessage(14, 0, "Hello GM" Players)
        else
            Unit:SendChatMessage(14, 0, "Hello" Players)
        end
    end
    
    
    
    function Johhny_McWeaksauce_OnGossip(Unit, Event, Player)
        Unit:GossipCreateMenu(100, Player, 0)
        Unit:GossipMenuAddItem(0, "Fly to the Aviary", 1, 0)
        Unit:GossipMenuAddItem(0, "Go to the Surface", 2, 0)
        Unit:GossipSendMenu(Player)
    end
    
    function Johhny_McWeaksauce_OnSubMenu(Unit, Event, Player, id, intid, code)
        if (intid == 1) then
            --function flight_path_JohhnyMcWeaksauce(event, plr, message, type, language)
            --local Taxi = LuaTaxi:CreateTaxi()
            --Taxi:AddPathNode(1, 16230, 16400, -57)
            --Taxi:AddPathNode(1, 16226, 16406, -54)
            --Taxi:AddPathNode(1, 16222, 16399, -50)
            --Taxi:AddPathNode(1, 16226, 16395, -44)
            --Taxi:AddPathNode(1, 16231, 16399, -39)
            --Taxi:AddPathNode(1, 16226, 16403, -32)
            --Taxi:AddPathNode(1, 16222, 16403, -32)
            --Taxi:AddPathNode(1, 16226, 16403, -32)
            --Taxi:AddPathNode(1, 16228, 16391, -32)
            --Taxi:AddPathNode(1, 16236, 16392, -32)
            --Taxi:AddPathNode(1, 16236, 16413, -32)
            --Taxi:AddPathNode(1, 16214, 16414, -33)
            --plr:StartTaxi(Taxi, 17675)
            --end
        else
            if (intid == 2) then
                Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
            end
        end
            
    RegisterServerHook(16, "flight_path_Johnny_McWeaksauce")
    RegisterUnitEvent(16999, 18, "Johnny_McWeaksauce_Greeting")
    RegisterUnitGossipEvent(16999, 1, "Johhny_McWeaksauce_OnGossip")
    RegisterUnitGossipEvent(16999, 2, "Johhny_McWeaksauce_OnSubMenu")
    [/SPOILER]Edit number 2: So, after rewriting the code, I went and delete the talking for the time being. I was able to get the menu to work, as well as the teleport, I just need to figure out how to get the if command within the submenu function to reference the taxi function.

    Also, for some reason, ANY message causes a flight... >.<

    [SPOILER]
    Code:
    function Johnny_McWeaksauce_Flight_Path(event, plr, message, type, language)
        local Taxi = LuaTaxi:CreateTaxi()
        Taxi:AddPathNode(1, 16230, 16400, -57)
        Taxi:AddPathNode(1, 16226, 16406, -54)
        Taxi:AddPathNode(1, 16222, 16399, -50)
        Taxi:AddPathNode(1, 16226, 16395, -44)
        Taxi:AddPathNode(1, 16231, 16399, -39)
        Taxi:AddPathNode(1, 16226, 16403, -32)
        Taxi:AddPathNode(1, 16222, 16403, -32)
        Taxi:AddPathNode(1, 16226, 16403, -32)
        Taxi:AddPathNode(1, 16228, 16391, -32)
        Taxi:AddPathNode(1, 16236, 16392, -32)
        Taxi:AddPathNode(1, 16236, 16413, -32)
        Taxi:AddPathNode(1, 16214, 16414, -33)
        plr:StartTaxi(Taxi, 17675)
        end
    
    
    function Johnny_McWeaksauce_OnGossip(Unit, Event, Player)
        Unit:GossipCreateMenu(100, Player, 0)
        Unit:GossipMenuAddItem(0, "Fly to the Aviary", 1, 0)
        Unit:GossipMenuAddItem(0, "Go to the Surface", 2, 0)
        Unit:GossipSendMenu(Player)
    end
    
    function Johnny_McWeaksauce_OnSubMenu(Unit, Event, Player, id, intid, code)
        if (intid == 1) then
            
            end
            
        if (intid == 2) then
            Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
            end
    end
    
    RegisterServerHook(16, "Johnny_McWeaksauce_Flight_Path")
    RegisterUnitGossipEvent(16999, 1, "Johnny_McWeaksauce_OnGossip")
    RegisterUnitGossipEvent(16999, 2, "Johnny_McWeaksauce_OnSubMenu")
    [/SPOILER]Edit #3: Got it working.
    [SPOILER]
    Code:
    function Johnny_McWeaksauce_OnGossip(Unit, Event, Player)
        Unit:GossipCreateMenu(100, Player, 0)
        Unit:GossipMenuAddItem(0, "Fly to the Aviary", 1, 0)
        Unit:GossipMenuAddItem(0, "Go to the Surface", 2, 0)
        Unit:GossipSendMenu(Player)
    end
    
    function Johnny_McWeaksauce_OnSubMenu(Unit, Event, Player, id, intid, code)
        if (intid == 1) then  
            local Taxi = LuaTaxi:CreateTaxi()
            Taxi:AddPathNode(1, 16230, 16400, -57)
            Taxi:AddPathNode(1, 16226, 16406, -54)
            Taxi:AddPathNode(1, 16222, 16399, -50)
            Taxi:AddPathNode(1, 16226, 16395, -44)
            Taxi:AddPathNode(1, 16231, 16399, -39)
            Taxi:AddPathNode(1, 16226, 16403, -32)
            Taxi:AddPathNode(1, 16222, 16403, -32)
            Taxi:AddPathNode(1, 16226, 16403, -32)
            Taxi:AddPathNode(1, 16228, 16391, -32)
            Taxi:AddPathNode(1, 16236, 16392, -32)
            Taxi:AddPathNode(1, 16236, 16413, -32)
            Taxi:AddPathNode(1, 16214, 16414, -33)
            Player:StartTaxi(Taxi, 17675)
            end
            
        if (intid == 2) then
            Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
            end
    end
    
    RegisterUnitGossipEvent(16999, 1, "Johnny_McWeaksauce_OnGossip")
    RegisterUnitGossipEvent(16999, 2, "Johnny_McWeaksauce_OnSubMenu")
    [/SPOILER]Now to find a way to allow my other NPC to take a code to activate the teleport.
    [SPOILER]
    Code:
    function Murloc_OnGossip(Unit, Event, Player)
        Unit:GossipCreateMenu(100, Player, 0)
        Unit:GossipMenuAddItem(0, "Yes I know the secret code", 1, 1)
        Unit:GossipSendMenu(Player)
        end
        
    function Murloc_OnSubMenu(Unit, Event, Player, id, intid, code)
        if (intid == 1) then
            Player:Teleport (1, 16240.183594, 16394.423828, -64.379303)
            end
    end
    
    RegisterUnitGossipEvent(21190, 1, "Murloc_OnGossip")
    RegisterUnitGossipEvent(21190, 2, "Murloc_OnSubMenu")
    [/SPOILER]

    Edit #4: I finally got both scripts working. I figure i'll post them here for anyone else looking to do something similar, and eventually release it with what its designed for. Text in red is designed to be changed.

    Aviary/To the Surface NPC
    [SPOILER]
    Code:
    function Johnny_McWeaksauce_OnGossip(Unit, Event, Player)
    	Unit:GossipCreateMenu(100, Player, 0)
    	Unit:GossipMenuAddItem(0, "Fly to the Aviary", 1, 0)
    	Unit:GossipMenuAddItem(0, "Go to the Surface", 2, 0)
    	Unit:GossipSendMenu(Player)
    end
    
    function Johnny_McWeaksauce_OnSubMenu(Unit, Event, Player, id, intid, code)
    	if (intid == 1) then  
    		local Taxi = LuaTaxi:CreateTaxi()
    		Taxi:AddPathNode(1, 16230, 16400, -57)
    		Taxi:AddPathNode(1, 16226, 16406, -54)
    		Taxi:AddPathNode(1, 16222, 16399, -50)
    		Taxi:AddPathNode(1, 16226, 16395, -44)
    		Taxi:AddPathNode(1, 16231, 16399, -39)
    		Taxi:AddPathNode(1, 16226, 16403, -32)
    		Taxi:AddPathNode(1, 16222, 16403, -32)
    		Taxi:AddPathNode(1, 16226, 16403, -32)
    		Taxi:AddPathNode(1, 16228, 16391, -32)
    		Taxi:AddPathNode(1, 16236, 16392, -32)
    		Taxi:AddPathNode(1, 16236, 16413, -32)
    		Taxi:AddPathNode(1, 16214, 16414, -33)
    		Player:StartTaxi(Taxi, 17675)
    		end
    		
    	if (intid == 2) then
    		Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
    		end
    end
    
    RegisterUnitGossipEvent(16999, 1, "Johnny_McWeaksauce_OnGossip")
    RegisterUnitGossipEvent(16999, 2, "Johnny_McWeaksauce_OnSubMenu")
    [/SPOILER]

    Code NPC
    [SPOILER]
    Code:
    function Murloc_OnGossip(Unit, Event, Player)
    	Unit:GossipCreateMenu(20001, Player, 0)
    	Unit:GossipMenuAddItem(0, "I know this knowledge", 1, 1)
    	Unit:GossipSendMenu(Player)
    	end
    	
    function Murloc_OnSubMenu(Unit, Event, Player, id, intid, code)
    	if (intid == 1) and (code == "Password") then
    		Player:Teleport (1, 16240.183594, 16394.423828, -64.379303)
    		end
    end
    
    RegisterUnitGossipEvent(15186, 1, "Murloc_OnGossip")
    RegisterUnitGossipEvent(15186, 2, "Murloc_OnSubMenu")
    [/SPOILER]
    Last edited by riizu; 07-12-2010 at 03:46 PM. Reason: Updated

    Need some help with my lua script
  2. #2
    I Hypnotoad I's Avatar Contributor
    Reputation
    147
    Join Date
    Aug 2007
    Posts
    873
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not lua expert but this may be your problem

    local Players = GetInRangePlayers()



    function Johnny_McWeaksauce_Greeting(Unit, Event)
    If plr:IsGm() == true then
    Unit:SendChatMessage(14, 0, "Hello GM" Players)
    else
    Unit:SendChatMessage(14, 0, "Hello" Players)
    end
    end



    function Johhny_McWeaksauce_OnGossip(Unit, Event, Player)
    Unit:GossipCreateMenu(100, Player, 0)
    Unit:GossipMenuAddItem(0, "Fly to the Aviary", 1, 0)
    Unit:GossipMenuAddItem(0, "Go to the Surface", 2, 0)
    Unit:GossipSendMenu(Player)
    end

    function Johhny_McWeaksauce_OnSubMenu(Unit, Event, Player, id, intid, code)
    if (intid == 1) then
    --function flight_path_JohhnyMcWeaksauce(event, plr, message, type, language)
    --local Taxi = LuaTaxi:CreateTaxi()
    --Taxi:AddPathNode(1, 16230, 16400, -57)
    --Taxi:AddPathNode(1, 16226, 16406, -54)
    --Taxi:AddPathNode(1, 16222, 16399, -50)
    --Taxi:AddPathNode(1, 16226, 16395, -44)
    --Taxi:AddPathNode(1, 16231, 16399, -39)
    --Taxi:AddPathNode(1, 16226, 16403, -32)
    --Taxi:AddPathNode(1, 16222, 16403, -32)
    --Taxi:AddPathNode(1, 16226, 16403, -32)
    --Taxi:AddPathNode(1, 16228, 16391, -32)
    --Taxi:AddPathNode(1, 16236, 16392, -32)
    --Taxi:AddPathNode(1, 16236, 16413, -32)
    --Taxi:AddPathNode(1, 16214, 16414, -33)
    --plr:StartTaxi(Taxi, 17675)
    --end
    else
    if (intid == 2) then
    Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
    end
    end

    RegisterServerHook(16, "flight_path_Johnny_McWeaksauce")
    RegisterUnitEvent(16999, 18, "Johnny_McWeaksauce_Greeting")
    RegisterUnitGossipEvent(16999, 1, "Johhny_McWeaksauce_OnGossip")
    RegisterUnitGossipEvent(16999, 2, "Johhny_McWeaksauce_OnSubMenu")


    Also, is this a script that makes players fly there, but GMs teleport?
    If so, I don't think you defined the 'GMs' on this V
    else
    if (intid == 2) then
    Player:Teleport(1, 16222.599609, 16265.900391, 13.208697)
    end
    end


    Last edited by I Hypnotoad I; 07-11-2010 at 07:50 PM.


    Dragon[Sky] can get into our signatures, AND our pants.



  3. #3
    riizu's Avatar Active Member
    Reputation
    16
    Join Date
    Oct 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All the dashes actually comment out that code. In my debugging attempts, I tried removing that entire option, but the chosen NPC (who is flagged at 35) lacks any gossip script options.

    As for the bit about flying/teleporting. The flight nodes are for a flight path, which I had working in a seperate script using that, and when you type "#taxi" you activate the script. I want to incorporate that into this script with a Gossip Script option.

    The teleport is a seperate option in the gossip script.
    Last edited by riizu; 07-11-2010 at 07:58 PM.

  4. #4
    Rock Lee's Avatar Banned
    Reputation
    41
    Join Date
    Jul 2010
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you make a quick summary on what doesnt work on a specific work aswell as what you want added.

  5. #5
    riizu's Avatar Active Member
    Reputation
    16
    Join Date
    Oct 2007
    Posts
    263
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out mate. The only thing I still need to do is work out how to script the npc to send out a greeting based on whether or not a player is in range and then edit to change the greeting based on whether or not the player is a GM.

Similar Threads

  1. Need some help with unlocked LUA scripting (UnitBuff)
    By ownedpandas in forum WoW UI, Macros and Talent Specs
    Replies: 0
    Last Post: 10-13-2016, 10:55 AM
  2. Need some help with LUA script
    By SupernovaHH in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 07-22-2009, 07:25 AM
  3. Need help with an LUA script.
    By Ryoken in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 06-21-2009, 09:30 PM
  4. Need some help with Lua
    By Kiev in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 12-23-2008, 05:26 AM
  5. [Request] I need some help with lua script (boss on death)
    By Ellenor in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 03-03-2008, 03:47 PM
All times are GMT -5. The time now is 11:48 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search