Originally Posted by Kanegasi
All player GUIDs are unique and do not change as long as the character does not change faction or realm. I'm pretty sure they stick if you only name change, but I could be wrong.
All other GUIDs are designated on spawn. Every single object, item, npc, anything else in the game receives a unique GUID upon spawn, including your pet, since it's a controllable npc. When your pet disappears, it will get a new GUID when you see it again.
Use the event UNIT_PET with the first arg being "player" to get the new GUID each time.
Also, you were missing an end, you need to make playerGUID and petGUID a local to prevent other addons from changing them, and the entering world event has login and reload boolean payloads so you don't have to unregister that event.
Lua Code:
local playerGUID, petGUID local function DummyFrame_OnEvent(self, event, ...) if event == "PLAYER_ENTERING_WORLD" then local login, reload = ... if login or reload then playerGUID = UnitGUID("player") petGUID = UnitGUID("pet") end elseif event == "UNIT_PET" then local unit = ... if unit == "player" then petGUID = UnitGUID("pet") end elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then local timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo() if (sourceGUID == playerGUID or sourceGUID == petGUID) and (destGUID ~= petGUID) and (destGUID ~= playerGUID) then print("sourceGUID "..sourceGUID) print("destGUID "..destGUID) print(timestamp.."|n") end end end DummyFrame:SetScript("OnEvent", DummyFrame_OnEvent)
|
Yeah i missed to copy that end-statement, i had it. I have the locals above, but forgot to dump the code. I had a lot of comments in the code and did'nt want to share that, and missed the end and the locals. Sorry.
This is what i had.
local playerGUID
local petGUID
local function DummyFrame_OnEvent(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then
playerGUID = UnitGUID("player")
print(playerGUID)
print(petGUID)
DummyFrame:UnregisterEvent("PLAYER_ENTERING_WORLD")
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
petGUID = UnitGUID("pet")
local timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo()
if (sourceGUID == playerGUID or sourceGUID == petGUID) and (destGUID ~=petGUID) and (destGUID ~=playerGUID) then
print("sourceGUID "..sourceGUID)
print("destGUID "..destGUID)
print(timestamp.."|n")
end
end
end
DummyFrame:SetScript("OnEvent", DummyFrame_OnEvent)
Thank you very much for your help, both of you.