NPC refrence error menu

User Tag List

Results 1 to 11 of 11
  1. #1
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NPC refrence error

    Hey,

    I've gotten everything working up to a point where you spawn in Morgan's Plot and begin falling, I have also spawned the NPC I'm using and found a spell to use. For some reason it keeps telling me that "Tyrande" is a nil value or other such errors, I've changed the script quite a few times but nothing I try seems to be working. If someone can take a look at the script and tell me what's wrong that will help ^.^

    Code:
    local NAME = "Tyrande"
    local NPCID = 7999
    
    function x_OnNewCharFirstEnterWorld(pUnit, event, pName, pRace, pClass, pPlayer)
    	local pUnit = Tyrande
    	local pPlayer = :GetClosestPlayer()
    	pPlayer:MoveTo(0, -11109.724609, -1797.242432, 20.312950, 2.185450)
    	Tyrande:ChannelSpell(47855, Unit:GetClosestPlayer()) -- Drain Soul
    end
    	
    RegisterServerHook(3, "x_OnNewCharFirstEnterWorld")
    Basically you spawn falling down a well then the teleport moves you a little bit so you face Tyrande (the npc) but of course the O direction isn't working, then it gets Tyrande to target the falling player (closest unit because I couldn't figure out any other way to do it.) and after I get the first part working it will make the player slowly fall to the ground while Tyrande is channeling the spell then she will stop channeling the spell.

    NPC refrence error
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Tyrande is not defined anywhere.

    NPCID is not used.
    NAME is not used.

    local pUnit and pPlayer you try to redefine, why?!?

    Something like this:

    Code:
    local NPCID = 7999
    
    function x_OnNewCharFirstEnterWorld(pUnit, event, pName, pRace, pClass, pPlayer)
    	pPlayer:MoveTo(0, -11109.724609, -1797.242432, 20.312950, 2.185450)
    	Tyrande:ChannelSpell(47855, pPlayer) -- Drain Soul
    end
    	
    RegisterServerHook(3, "x_OnNewCharFirstEnterWorld")
    
    function On_Spawn_Defined_Tyrande(pUnit, Event)
    	Tyrande = pUnit
    end
    
    RegisterUnitEvent(NPCID, 18, "On_Spawn_Defined_Tyrande")
    Do not create multiple threads for questions, just put them all in the same thread.

  3. #3
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I'm just going to say that I thought NPCID,NAME,pUnit,pPlayer could be combined in a weird way to refrence different npc's in the same script (I forgot lot about Lua when I stopped scripting for awhile =/).
    Thanks for the fix and I'll just keep using this thread f I get anymore errors.

    ---------- Post added at 01:10 PM ---------- Previous post was at 01:03 PM ----------

    I just imported the updated script and tested it, the script errors out on line 4 because pPlayer is a nil value.
    (That's why I used the line "local pPlayer = :GetClosestPlayer()" in the origional script)

  4. #4
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Well to be honest, the errors you were making had nothing to do with Lua, the same basic logic rules apply to pretty much all programming languages.

    edit:

    Look at:
    SERVER_HOOK_FIRST_ENTER_WORLD = 3 --(event, pPlayer)

    The parameters do not have all the stuff you included, that is why.

    http://www.arcemu.org/wiki/index.php..._of_All_Events

  5. #5
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I finally fixed most of it and I got rid of most of the errors. Everything except the Tyrand part works perfectly.

    Code:
    local PlayerA
    local Tyrande
    local NPCID = 7999
    
    function X_OnFirstEnterWorld(event, pPlayer, pUnit, player)
    	local Tyrande = pUnit
    		if PlayerA == nil then
    		pPlayer:SetBindPoint(-11110.046875, -1797.107056, 20.674711, 0, 2563) -- Set's the char's hearthstone
    		pPlayer:CastSpell(12438) --Slow Fall
            pPlayer:CastSpell(53658) --Shadowmourn Tabard Visual
    		pPlayer:MovePlayerTo(-11110.046875, -1797.107056, 20.674711, 2.663683, 12288, 1)
            PlayerA = pPlayer 
    		Tyrande:SendChatMessage(15,0,"Don't worry I got you!")
    		Tyrande:ChannelSpell(47855, player) -- Drain Soul
    		PlayerA:RemoveAura(53658) -- Removes glowy bubble
    	end
    end
    
    RegisterServerHook(3, "X_OnFirstEnterWorld") -- Register the on first enter world

  6. #6
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    What is PlayerA, why did you set it as the player, and why is Tyrande being changed to a local variable within the function (clashing variables)?

  7. #7
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ---------- Post added at 04:35 PM ---------- Previous post was at 03:11 PM ----------

    [/COLOR]I cleaned up the stupid parts of the script and now its still not working when it gets to the pUnit part.
    Code:
    local NPCID = 7999
    
    function X_OnFirstEnterWorld(event, pPlayer, pUnit)
    		if PlayerA == nil then
    		pPlayer:SetBindPoint(-11110.046875, -1797.107056, 20.674711, 0, 2563) -- Set's the char's hearthstone
    		pPlayer:CastSpell(12438) --Slow Fall
            pPlayer:CastSpell(53658) --Shadowmourn Tabard Visual
    		pPlayer:MovePlayerTo(-11110.046875, -1797.107056, 20.674711, 2.663683, 12288, 1) 
    		pUnit:SendChatMessage(15,0,"Don't worry I got you!")
    		pUnit:ChannelSpell(47855, pPlayer) -- Drain Soul
    		pPlayer:RemoveAura(53658) -- Removes glowy bubble
    	end
    end
    
    RegisterServerHook(3, "X_OnFirstEnterWorld") -- Register the on first enter world
    Last edited by tyeeeee1; 02-03-2011 at 02:26 PM.

  8. #8
    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)
    There's no pUnit variable passed on in the OnFirstEnterWorld event. What you should use is local pUnit = pPlayer:GetCreatureNearestCoords(pPlayer:GetX(), pPlayer:GetY(), pPlayer:GetZ(), NPCID) instead, which returns a reference to the creature (if found, so it would be wise to check for a nil value there, unles you're 100% certain the creature is always there). With pUnit initialized, you should be able to make it perform the things you would like it to.
    Ignorance is bliss.

  9. #9
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks it works as intended now the only thing left is to tweak it a bit, BTW if there some sort of wait timer for Lua which stops the script for a few seconds and then continues it?

  10. #10
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    No, not without freezing the whole process (basically whole server).

    Just use events.

  11. #11
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, thanks for all the help.

Similar Threads

  1. NPC Editing Error
    By TiberiusMalaris in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 07-28-2010, 05:30 AM
  2. [Model Error] Every npc is a blue/white box
    By HunterHero in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 02-14-2010, 05:33 AM
  3. [request more eyes to see the error :)] Mangos Npc trainer
    By Veldor in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 11-18-2009, 12:00 AM
  4. [Help]Error creating a Npc boss
    By Agent Orange in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 12-31-2008, 10:53 AM
  5. Error with a level npc.lua
    By _DEFiANT in forum WoW EMU Questions & Requests
    Replies: 10
    Last Post: 09-09-2008, 05:47 PM
All times are GMT -5. The time now is 05:55 PM. 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