I can't find anything wrong with my script, can you? menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I can't find anything wrong with my script, can you?

    So basically, this script isn't working. Anyone knows what's wrong with it?

    local NPC_ID = 85010
    local QUEST_ID = 90006


    function Quest_OnQuestAccept(event, pPlayer, pQuestGiver, questId)
    if(pQuestGiver == NPC_ID) and (questId == QUEST_ID) then
    pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    end
    end

    function Kodos_Spawn(QuestGiver, Event)
    pGuestGiver:SendChatMessage(12, 0, "Watch out!")
    pQuestGiver:RegisterEvent("Kodos_Summon", 15000, 10)
    end

    RegisterServerHook(14, "Quest_OnQuestAccept")

    ----------Spells------------


    function Kodos_Summon(QuestGiver, Event)
    QuestGiver:SpawnCreature (85011, -8246, -2606, 133, 4, 380000)
    end

    ---------End phases----------

    I can't find anything wrong with my script, can you?
  2. #2
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    pQuestGiver is a object not a integer.

    Use: pQuestGiver:GetEntry() to return the ID.

  3. #3
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alrighty, now my script looks like this:

    local NPC_ID = 85010
    local QUEST_ID = 90006


    function Quest_OnQuestAccept(event, pPlayer, pQuestGiver, questId)
    if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    end
    end

    function Kodos_Spawn(QuestGiver, Event)
    pGuestGiver:SendChatMessage(12, 0, "Watch out!")
    pQuestGiver:RegisterEvent("Kodos_Summon", 15000, 10)
    end

    RegisterServerHook(14, "Quest_OnQuestAccept")

    ----------Spells------------


    function Kodos_Summon(QuestGiver, Event)
    QuestGiver:SpawnCreature (85011, -8246, -2606, 133, 4, 380000)
    end

    ---------End phases----------
    So I saved it, did reloadscripts and I when I accept the quest I get the error 'scripts/TestQuest.lua:6: attempt to index local 'pQuestGiver' <a number value>'.

    What's wrong now ;o?

  4. #4
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Don't use reload scripts. Fully restart the server.

  5. #5
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    Don't use reload scripts. Fully restart the server.
    Did that, same error given :/

  6. #6
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Laenoar View Post
    Did that, same error given :/
    I see now. The argument was returning a number value (integer) rather than a unit pointer.

    Code:
    function Quest_OnQuestAccept(event, pPlayer, pQuestGiver, questId)
    Needs to be changed to:

    Code:
    function OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    Where-ever you got the argument order from is incorrect.

  7. #7
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, thanks for that. Now the first part is working, I get the text 'Get ready!' showing up on my screen.
    I first tried summoning with this code, wich I got from somewhere:
    function Kodos_Summon(QuestGiver, Event)
    QuestGiver:SpawnCreature (85011, -8246, -2606, 133, 4, 380000)
    end
    But it doesn't seem to work, nor does the NPC say 'Watch out!' wich is supposed to happen 10 seconds after the 'Get ready!'.
    Then I decided to try this code for summoning:
    function Kodos_Summon(QuestGiver, Event)
    QuestGiver:SpawnCreature (85011, -8246, -2606, 133, 0)
    end
    Still not working, no error given or anything. Any idea what I did wrong now?

  8. #8
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    SpawnCreature(id, x, y, z, o, faction, time) -- set time to 0 to spawn forever till next restart/it dies

    Those are the required arguments (more can be supplied - ...time, weapon mainhand, weapon offhand, weapon ranged, phase, save). You do not supply enough arguments for it to spawn successfully.

  9. #9
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    SpawnCreature(id, x, y, z, o, faction, time) -- set time to 0 to spawn forever till next restart/it dies

    Those are the required arguments (more can be supplied - ...time, weapon mainhand, weapon offhand, weapon ranged, phase, save). You do not supply enough arguments for it to spawn successfully.
    Okay, thank you, so now my scripts looks like this:
    local NPC_ID = 85010
    local QUEST_ID = 90006


    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    end
    end

    function Kodos_Spawn(QuestGiver, Event)
    pGuestGiver:SendChatMessage(12, 0, "Watch out!")
    pQuestGiver:RegisterEvent("Kodos_Summon", 15000, 5)
    end

    RegisterServerHook(14, "Quest_OnQuestAccept")

    ----------Spells------------


    function Kodos_Summon(QuestGiver, Event)
    QuestGiver:SpawnCreature(85011, -8246, -2606, 133, 0, 14, 0)
    end

    ---------End phases----------
    And it says 'Get ready!' but it doesn't seem to properly register the 'function Kodos_Spawn'. Meaning I do not get the NPC to say 'Watch out!' or get any Kodos to spawn. Man, I really appreciate your help. I could probably figure this out if I got a proper error showing up, but nope, no error or anything. Did I do anything wrong registering the event?

  10. #10
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Laenoar View Post
    Okay, thank you, so now my scripts looks like this:


    And it says 'Get ready!' but it doesn't seem to properly register the 'function Kodos_Spawn'. Meaning I do not get the NPC to say 'Watch out!' or get any Kodos to spawn. Man, I really appreciate your help. I could probably figure this out if I got a proper error showing up, but nope, no error or anything. Did I do anything wrong registering the event?
    I think there is a issue with your Lua engine because I can see pretty obvious errors that should be printing out to console.

    At this function:

    Code:
    function Kodos_Spawn(QuestGiver, Event)
    You say that the unit pointer passed in is going to be called 'QuestGiver'. But then on the next line, you try to use:

    pGuestGiver

    Which does not exist in this context.

    You can use print("string") to print to console, and thus find where execution stops and why. You can print variables using this method too.

    Here is a fixed version of your script:

    Code:
    local NPC_ID = 85010
    local QUEST_ID = 90006
    
    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    	if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    		pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    		pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    	end
    end
    
    function Kodos_Spawn(pQuestGiver, Event)
    	pGuestGiver:SendChatMessage(12, 0, "Watch out!")
    	pQuestGiver:RegisterEvent("Kodos_Summon", 15000, 5)
    end
    
    RegisterServerHook(14, "Quest_OnQuestAccept")
    
    ----------Spells------------
    
    
    function Kodos_Summon(pQuestGiver, Event)
    	pQuestGiver:SpawnCreature(85011, -8246, -2606, 133, 0, 14, 0)
    end
    
    ---------End phases----------

  11. #11
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still not working, same thing as I said before. I only get the message 'Get ready!' showing up on my screen :/

  12. #12
    XxXGenesisXxX's Avatar Sergeant Major
    Reputation
    67
    Join Date
    Apr 2012
    Posts
    154
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know shit about lua anymore, learnt a little bit of it few years ago, but haven't really touched it since so I may be totally off and wrong. However I did notice, are you meant to have both "end"s there? Cause what's the second one ending? Your first is ending your function yeah? What's the second ending? Or do you have to end the "if" statements?

    Code:
    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    	if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    		pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    		pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    	end
    end

  13. #13
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by XxXGenesisXxX View Post
    I don't know shit about lua anymore, learnt a little bit of it few years ago, but haven't really touched it since so I may be totally off and wrong. However I did notice, are you meant to have both "end"s there? Cause what's the second one ending? Your first is ending your function yeah? What's the second ending? Or do you have to end the "if" statements?

    Code:
    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    	if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    		pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    		pQuestGiver:RegisterEvent("Kodos_Spawn", 10000, 1)
    	end
    end
    You end if's.

    @OP, test this:

    Code:
    local NPC_ID = 85010
    local QUEST_ID = 90006
    
    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    	if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    		pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    		print("Registering Event")
    		pQuestGiver:RegisterEvent("zKodos_Spawn", 10000, 1)
    	end
    end
    
    function zKodos_Spawn(pQuestGiver, Event)
    	print("function called")
    	pQuestGiver:SendChatMessage(12, 0, "Watch out!")
    	pQuestGiver:RegisterEvent("zKodos_Summon", 15000, 5)
    end
    
    RegisterServerHook(14, "Quest_OnQuestAccept")
    
    ----------Spells------------
    
    
    function zKodos_Summon(pQuestGiver, Event)
    	print("Spawning creature!")
    	pQuestGiver:SpawnCreature(85011, -8246, -2606, 133, 0, 14, 0)
    end
    
    ---------End phases----------

  14. #14
    Laenoar's Avatar Corporal
    Reputation
    1
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all your help, but it's still not working :/, I only get 'Registering Event' printed. I think I should give up, really, I have no idea what's causing this problem.

  15. #15
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Perhaps events cannot be fired from this hook (similar issues appear in gossip scripts).

    Try this as a hack fix:

    Code:
    local NPC_ID = 85010
    local QUEST_ID = 90006
    local start = false
    
    function Quest_OnQuestAccept(event, pPlayer, questId, pQuestGiver)
    	if(pQuestGiver:GetEntry() == NPC_ID) and (questId == QUEST_ID) then
    		pQuestGiver:SendChatMessage(42, 0, "Get ready!")
    		start = true
    	end
    end
    
    function QuestGiverSpawns(pUnit, Event)
    	pUnit:RegisterEvent("CHeckForEventStarT", 1000, 0)
    end
    
    function CHeckForEventStarT(pUnit)
    	if start then
    		start = false
    		pUnit:RemoveEvents()
    		pUnit:RegisterEvent("zKodos_Spawn", 4000, 1)
    	end
    end
    
    RegisterUnitEvent(NPC_ID, 18, "QuestGiverSpawns")
    
    function zKodos_Spawn(pUnit)
    	print("function called")
    	pUnit:SendChatMessage(12, 0, "Watch out!")
    	pUnit:RegisterEvent("zKodos_Summon", 15000, 5)
    	pUnit:RegisterEvent("QuestGiverSpawns", 80000, 1)
    end
    
    RegisterServerHook(14, "Quest_OnQuestAccept")
    
    ----------Spells------------
    
    
    function zKodos_Summon(pUnit)
    	print("Spawning creature!")
    	pUnit:SpawnCreature(85011, -8246, -2606, 133, 0, 14, 0)
    end
    
    ---------End phases----------

Page 1 of 2 12 LastLast

Similar Threads

  1. Whats wrong with my Script
    By edded in forum WoW EMU Questions & Requests
    Replies: 9
    Last Post: 07-31-2009, 10:02 AM
  2. What is wrong with this script?
    By XxCyanidexX in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 03-01-2009, 12:13 PM
  3. Can you see anything wrong with this .lua?
    By Kiev in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 06-13-2008, 10:22 AM
  4. What is Wrong with my Script
    By Juicyz in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 05-23-2008, 07:37 PM
  5. [Need help] What's wrong with this script?
    By Arthas117 in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 01-10-2008, 02:04 PM
All times are GMT -5. The time now is 07:11 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