WoW:API UnitGUID: Difference between revisions
(New page: {{wowapi}} __NOTOC__ Returns the GUID of the unit specified. UnitGUID("unit") == Returns == <!-- List each return value, together with its type --> :;GUID : Ret...) |
(Updated with new information) |
||
| Line 5: | Line 5: | ||
UnitGUID("[[unitId|unit]]") | UnitGUID("[[unitId|unit]]") | ||
== What does it all mean? == | |||
The GUID is a unique hexadecimal string for each unit in the game. | |||
The strings seems to always begin with '0x', which is the normal prefix for hexadecimal numbers. | |||
I don't know the purpose of the next two digits; seems to be 'F1' for everything except players, which are '00'. | |||
The digit after that appears to depend on what the unit is used for. Players seem to have '0', NPCs, monsters, critters, and non-combat pets seem to have '3', and player pets and minions seem to have '4' | |||
'. | |||
The next seven digits seem to be the unit's type, which is always the same for any unit of that type, regardless of locale. | |||
''Note:'' 7 nibbles implies that 3 and a half bytes are used for this field, which is kind of an odd number. Also, this is larger than the following field, which only has 6 digits, which is even more odd as one would expect there to be more units than unit types. So, this might actually be some unknown digit followed by 6 digits for the unit type. | |||
The next six digits seem to be more or less random, and are probably assigned sequentially each time the server creates a unit. | |||
== Speculations == | == 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. | 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. | ||
| Line 23: | Line 40: | ||
<big>'''Decimal Result'''</big> | <big>'''Decimal Result'''</big> | ||
'''I believe the GUID is too large to be represented as a number, as such, this is a bad idea.''' [[User:Smariot|Smariot]] 19:33, 8 April 2008 (UTC) | |||
Alternatively you can also make it output the decimal value instead of the hexdecimal by doing like this: | Alternatively you can also make it output the decimal value instead of the hexdecimal by doing like this: | ||
Revision as of 19:33, 8 April 2008
Returns the GUID of the unit specified. Works on both players and NPC.
UnitGUID("unit")
What does it all mean?
The GUID is a unique hexadecimal string for each unit in the game.
The strings seems to always begin with '0x', which is the normal prefix for hexadecimal numbers.
I don't know the purpose of the next two digits; seems to be 'F1' for everything except players, which are '00'.
The digit after that appears to depend on what the unit is used for. Players seem to have '0', NPCs, monsters, critters, and non-combat pets seem to have '3', and player pets and minions seem to have '4' '.
The next seven digits seem to be the unit's type, which is always the same for any unit of that type, regardless of locale.
Note: 7 nibbles implies that 3 and a half bytes are used for this field, which is kind of an odd number. Also, this is larger than the following field, which only has 6 digits, which is even more odd as one would expect there to be more units than unit types. So, this might actually be some unknown digit followed by 6 digits for the unit type.
The next six digits seem to be more or less random, and are probably assigned sequentially each time the server creates a 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
I believe the GUID is too large to be represented as a number, as such, this is a bad idea. Smariot 19:33, 8 April 2008 (UTC)
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