WoW API: UnitGUID
Returns the GUID of the unit specified. Works on both players and NPC.
UnitGUID("unit")
Speculations
The value returned from players is how recent the player have been created. Someone with the number 1000 would be the 1000th created character on the server, a NPC would simply count up. Each NPC that respawns adds a number higher, so 4294967295 means that there have been 4294967294 NPC before that one that have respawned. Renaming does not change the player UnitGUID value so you can track players trough renames using this, unfortunately if you transfer you're character obtains a new GUID, the last value obtainable (as creating a new character). In instances spawned NPC/mobs return the same value, unlike outside a instance. Player pets keep their value when you despawn then spawn them back, so pets appear to have their own GUID counter like character GUID (creation) counter.
Returns
- GUID
- Returns the unit GUID in hexdecimal.
Example
local name = UnitName("target"); local guid = UnitGUID("target"); ChatFrame1:AddMessage(name.." has the GUID: "..guid);
Result
Cyan has the GUID: 0x00000000012729FD
Decimal Result
Alternatively you can also make it output the decimal value instead of the hexdecimal by doing like this:
local name = UnitName("target"); local guid = tonumber(UnitGUID("target"),16); ChatFrame1:AddMessage(name.." has the GUID: "..guid);
The above function would then return this:
Cyan has the GUID: 19343869