API UnitGUID

Returns the GUID of the specified unit. guid = UnitGUID("unit")

Arguments

 * unit : UnitId - unit to look up the GUID of.

Returns

 * guid : String (GUID) - a string containing the hexadecimal representation of the unit's GUID, e.g. "Creature-0-1133-870-141-71953-0000432FBD" (Xuen, on Timeless Isle), or nil if the unit does not exist.

Example
The following snippet attempts to figure out what you're targeting based on its GUID: local guid, name = UnitGUID("target"), UnitName("target") local type, zero, server_id, instance_id, zone_uid, npc_id, spawn_uid = strsplit("-",guid); print(name .. " is a " .. type); if type == "Creature" then print(name .. "'s NPC id is " .. npc_id) elseif type == "Vignette" then print(name .. " is a Vignette and should have its npc_id be zero (" .. npc_id .. ").") elseif type == "Player" then print(name .. " is a player.") end