View Single Post
06-17-20, 11:49 AM   #10
millo666
A Murloc Raider
Join Date: Jun 2020
Posts: 7
Originally Posted by Kanegasi View Post
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:
  1. local playerGUID, petGUID
  2. local function DummyFrame_OnEvent(self, event, ...)
  3.     if event == "PLAYER_ENTERING_WORLD" then
  4.         local login, reload = ...
  5.         if login or reload then
  6.             playerGUID = UnitGUID("player")
  7.             petGUID = UnitGUID("pet")
  8.         end
  9.     elseif event == "UNIT_PET" then
  10.         local unit = ...
  11.         if unit == "player" then
  12.             petGUID = UnitGUID("pet")
  13.         end
  14.     elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
  15.         local timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo()
  16.         if (sourceGUID == playerGUID or sourceGUID == petGUID) and (destGUID ~= petGUID) and (destGUID ~= playerGUID) then
  17.             print("sourceGUID "..sourceGUID)
  18.             print("destGUID "..destGUID)
  19.             print(timestamp.."|n")
  20.         end
  21.     end
  22. end
  23. 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.
  Reply With Quote