Missing Skill NPC (Lua) menu

Shout-Out

User Tag List

Results 1 to 8 of 8
  1. #1
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Missing Skill NPC (Lua)

    I just want someone to read Syntax on it, since I

    feel I've made something wrong, but it executes just fine in the

    Console =/

    The problem is that I can't make "GetPlayerClass()" work. And no

    it's not "GetClass()".


    NOTE:
    Please do not leach off this script...I got

    the original one, so if you ever release it as your own, I will

    know :3
    Thank you! ^^


    Code:
    local MSkillNPC = 4 -- Actual Entry goes here
    local plr
    
    
    function OnSpawn_Define(pUnit,event)
    	MSN = pUnit -- MSN = Missing Skill NPC
    end
    
    RegisterUnitEvent(MSkillNPC,18,"OnSpawn_Define")
    
    function MSN_Gossip(pUnit, event, player)
    	MSN:GossipCreateMenu(10, player, 0)
    		MSN:GossipMenuAddItem(0, "Welcome to *******'s 
    
    Missing Skill NPC V 4.6 made by AngelSandy", 1, 0)
    		MSN:GossipMenuAddItem(0, "Please pick your Class 
    
    and/or Race below, should you miss any skills.", 2, 0)
    		MSN:GossipMenuAddItem(3, "Hunter", 3, 0)
    		MSN:GossipMenuAddItem(3, "Warrior", 4, 0)
    		MSN:GossipMenuAddItem(3, "Warlock", 5, 0)
    		MSN:GossipMenuAddItem(3, "Mage", 6, 0)
    		MSN:GossipMenuAddItem(3, "Paladin", 7, 0)
    		MSN:GossipMenuAddItem(3, "Rogue", 8, 0)
    		MSN:GossipMenuAddItem(3, "Priest", 9, 0)
    		MSN:GossipMenuAddItem(3, "Druid", 10, 0)
    		MSN:GossipMenuAddItem(3, "Death Knight", 11, 0)
    		MSN:GossipMenuAddItem(3, "Shaman", 12,0)
    	MSN:GossipSendMenu(player)
    end
    
    function MSN_Select(pUnit, event, player, id, intid, Code)
    plr = player:GetClosestPlayer()
    
    if(intid == 3) and player:GetPlayerClass() == 3 then -- Hunter
    		plr:LearnSpell(1515) -- Tame Beast
    		plr:LearnSpell(6991) -- Feed Pet
    		plr:LearnSpell(2641) -- Dismiss Pet
    		plr:LearnSpell(883) -- Call Pet
    		plr:LearnSpell(928) -- Revive Pet
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Hunter.")
    end
    
    if(intid == 4) and player:GetPlayerClass() == 4 then -- Warrior
    		plr:LearnSpell(71) -- Defensive Stance
    		plr:LearnSpell(7386) -- Sunder Armor
    		plr:LearnSpell(355) -- Taunt
    		plr:LearnSpell(2458) -- Berserker Stance
    		plr:LearnSpell(2457) -- Battle Stance
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Warrior")
    end
    
    if(intid == 5) and player:GetPlayerClass() == 5 then -- Warlock
    		plr:LearnSpell(688) -- Imp
    		plr:LearnSpell(697) -- Voidwalker
    		plr:LearnSpell(712) -- Succubus
    		plr:LearnSpell(691) -- Felhunter
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Warlock")
    end
    
    if(intid == 6) and player:GetPlayerClass() == 6 then -- Mage
    		plr:LearnSpell(28272) -- Polymorph (Pig)
    		plr:LearnSpell(53140) -- Teleport: Dalaran
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Mage")
    end
    
    
    if(intid == 7) then and player:GetPlayerClass() == 7 -- Paladin
    		plr:LearnSpell(7328) -- Redemption Rank 1
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Paladin")
    end
    
    if(intid == 8) and player:GetPlayerClass() == 8 then -- Rogue
    		MSN:SendChatMessage(14, 0, "A Rogue you say? I 
    
    don't have anything to teach you. Already know it all!")
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Rogue")
    end
    
    if(intid == 9) and player:GetPlayerClass() == 9 then -- Priest
    		MSN:SendChatMessage(14, 0, "A Rogue you say? I 
    
    don't have anything to teach you. Already know it all!")
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Priest")
    end
    
    if(intid == 10) and player:GetPlayerClass() == 10 then -- Druid
    		plr:LearnSpell(5487) -- Bearform
    		plr:LearnSpell(6795) -- Growl
    		plr:LearnSpell(6807) -- Maul
    		plr:LearnSpell(1066) -- Aquatic Form
    		plr:LearnSpell(8946) -- Cure Poison
    		plr:LearnSpell(40120) -- Swift Flight Form
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Druid")
    end
    
    if(intid == 11) and player:GetPlayerClass() == 11 then -- Death 
    
    Knight
    		plr:LearnSpell(48778) -- Archerus Deathcharger
    		plr:LearnSpell(50977) -- Death Gate
    		plr:LearnSpell(53428) -- Runeforging
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Death Knight")
    end
    
    if(intid == 12) and player:GetPlayerClass() == 12 then -- Shaman
    		plr:LearnSpell(3599) -- Searing Totem
    		plr:LearnSpell(5394) -- Healing Stream Totem
    		plr:LearnSpell(8071) -- Stoneskin Totem
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Shaman")
    end
    end
    
    RegisterUnitGossipEvent(MSkillNPC, 1, "MSN_Gossip") 
    RegisterUnitGossipEvent(MSkillNPC, 2, "MSN_Select")

    Here it is <_<
    Last edited by AngelSandy; 08-13-2009 at 08:46 AM.

    Missing Skill NPC (Lua)
  2. #2
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GetPlayerClass() returns a string.
    If the player's class is '1', it will return "Warrior".
    So basically:
    Code:
    if(intid == 3) and player:GetPlayerClass() == "Hunter" then -- Hunter
    This is the coding behind GetPlayerClass()
    Code:
    int plrclass = RAW_TO_PLAYER(ptr)->getClass();
    
       switch(plrclass) {
          case 1:
             lua_pushstring(L, "Warrior");
             break;
          case 2:
             lua_pushstring(L, "Paladin");
             break;
          case 3:
             lua_pushstring(L, "Hunter");
             break;
          case 4:
             lua_pushstring(L, "Rogue");
             break;
          case 5:
             lua_pushstring(L, "Priest");
             break;
          //case 6:
          case 7:
             lua_pushstring(L, "Shaman");
             break;
          case 8:
             lua_pushstring(L, "Mage");
             break;
          case 9:
             lua_pushstring(L, "Warlock");
             break;
          //case 10:
          case 11:
             lua_pushstring(L, "Druid");
             break;
          default:
             lua_pushstring(L, "Unknown");
             break;
       }

  3. #3
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to work with numbers it's easy to write a convert function which return a class' value as a number.
    Code:
    function Converter(Class)
    if Class == "Warrior" then
      return 1
    elseif Class == "Paladin" then
      return 2
    
    etc.
    
    end
    end
    This mean you can use Converter(player:GetPlayerClass()) == 1. However, it's actually much easier to just work with the string, so I wouldn't recommend using the method I described above.

    EDIT: I just had an actual look at the script. Why don't you use the class check before the options appear? Means people can't "accidently" click the wrong class.
    Last edited by Dynashock; 08-13-2009 at 09:58 AM.

  4. #4
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't think of the option at the time I made it really.

    I guess it could be an option, but I just wanted to make a simple Menu setup and stuff. Something you can help me with?
    My brain usually starts to hurt after a longer fight with my good friend LuaGossip x_x

  5. #5
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function MSN_Select(pUnit, event, player, id, intid, Code)
    plr = player:GetClosestPlayer()
    
    if(intid == 3) and player:GetPlayerClass() == "Hunter" then -- Hunter
    		plr:LearnSpell(1515) -- Tame Beast
    		plr:LearnSpell(6991) -- Feed Pet
    		plr:LearnSpell(2641) -- Dismiss Pet
    		plr:LearnSpell(883) -- Call Pet
    		plr:LearnSpell(928) -- Revive Pet
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Hunter.")
    end
    
    if(intid == 4) and player:GetPlayerClass() == "Warrior" then -- Warrior
    		plr:LearnSpell(71) -- Defensive Stance
    		plr:LearnSpell(7386) -- Sunder Armor
    		plr:LearnSpell(355) -- Taunt
    		plr:LearnSpell(2458) -- Berserker Stance
    		plr:LearnSpell(2457) -- Battle Stance
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Warrior")
    end
    
    if(intid == 5) and player:GetPlayerClass() == "Warlock" then -- Warlock
    		plr:LearnSpell(688) -- Imp
    		plr:LearnSpell(697) -- Voidwalker
    		plr:LearnSpell(712) -- Succubus
    		plr:LearnSpell(691) -- Felhunter
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Warlock")
    end
    
    if(intid == 6) and player:GetPlayerClass() == "Mage" then -- Mage
    		plr:LearnSpell(28272) -- Polymorph (Pig)
    		plr:LearnSpell(53140) -- Teleport: Dalaran
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Mage")
    end
    
    
    if(intid == 7) then and player:GetPlayerClass() == "Paladin" -- Paladin
    		plr:LearnSpell(7328) -- Redemption Rank 1
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Paladin")
    end
    
    if(intid == 8) and player:GetPlayerClass() == "Rogue" then -- Rogue
    		MSN:SendChatMessage(14, 0, "A Rogue you say? I 
    
    don't have anything to teach you. Already know it all!")
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Rogue")
    end
    
    if(intid == 9) and player:GetPlayerClass() == "Priest" then -- Priest
    		MSN:SendChatMessage(14, 0, "A Rogue you say? I 
    
    don't have anything to teach you. Already know it all!")
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Priest")
    end
    
    if(intid == 10) and player:GetPlayerClass() == "Druid" then		plr:LearnSpell(5487) -- Bearform
    		plr:LearnSpell(6795) -- Growl
    		plr:LearnSpell(6807) -- Maul
    		plr:LearnSpell(1066) -- Aquatic Form
    		plr:LearnSpell(8946) -- Cure Poison
    		plr:LearnSpell(40120) -- Swift Flight Form
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Druid")
    end
    
    if(intid == 11) and player:GetPlayerClass() == "Unknown" then -- Death 
    
    Knight
    		plr:LearnSpell(48778) -- Archerus Deathcharger
    		plr:LearnSpell(50977) -- Death Gate
    		plr:LearnSpell(53428) -- Runeforging
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Death Knight")
    end
    
    if(intid == 12) and player:GetPlayerClass() == "Shaman" then -- Shaman
    		plr:LearnSpell(3599) -- Searing Totem
    		plr:LearnSpell(5394) -- Healing Stream Totem
    		plr:LearnSpell(8071) -- Stoneskin Totem
    	plr:GossipComplete()
    else
    player:SendAreaTriggerMessage("Your are not a Shaman")
    end
    end

  6. #6
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    w00t thanks.

    +Rep for youz :b

    Question tho:
    Why did you add an "Unknown"? Is that because the core can't detect Death Knights properly or?
    Last edited by AngelSandy; 08-14-2009 at 09:57 AM.

  7. #7
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nah, the lua engine just never added support for it. I'd update guaengine but im lazy.

  8. #8
    Sounddead's Avatar Contributor
    Reputation
    160
    Join Date
    Sep 2007
    Posts
    1,126
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GP is lazy. But to fix it, you have to go into LuaEngine.cpp and search for:
    int luaUnit_GetPlayerClass(lua_State * L, Unit * ptr)
    Once you in the GetPlayerClass function, look down to case 6. It is commented out, so un comment it, or replace it with:
    case 6:
    lua_pushstring(L, "DeathKnight");
    break;

    I live in a shoe

Similar Threads

  1. Lua Skill Npc
    By shadowslayer133 in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 04-03-2009, 04:15 PM
  2. [Release] Skill Npc 2.0
    By Sylex in forum World of Warcraft Emulator Servers
    Replies: 30
    Last Post: 06-02-2008, 05:02 PM
  3. [Release] Skill Npc 3.0
    By Sylex in forum World of Warcraft Emulator Servers
    Replies: 21
    Last Post: 04-10-2008, 09:51 AM
  4. [Release] Skill Npc - Revived
    By Sylex in forum World of Warcraft Emulator Servers
    Replies: 38
    Last Post: 02-29-2008, 02:31 PM
  5. [Release] Chirspee's Teleporting NPC, Buff NPC's, Skill NPC and Heal NPC
    By Illidan1 in forum World of Warcraft Emulator Servers
    Replies: 13
    Last Post: 11-22-2007, 04:05 PM
All times are GMT -5. The time now is 10:33 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