Plr is nil value menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Xmaily's Avatar Master Sergeant
    Reputation
    14
    Join Date
    May 2013
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Plr is nil value

    I'm trying to script a quest and I keep getting this error Attempt to index local "Plr" <a nil value>

    Here is the code:

    if(intid == 5) then
    pUnit:GossipCreateMenu(3544, player, 0)
    pUnit:SendChatMessage(12, 0, "Thanks for the Help!", 0, 0)
    pUnit:Emote(1, 5000)
    pUnit:RegisterEvent("Testquest", 1000, 1)
    pUnit:GossipSendMenu(player)
    end
    end

    RegisterUnitGossipEvent(97582, 1, "Teleport_on_gossip_talk")
    RegisterUnitGossipEvent(97582, 2, "Teleport_on_gossip_select")

    function Testquest(pUnit, Event, Plr)
    if Player:HasQuest(QuestID) then
    Plr:AdvanceQuestObjective(QuestID, 0)
    end
    end

    Plr is nil value
  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)
    Code:
    function Testquest(pUnit, Event, Plr)
    if Player:HasQuest(QuestID) then
    Plr:AdvanceQuestObjective(QuestID, 0)
    end
    end
    You pass in the value Plr then use Player on the next line which is not going to exist.

    Also you should post the full script and the error line number.

  3. #3
    Xmaily's Avatar Master Sergeant
    Reputation
    14
    Join Date
    May 2013
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    Code:
    function Testquest(pUnit, Event, Plr)
    if Player:HasQuest(QuestID) then
    Plr:AdvanceQuestObjective(QuestID, 0)
    end
    end
    You pass in the value Plr then use Player on the next line which is not going to exist.

    Also you should post the full script and the error line number.
    Code:
    local QuestID = 90072
    
    function Teleport_on_gossip_talk(pUnit, event, player)
    pUnit:GossipCreateMenu(3544, player, 0)
    pUnit:GossipMenuAddItem(0, "You need to get out of here Quickly! It's not safe here.", 5, 0)
    pUnit:GossipSendMenu(player)
    end
    
    function Teleport_on_gossip_select(pUnit, event, player, id, intid, code)
    
    if(intid == 5) then
    pUnit:GossipCreateMenu(3544, player, 0) 
    pUnit:SendChatMessage(12, 0, "Thanks for the Help!", 0, 0)
    pUnit:Emote(1, 5000)
    pUnit:RegisterEvent("TestFunction", 1000, 1)
    pUnit:RegisterEvent("Citizendespawn", 5000, 1)
    pUnit:GossipSendMenu(player)
    end
    end
    
    RegisterUnitGossipEvent(97582, 1, "Teleport_on_gossip_talk")
    RegisterUnitGossipEvent(97582, 2, "Teleport_on_gossip_select")
    
    function Orggruntevent_OnSpawn(pUnit, Event)
            pUnit:Emote(430, 4000)
    end
    
    function Orggruntevent_OnCombat(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    function Orggruntevent_OnKilledPlayer(pUnit, Event, Plr)
    end
    
    function Orggruntevent_OnLeaveCombat(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    function Orggruntevent_OnDied(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(97582, 1, Orggruntevent_OnCombat)
    RegisterUnitEvent(97582, 2, Orggruntevent_OnLeaveCombat)
    RegisterUnitEvent(97582, 3, Orggruntevent_OnKilledPlayer)
    RegisterUnitEvent(97582, 4, Orggruntevent_OnDied)
    RegisterUnitEvent(97582, 18, Orggruntevent_OnSpawn)
    
    function TestFunction(pUnit, Event, Plr)
    	if Plr:HasQuest(QuestID) then
    		Plr:AdvanceQuestObjective(QuestID, 0)
    	end
    end
    
        function Citizendespawn(pUnit, Event, Plr)
                pUnit:CastSpell(51347)
                pUnit:Despawn(1600, 0)
        end
    The Error Line is if Plr:HasQuest(QuestID) then wit the error Attempt to index local "Plr" <a nil value>

    I change that silly mistake of Player and Plr but it's still giving me a error.
    Last edited by Xmaily; 10-20-2013 at 04:09 PM.

  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)
    I'll be surprised if this even slightly worked.

    Try this:

    Code:
    local QuestID = 90072
    
    function Teleport_on_gossip_talk(pUnit, event, player)
    	pUnit:GossipCreateMenu(3544, player, 0)
    	pUnit:GossipMenuAddItem(0, "You need to get out of here Quickly! It's not safe here.", 5, 0)
    	pUnit:GossipSendMenu(player)
    end
    
    function Teleport_on_gossip_select(pUnit, event, player, id, intid, code)
    	if(intid == 5) then
    		pUnit:SendChatMessage(12, 0, "Thanks for the Help!", 0, 0)
    		pUnit:Emote(1, 5000)
    		pUnit:RegisterEvent("TestFunction", 1000, 1)
    		pUnit:RegisterEvent("Citizendespawn", 5000, 1)
    		player:GossipComplete()
    	end
    end
    
    RegisterUnitGossipEvent(97582, 1, "Teleport_on_gossip_talk")
    RegisterUnitGossipEvent(97582, 2, "Teleport_on_gossip_select")
    
    function Orggruntevent_OnSpawn(pUnit, Event)
        pUnit:Emote(430, 0)
    end
    
    function Orggruntevent_OnCombat(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    function Orggruntevent_OnKilledPlayer(pUnit, Event, Plr)
    end
    
    function Orggruntevent_OnLeaveCombat(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    function Orggruntevent_OnDied(pUnit, Event, Plr)
    	pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(97582, 1, Orggruntevent_OnCombat)
    RegisterUnitEvent(97582, 2, Orggruntevent_OnLeaveCombat)
    RegisterUnitEvent(97582, 3, Orggruntevent_OnKilledPlayer)
    RegisterUnitEvent(97582, 4, Orggruntevent_OnDied)
    RegisterUnitEvent(97582, 18, Orggruntevent_OnSpawn)
    
    function TestFunction(pUnit, Event)
    	local Plr = pUnit:GetClosestPlayer()
    	if Plr and Plr:HasQuest(QuestID) then
    		Plr:AdvanceQuestObjective(QuestID, 0)
    	end
    end
    
    function Citizendespawn(pUnit, Event, Plr)
    	pUnit:CastSpell(51347)
    	pUnit:Despawn(1600, 0)
    end
    Player is not a variable passed with a registered unit event.

Similar Threads

  1. [Lua Script] Help with script, index upvalue "NPC_SPAWNER_A" <nil value> ?
    By hinur in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 12-15-2015, 03:00 AM
  2. Replies: 0
    Last Post: 01-18-2015, 07:33 AM
  3. [Lua Script] Attempt to index local 'Unit' (a nil value)
    By chris999 in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 01-05-2011, 09:58 AM
  4. LUA, How Can i check for a nil value?
    By controlsx2 in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 06-21-2009, 08:32 PM
  5. Cheat Engine Values
    By cosmo145 in forum World of Warcraft Bots and Programs
    Replies: 45
    Last Post: 05-06-2007, 02:36 PM
All times are GMT -5. The time now is 09:57 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