A few questions about working with GUIDs menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  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)

    A few questions about working with GUIDs

    Hey,

    I'm currently starting to script a few misc units in a small area that I'm working on and because I find that using the commands to setup waypoints, emotes, etc... can be a bit buggy I've decided to try my hand at scripting each NPC.
    I'm fairly sure I can use the GUID instead of setting the script to run on all units of type 90017 but there are a few questions I have:

    -How would I register the function when using a GUID since I think I cannot use something like this
    Code:
    RegisterUnitEvent(90017, 18, "SeanPinius_01")
    because it registers the fuction to all units of type 90017.

    -If I set "Guard" to the GUID of one specific guard unit like so
    Code:
    function CDarrowGuard01(unit, event)
    	local Guard = Unit:GetUnitByGUID(142169)
    	Guard:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    	Guard:RegisterEvent("CDarrowGuard02", 10000, 1)
    end
    will it conflict with another script if the other script also uses the same variable name ?

    -I've heard that the GUID is also known as the SQLEntryID, when I do the command ".N I" on an NPC to find out its information it shows both an SQLEntryID and a GUID. Which one do I use?

    I think thats all I wanted to know for now, I may have a few more questions later on. Thanks for any help in advance.

    A few questions about working with GUIDs
  2. #2
    bendaferi's Avatar Active Member
    Reputation
    34
    Join Date
    Jun 2008
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GetUnitBySqlId() will return the sql id of the unit
    GetGUID() will return it's unique guid value

    I recommed you to use the GetUnitBySqlId() command. You can find out the specified npcs SqlId by targeting it and typing ".npc info".

    Also watch out unit ~= Unit. (just noticed )

  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)
    So it is better to use the SQLID instead of the GUID?

    Also... I'm not sure what you're saying for me to watch out for (I'm still a noob =P)

  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)
    Either way, your script will have that script call for each time that npc ID is spawned, and then make that GUID move each time.

    Do on spawn:

    Code:
    local npc = pUnit:GetUnitByGUID(put_guid_here)
    if npc == pUnit:GetGUID() then -- this way, only if the current npc = the unit's GUID then we do the script
        npc:DoStuff()
    end

  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)
    I've updated the script with your suggestions Stoneharry, but even after reloading the scripts, respawningthe NPC, and waiting for the NPC to do something nothing seems top be happening. I double checked that the GUID was correct and it was.
    Did I make an error putting in what you said?

    Code:
    function CDarrowGuard001_01(Unit, Event)
    	local Guard = Unit:GetGUID(-1577058301)
    	if Guard == Unit:GetGUID() then
    		Guard:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Guard:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event)
    	Guard:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Guard:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Guard:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Guard:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Guard:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")

  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)
    If there are no errors, you should know what to do by now. Mass print.

    However, your script is wrong which is why it is not working.

    Code:
    function CDarrowGuard001_01(Unit, Event)
    	local Guard = Unit:GetUnitByGUID(-1577058301) -- you might need to remove the - in this, test it.
    	Unit:SendChatMessage(Guard) -- this is the unit we are checking for
    	Unit:SendChatMessage(Unit:GetGUID()) -- this is the unit calling the event
    	if Guard == Unit:GetGUID() then -- if unit calling event = unit we are looking for
    		Unit:SendChatMessage(12,0,"The GUID's match!") -- send message
    		Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Unit:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Unit:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")

  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)
    It took me a few reads to understand what you meant up top =P

    I just did a few different edits and re-edits. Your two new lines "Unit:SendChatMessage(Guard)" "Unit:SendChatMessage(Unit:GetGUID())" I assumed were to tell me what "Guard" and "Unit:GetGUID()" were doing because they show up as bad arguments or something like that when loadong the script. So I tested two times with them (One test with the GUID of "-1577058301" and the other with the GUID of "-1577058301"). Neither worked.

    Then I removed those two lines and tested twice again with the two different GUIDS. Still no luck =/
    I checked the units GUID again and it is correct.




    **Sorry if its painfully obvious, I'm just a bit slow today =P**

  8. #8
    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 on the send chat message I forgot to add (12,0,tostring(Guard))

    which is why you got an argument error.

    You can try something like this instead, supplying the SQLId:

    Code:
    function CDarrowGuard001_01(Unit, Event)
    
    	-- local Guard = Unit:GetUnitByGUID(-1577058301)
    	
    	local Guard = Unit:GetUnitBySqlId(SQLId)
    	Unit:SendChatMessage(12,0,tostring(Guard)) -- this is the unit we are checking for
    	local GUID = Guard:GetGUID()
    	Unit:SendChatMessage(12,0,tostring(GUID))
    	Unit:SendChatMessage(Unit:GetGUID()) -- this is the unit calling the event
    	if GUID == Unit:GetGUID() then -- if unit calling event = unit we are looking for
    		Unit:SendChatMessage(12,0,"The GUID's match!") -- send message
    		Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Unit:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Unit:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")

  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)
    Line 9 comes back as an argument because I think it should say "tostring(Unit:GetGUID())" instead of Unit:"GetGUID()". The unit I'm tring to manipulate says that his GUID is actually A2000003 and not the number that shows up when I use the command ".N I".
    For the top area before line 9 it works for every guard NPC (As I think you intended it to) so thats how I get the GUID of A2000003.

    When I remove line 9 the script loads perfectly with no arguments at all. But from what I can somewhat grasp, something is going on on the line "if GUID == Unit:GetGUID() then" because the script should work. I think something is going on with the GUID.


    I broke the script into a fragment of what you have and just put it down to:

    Code:
    function CDarrowGuard001_01(Unit, Event)
    
    	-- local Guard = Unit:GetUnitByGUID(-1577058301)
    	
    local Guard = Unit:GetUnitBySqlId(142170)
    local GUID = Guard:GetUnitByGUID()
    	if GUID == Guard:GetUnitByGUID() then
    	Guard:SendChatMessage(12, 7, "working")
    	Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    	Guard:RegisterEvent("CDarrowGuard001_02", 1000, 1)
    end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 30000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Unit:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")
    To make sure that the MoveTo commands were working and they were, so i(in my mind) has to be some sort of problem with the GUID.







    Currently the script looks like this:
    Code:
    function CDarrowGuard001_01(Unit, Event)
    
    	-- local Guard = Unit:GetUnitByGUID(-1577058301)
    	
    	local Guard = Unit:GetUnitBySqlId(142170)
    	Unit:SendChatMessage(12,0,tostring(Guard)) -- this is the unit we are checking for
    	local GUID = Guard:GetGUID()
    	Unit:SendChatMessage(12,0,tostring(GUID))
    	Unit:SendChatMessage(12, 0, Unit:GetGUID()) -- this is the unit calling the event
    	if GUID == Unit:GetGUID() then -- if unit calling event = unit we are looking for
    		Unit:SendChatMessage(12,0,"The GUID's match!") -- send message
    		Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Unit:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Unit:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")
    *Thanks for the help up till now*

  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)
    Can you please post what is being sent in the messages in the order they are sent.

    The script uses the SQLID of the creature to get his GUID. This is then sent as a message (may return null if no creature was found and error).

    The script then gets the GUID of the Guard (this may not be needed if Guard is already the GUID, in which case it will error. Remove this line for testing.)

    It the sends both the units get and the GUID returned from the creature we are looking for. We need to try and get them to be the same thing.

  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)
    When the script includes line 9 like so:

    Code:
    function CDarrowGuard001_01(Unit, Event)
    
    	-- local Guard = Unit:GetUnitByGUID(-1577058301)
    	
    	local Guard = Unit:GetUnitBySqlId(142170)
    	Unit:SendChatMessage(12,0,tostring(Guard)) -- this is the unit we are checking for
    	local GUID = Guard:GetGUID()
    	Unit:SendChatMessage(12,0,tostring(GUID))
    	Unit:SendChatMessage(12, 0, Unit:GetGUID()) -- this is the unit calling the event
    	if GUID == Unit:GetGUID() then -- if unit calling event = unit we are looking for
    		Unit:SendChatMessage(12,0,"The GUID's match!") -- send message
    		Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Unit:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end
    
    function CDarrowGuard001_04(Unit, Event)
    	Unit:MoveTo(1075.207764, -2438.461914, 61.268898, 0.807374)
    end
    	
    RegisterUnitEvent(90018, 18, "CDarrowGuard001_01")
    The error that shows up is below and if I remember correctly it shows up 3-4 times in a row and it is the only error:

    Code:
    [ERR] C:\WoW Private Server Files 11-23-2010\arcemu\code\src\scripts\src\LuaEngine\LUAEngine.cpp:92 report ...cripts\Caer Darrow Guard Patrol 01 (Caer Darrow).lua:9: bad argument #2 to 'SendChatMessage' (string expected, got userdata)
    I know that that error shows up because line 9 isn't written right. So when I delete line 9 and then reload the script it loads perfectly but even after waiting for about a minute nothing happens except for the chat messages above the line "if GUID == Unit:GetGUID() then":
    Code:
    Caer Darrow Guard says: nil
    Caer Darrow Guard says: nil
    Caer Darrow Guard says: Unit (4F700EA8)
    Caer Darrow Guard says: A2000003

  12. #12
    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)
    Fixed, test this:

    Code:
    function CDarrowGuard001_01(Unit, Event)
    	local Guard = Unit:GetUnitBySqlId(142170)
    	Unit:SendChatMessage(12,0,"Output : 1 = "..tostring(Guard)) -- this is the unit we are checking for
    	local GUID = Guard:GetGUID()
    	Unit:SendChatMessage(12,0,"Output : 2 = "..tostring(GUID))
    	Unit:SendChatMessage(12, 0, "Output : 3 = "..tostring(Unit:GetGUID())) -- this is the unit calling the event
    	if GUID == Unit:GetGUID() then -- if unit calling event = unit we are looking for
    		Unit:SendChatMessage(12,0,"The GUID's match!") -- send message
    		Unit:MoveTo(949.457764, -2500.565918, 57.704636, 2.952302)
    		Unit:RegisterEvent("CDarrowGuard001_02", 10000, 1)
    	end
    end
    
    function CDarrowGuard001_02(Unit, Event) -- We can use Unit now since all the unit we are trying to control registered the event
    	Unit:MoveTo(1025.368042, -2514.938477, 59.142624, 1.279398)
    	Unit:RegisterEvent("CDarrowGuard001_03", 10000, 1)
    end
    
    function CDarrowGuard001_03(Unit, Event)
    	Unit:MoveTo(1037.240479, -2463.902832, 60.313976, 0.677783)
    	Unit:RegisterEvent("CDarrowGuard001_04", 5000, 1)
    end

  13. #13
    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)
    The unit still doesn't move but here is what is outputted:

    Code:
    Caer Darrow Guard says: Output: 1 = nil
    Caer Darrow Guard says: Output: 1 = nil
    Caer Darrow Guard says: Output: 1 = Unit (4F448C18)
    Caer Darrow Guard says: Output: 2 = A2000003
    Caer Darrow Guard says: Output: 3 = (Forgot what this said, but it looked normal)
    The above appears when I first log in to my character which is infront of the unit. The below is what pops up after I do "reloadscripts" in world.exe:

    Code:
    Caer Darrow Guard says: Output: 1 = Unit (4F448C18)
    Caer Darrow Guard says: Output: 2 = A2000003
    Caer Darrow Guard says: Output: 3 = A2000001
    Caer Darrow Guard says: Output: 1 = Unit (4F448C18)
    Caer Darrow Guard says: Output: 2 = A2000003
    Caer Darrow Guard says: Output: 3 = A2000002
    Caer Darrow Guard says: Output: 1 = Unit (4F448C18)
    Caer Darrow Guard says: Output: 2 = A2000003
    Caer Darrow Guard says: Output: 3 = A2000003
    I should probably note that there are two guards within viewing distance of the guard I'm trying to control, thats probably why the message pops up three times.

  14. #14
    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)
    Basically it is null because the unit you are trying to get has not loaded yet when you logged in. You can fix this by having a simple:

    if Guard ~= nil then
    do stuff
    end

    Anyway, as far as I can tell, outputs 2 and 3 are what we are comparing, and they are the same:

    Caer Darrow Guard says: Output: 2 = A2000003
    Caer Darrow Guard says: Output: 3 = A2000003

    So if you try changing:

    if GUID == Unit:GetGUID() then

    to

    if tostring(GUID) == tostring(Unit:GetGUID()) then

    then it should work.

  15. #15
    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)
    The script is running properly now. I'm slightly lost on what you did there. What is tostring and why did it work?


    Thank you for helping me ^.^

Page 1 of 2 12 LastLast

Similar Threads

  1. Questions about Kopp's Guide (not about downloading it)
    By kc0716 in forum World of Warcraft General
    Replies: 6
    Last Post: 02-28-2007, 04:08 PM
  2. A few questions about model editing
    By Kelindel in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 01-01-2007, 11:23 PM
  3. A few questions about model editing
    By Kelindel in forum World of Warcraft General
    Replies: 0
    Last Post: 01-01-2007, 08:57 PM
  4. A few questions about WoW
    By colm in forum World of Warcraft General
    Replies: 2
    Last Post: 08-23-2006, 12:04 PM
All times are GMT -5. The time now is 08:24 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