Need A Bit of Lua Help menu

User Tag List

Results 1 to 7 of 7
  1. #1
    Dr. Livingstone's Avatar Member
    Reputation
    113
    Join Date
    Mar 2008
    Posts
    290
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need A Bit of Lua Help

    I feel a little odd asking for help here, but I just can't seem to get this teleporter to work... Its not my first teleporter either. I just can't find a problem in the script.

    Code:
    local npcid = 100000
    
    function On_Gossip(unit, event, player)
    	local race = player:GetPlayerRace()
    	if race==1 or race==3 or race==4 or race==7 or race==11 then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(0, "Alliance Cities", 1, 0)
    	unit:MenuAddItem(0, "Azeroth Instances", 2, 0)
    	unit:MenuAddItem(0, "Outland Instances", 3, 0)
    	unit:MenuAddItem(0, "Northrend Instances", 4, 0)
    	unit:MenuAddItem(0, "Gurubashi Arena", 6, 0)
    	unit:MenuSendToPlayer(player)
    	else 
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(0, "Horde Cities", 7, 0)
    	unit:MenuAddItem(0, "Azeroth Instances", 2, 0)
    	unit:MenuAddItem(0, "Outland Instances", 3, 0)
    	unit:MenuAddItem(0, "Northrend Instances", 4, 0)
    	unit:MenuAddItem(0, "Gurubashi Arena", 6, 0)
    	unit:MenuSendToPlayer(player)
    end
    end
    
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    	if(intid == 2) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(2, "Azeroth Raids", 101, 0)
    	unit:MenuAddItem(2, "Shadowfang Keep", 10, 0)
    	unit:MenuAddItem(2, "Scarlet Monestary", 11, 0)
    	unit:MenuAddItem(2, "Stratholme", 12, 0)
    	unit:MenuAddItem(2, "Scholomance", 13, 0)
    	unit:MenuAddItem(2, "Gnomeregan", 14, 0)
    	unit:MenuAddItem(2, "Uldaman", 15, 0)
    	unit:MenuAddItem(2, "Sunken Temple", 16, 0)
    	unit:MenuAddItem(2, "Blackrock Spire", 17, 0)
    	unit:MenuAddItem(2, "Deadmines", 21, 0)
    	unit:MenuAddItem(2, "Zul'Farrak", 18, 0)
    	unit:MenuAddItem(2, "Wailing Caverns", 20, 0)
    	unit:MenuAddItem(2, "Blackfathom Depths", 22, 0)
    	unit:MenuAddItem(2, "Razorfen Downs", 23, 0)
    	unit:MenuAddItem(2, "Razorfen Kraul", 24, 0)
    	unit:MenuAddItem(2, "Maraudon", 25, 0)
    	unit:MenuAddItem(2, "Dire Maul", 26, 0)
    	unit:MenuSendToPlayer(player)
    end
    
    	if(intid == 4) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(4, "Utgarde Keep", 49)
    	unit:MenuAddItem(4, "The Nexus", 50)
    	unit:MenuAddItem(4, "Azjol-Nerub", 51)
    	unit:MenuAddItem(4, "Drak'Tharon Keep", 53)
    	unit:MenuAddItem(4, "Violet Hold", 54)
    	unit:MenuAddItem(4, "Gundrak", 55)
    	unit:MenuAddItem(4, "Halls of Stone", 56)
    	unit:MenuAddItem(4, "Utgarde Pinacle", 57)
    	unit:MenuAddItem(4, "Oculus", 58)
    	unit:MenuAddItem(4, "Halls of Lightning", 59)
    	unit:MenuAddItem(4, "Naxxramas", 60)
    	unit:MenuAddItem(4, "Obsidian Sanctum", 61)
    	unit:MenuAddItem(4, "Eye of Eternity", 62)
    	unit:MenuSendToPlayer(player)
    end
    
    	if(intid == 3) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(3, "Outland Raids", 102, 0)
    	unit:MenuAddItem(3, "Hellfire Citadel", 27, 0)
    	unit:MenuAddItem(3, "Coilfang Reservoir", 28, 0)
    	unit:MenuAddItem(3, "Auchindoun", 29, 0)
    	unit:MenuAddItem(3, "Caverns of Time", 30)
    	unit:MenuAddItem(3, "Tempest Keep", 31)
    	unit:MenuSendToPlayer(player)
    end
    	
    	if(intid == 7) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(4, "Ironforge", 32, 0)
        unit:MenuAddItem(4, "Stormwind", 33, 0)
        unit:MenuAddItem(4, "Darnassus", 34, 0)
        unit:MenuAddItem(4, "Exodar", 35, 0)
    	unit:GossipSendMenu(player)
    	end
    	
    	if(intid == 1) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(5, "Orgrimmar", 36, 0)
        unit:MenuAddItem(5, "Thunder Bluff", 37, 0)
        unit:MenuAddItem(5, "Undercity", 38, 0)
        unit:MenuAddItem(5, "Silvermoon", 39, 0)
        unit:GossipSendMenu(player)
        end
    
    	if(intid == 101) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(5, "Molten Core", 40)
    	unit:MenuAddItem(5, "Blackwing Lair", 41)
    	unit:MenuAddItem(5, "Ahn'Qiraji", 42)
    	unit:MenuAddItem(5, "Zul'Gurub", 43)
    	unit:GossipSendMenu(player)
    	end
    	
    	if(intid == 102) then
    	unit:GossipCreateMenu(3542, player, 0)
    	unit:MenuAddItem(5, "Gruul's Lair", 44)
    	unit:MenuAddItem(5, "Magtheridon's Lair", 45)
    	unit:MenuAddItem(5, "Serpentshrine Cavern", 46)
    	unit:MenuAddItem(5, "The Eye", 47)
    	unit:MenuAddItem(5, "Black Temple", 48)
    	unit:GossipSendMenu(player)
    	end
    	
    if(intid == 49) then
    player:Teleport(571, 1219.462891, -4864.646484, 1219.453)
    end
    
    if(intid == 50) then
    player:Teleport(571, 3892.810059, 6985.250000, 69.488)
    end
    
    if(intid == 51) then
    player:Teleport(571, 3672.219971, 2171.280029, 35.941)
    end
    
    if(intid == 53) then
    player:Teleport(571, 4774.504395, -2034.122192, 229.383255)
    end
    
    if(intid == 54) then
    player:Teleport(571, 5680.942871, 488.491882, 652.441772)
    end
    
    if(intid == 55) then
    player:Teleport(571, 6933.438965, -4435.000488, 450.5183)
    end
    
    if(intid == 56) then
    player:Teleport(571, 8920.916992, -987.454834, 1039.3595)
    end
    
    if(intid == 57) then
    player:Teleport(571, 1251.349976, -4854.939941, 215.6921)
    end
    
    if(intid == 58) then
    player:Teleport(602, 1333.760010, 236.863007, 52.50471)
    end
    
    if(intid == 59) then
    player:Teleport(571, 3666.10887, -1265.906372, 243.513428)
    end
    
    if(intid == 60) then
    player:Teleport(571, 3557.592285, 272.407715, -115.965)
    end
    
    if(intid == 62) then
    player:Teleport(571, 3858.724121, 6990.097168, 152.059)
    end
    	
    if(intid == 44) then
    player:Teleport(530, 3541.178467, 5092.121094, 3.8)
    end
    
    if(intid == 45) then
    player:Teleport(530, -317.202118, 3092.593994, -116.424)
    end
    
    if(intid == 46) then
    player:Teleport(530, 733.699768, 6881.137695, -66.6122)
    end
    
    if(intid == 47) then
    player:Teleport(530, 3088.664795, 1380.524414, 184.885)
    end
    
    if(intid == 48) then
    player:Teleport(530, -3561.310547, 332.191040, 36.171)
    end
    	
    if(intid == 40) then
    player:Teleport(0, -7511.14, -1041.903, 180.913)
    end
    
    if(intid == 41) then
    player:Teleport(0, -7660.1382, -1220.3395, 287.7882)
    end
    
    if(intid == 42) then
    player:Teleport(1, -8181.294, 1530.592651, 4.195)
    end
    
    if(intid == 43) then
    player:Teleport(0, -11916.222656, -1208.617676, 92.2878)
    end
    	
    if(intid == 6) then
    player:Teleport(1, 1498.845215, -4414.937988, 22.203)
    end
    
    if(intid == 7) then
    player:Teleport(1, 1530.256592, 210.98, -43.1)
    end
    
    if(intid == 8) then
    player:Teleport(0, -1284.997437, 179.616898, 129)
    end
    
    if(intid == 9) then
    player:Teleport(0, 9459.475586, -7280.01, 14.23)
    end
    
    if(intid == 10) then
    player:Teleport(0, -246.061758, 1533.107544, 77.09)
    end
    
    if(intid == 11) then
    player:Teleport(0, 2892.173584, -811.338379, 160.34)
    end
    
    if(intid == 12) then
    player:Teleport(0, 3354.986084, -3379.198486, 144.7871937)
    end
    
    if(intid == 13) then
    player:Teleport(0, 1243.319825, -2591.356201, 90.192810)
    end
    
    if(intid == 14) then
    player:Teleport(0, -5182.606934, 617.909424, 405.46)
    end
    
    if(intid == 15) then
    player:Teleport(0, -6070.064941, -2955.942627, 209.78)
    end
    
    if(intid == 16) then
    player:Teleport(0, -10451.191406, -3822.810303, 18.07)
    end
    
    if(intid == 17) then
    player:Teleport(0, -7495.056129, -1116.887695, 265.74)
    end
    
    if(intid == 18) then
    player:Teleport(1, -6804.0342, -2890.755, 8.862)
    end
    
    if(intid == 20) then
    player:Teleport(1, -739.523, -2216.3104, 16.3803)
    end
    
    if(intid == 21) then
    player:Teleport(0, -11209.875000, 1669.595093, 24.933108)
    end
    
    if(intid == 22) then
    player:Teleport(1, 4139.332031, 891.448730, -18.947780)
    end
    
    if(intid == 23) then
    player:Teleport(1, -4653.043945, -2501.171143, 81.194329)
    end
    
    if(intid == 24) then
    player:Teleport(1, -4464.919922, -1666.239990, 81.892128)
    end
    
    if(intid == 25) then
    player:Teleport(349, 752.909973, -616.530029, -33.110001)
    end
    
    if(intid == 26) then
    player:Teleport(1, -3752.292725, 1044.019287, 162.183167)
    end
    
    if(intid == 1) then
    player:Teleport(37, 107.608002, 1014.510010, 296.203003)
    end
    
    if(intid == 27) then
    player:Teleport(530, -275.470123, 3111.767334, 31.456154)
    end
    
    if(intid == 28) then
    player:Teleport(530, 741.431335, 6866.434082, -69.119469)
    end
    
    if(intid == 29) then
    player:Teleport(530, -3336.829102, 4933.846191, -100.439507)
    end
    
    if(intid == 30) then
    player:Teleport(1, -8480.312500, -4308.177246, -208.442169)
    end
    
    if(intid == 31) then
    player:Teleport(530, 3098.636475, 1515.429565, 190.300446)
    end
    
    if(intid == 6) then
    player:Teleport(0, -13264.169922, 151.133057, 35.005310)
    end
    
    if(intid == 32) then
    player:Teleport(0, -4981.250000, -881.541992, 501.659729)
    end
    
    	
    if(intid == 33) then
    player:Teleport(0, -8913.230469, 554.632996, 93.794456)
    end
    	
    if(intid == 34) then
    player:Teleport(0, 9945.129883, 2616.889893, 1316.459961)
    end
    	
    if(intid == 35) then
    player:Teleport(0, -3994.848633, -11862.791016, 0.269375)
    end
    
    if(intid == 36) then
    player:Teleport(1, 1502.709961, -4415.419922, 21.552349)
    end
        
    if(intid == 37) then
    player:Teleport(1, -1284.529419, 158.671707, 129.994247)
    end
        
    if(intid == 38) then
    player:Teleport(0, 1831.260010, 238.529999, 60.520733)
    end
        
    if(intid == 39) then
    player:Teleport(530, 9414.179688, -72578.970215, 14.203904)
    end
    end
    
    RegisterUnitGossipEvent(100000, 1, "On_Gossip")
    RegisterUnitGossipEvent(100000, 2, "Gossip_Submenus")
    When I start up the server it loads fine, but when I try to use the NPC the console says "scripts/teleporter.lua:15: attempt to call method 'MenuAddItem' a nil value" Any help would be much appreciated.

    Need A Bit of Lua Help
  2. #2
    Mildan's Avatar Member
    Reputation
    10
    Join Date
    Feb 2009
    Posts
    80
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe it is your if race thingy.

  3. #3
    Dr. Livingstone's Avatar Member
    Reputation
    113
    Join Date
    Mar 2008
    Posts
    290
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm... I've used it before though. I'll look into a different check though. Thanks +Rep

  4. #4
    Performer's Avatar Contributor
    Reputation
    212
    Join Date
    Nov 2007
    Posts
    874
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using faction instead of race. Havent done LUA in a long time, more on C++ now so i cant really help you much.


  5. #5
    Jotox's Avatar Contributor
    Reputation
    250
    Join Date
    Mar 2008
    Posts
    282
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    replace all "unit:MenuAddItem(..)" with "unit:GossipMenuAddItem(..)"

    That will fix it.

  6. #6
    Dr. Livingstone's Avatar Member
    Reputation
    113
    Join Date
    Mar 2008
    Posts
    290
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I get the same error just it says 'MenuSendToPlayer' instead of 'MenuAddItem'

  7. #7
    Mildan's Avatar Member
    Reputation
    10
    Join Date
    Feb 2009
    Posts
    80
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function On_Gossip(unit, event, player)
    	local race = player:GetPlayerRace()
    	if race==1 or race==3 or race==4 or race==7 or race==11 then
    	unit:GossipCreateMenu(3544, player, 0)
    	unit:MenuAddItem(0, "Alliance Cities", 1, 0)
    	unit:MenuAddItem(0, "Azeroth Instances", 2, 0)
    	unit:MenuAddItem(0, "Outland Instances", 3, 0)
    	unit:MenuAddItem(0, "Northrend Instances", 4, 0)
    	unit:MenuAddItem(0, "Gurubashi Arena", 6, 0)
    	unit:MenuSendToPlayer(player)
    	else 
    	unit:GossipCreateMenu(3544, player, 0)
    	unit:MenuAddItem(0, "Horde Cities", 7, 0)
    	unit:MenuAddItem(0, "Azeroth Instances", 2, 0)
    	unit:MenuAddItem(0, "Outland Instances", 3, 0)
    	unit:MenuAddItem(0, "Northrend Instances", 4, 0)
    	unit:MenuAddItem(0, "Gurubashi Arena", 6, 0)
    	unit:MenuSendToPlayer(player)
    end
    end
    
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    	if(intid == 2) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(2, "Azeroth Raids", 101, 0)
    	unit:MenuAddItem(2, "Shadowfang Keep", 10, 0)
    	unit:MenuAddItem(2, "Scarlet Monestary", 11, 0)
    	unit:MenuAddItem(2, "Stratholme", 12, 0)
    	unit:MenuAddItem(2, "Scholomance", 13, 0)
    	unit:MenuAddItem(2, "Gnomeregan", 14, 0)
    	unit:MenuAddItem(2, "Uldaman", 15, 0)
    	unit:MenuAddItem(2, "Sunken Temple", 16, 0)
    	unit:MenuAddItem(2, "Blackrock Spire", 17, 0)
    	unit:MenuAddItem(2, "Deadmines", 21, 0)
    	unit:MenuAddItem(2, "Zul'Farrak", 18, 0)
    	unit:MenuAddItem(2, "Wailing Caverns", 20, 0)
    	unit:MenuAddItem(2, "Blackfathom Depths", 22, 0)
    	unit:MenuAddItem(2, "Razorfen Downs", 23, 0)
    	unit:MenuAddItem(2, "Razorfen Kraul", 24, 0)
    	unit:MenuAddItem(2, "Maraudon", 25, 0)
    	unit:MenuAddItem(2, "Dire Maul", 26, 0)
    	unit:MenuSendToPlayer(player)
    end
    
    	if(intid == 4) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(4, "Utgarde Keep", 49)
    	unit:MenuAddItem(4, "The Nexus", 50)
    	unit:MenuAddItem(4, "Azjol-Nerub", 51)
    	unit:MenuAddItem(4, "Drak'Tharon Keep", 53)
    	unit:MenuAddItem(4, "Violet Hold", 54)
    	unit:MenuAddItem(4, "Gundrak", 55)
    	unit:MenuAddItem(4, "Halls of Stone", 56)
    	unit:MenuAddItem(4, "Utgarde Pinacle", 57)
    	unit:MenuAddItem(4, "Oculus", 58)
    	unit:MenuAddItem(4, "Halls of Lightning", 59)
    	unit:MenuAddItem(4, "Naxxramas", 60)
    	unit:MenuAddItem(4, "Obsidian Sanctum", 61)
    	unit:MenuAddItem(4, "Eye of Eternity", 62)
    	unit:MenuSendToPlayer(player)
    end
    
    	if(intid == 3) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(3, "Outland Raids", 102, 0)
    	unit:MenuAddItem(3, "Hellfire Citadel", 27, 0)
    	unit:MenuAddItem(3, "Coilfang Reservoir", 28, 0)
    	unit:MenuAddItem(3, "Auchindoun", 29, 0)
    	unit:MenuAddItem(3, "Caverns of Time", 30)
    	unit:MenuAddItem(3, "Tempest Keep", 31)
    	unit:MenuSendToPlayer(player)
    end
    	
    	if(intid == 7) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(4, "Ironforge", 32, 0)
        unit:MenuAddItem(4, "Stormwind", 33, 0)
        unit:MenuAddItem(4, "Darnassus", 34, 0)
        unit:MenuAddItem(4, "Exodar", 35, 0)
    	unit:GossipSendMenu(player)
    	end
    	
    	if(intid == 1) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(5, "Orgrimmar", 36, 0)
        unit:MenuAddItem(5, "Thunder Bluff", 37, 0)
        unit:MenuAddItem(5, "Undercity", 38, 0)
        unit:MenuAddItem(5, "Silvermoon", 39, 0)
        unit:GossipSendMenu(player)
        end
    
    	if(intid == 101) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(5, "Molten Core", 40)
    	unit:MenuAddItem(5, "Blackwing Lair", 41)
    	unit:MenuAddItem(5, "Ahn'Qiraji", 42)
    	unit:MenuAddItem(5, "Zul'Gurub", 43)
    	unit:GossipSendMenu(player)
    	end
    	
    	if(intid == 102) then
    	unit:GossipCreateMenu(3543, player, 0)
    	unit:MenuAddItem(5, "Gruul's Lair", 44)
    	unit:MenuAddItem(5, "Magtheridon's Lair", 45)
    	unit:MenuAddItem(5, "Serpentshrine Cavern", 46)
    	unit:MenuAddItem(5, "The Eye", 47)
    	unit:MenuAddItem(5, "Black Temple", 48)
    	unit:GossipSendMenu(player)
    	end
    Try this instead.

Similar Threads

  1. [Help] Need LUA help? Post here!
    By EcHoEs in forum World of Warcraft Emulator Servers
    Replies: 20
    Last Post: 10-03-2010, 01:18 PM
  2. [Help] my first lua need quite bit of help
    By jordddm in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 03-22-2009, 11:10 AM
  3. A little bit of lua help.
    By skrubz in forum Programming
    Replies: 3
    Last Post: 12-16-2008, 09:59 PM
  4. Need a bit help here please :)
    By Spurven in forum World of Warcraft General
    Replies: 2
    Last Post: 01-28-2008, 04:29 PM
  5. Need a bit of help...
    By Rhynix in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 12-12-2007, 08:54 PM
All times are GMT -5. The time now is 01:44 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search