Thread Tools Display Modes
08-19-23, 10:38 AM   #1
Robotron
A Murloc Raider
Join Date: May 2020
Posts: 5
Angry How to do something on logout?

How to do something on logout?
Code:
Frame:SetScript("OnEvent", function(this, event, ...)
  if event=="PLAYER_LEAVING_WORLD" then
    SendChatMessage("1", "PARTY")
  end
end)
Frame:RegisterEvent("PLAYER_LEAVING_WORLD")
Seems this code is not triggering at all.
  Reply With Quote
08-19-23, 11:46 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
You've probably left the party (automatically removed by the game) before the SendMessage is processed.

Try the following to whisper yourself when you do a /reload (or logout but...).
Change the target character name to your logged in character.

Lua Code:
  1. local Frame = CreateFrame("frame")
  2. Frame:SetScript("OnEvent", function(this, event, ...)
  3.     SendChatMessage("Bye!", "WHISPER", nil, "YourCharacter")
  4.   end
  5. end)
  6. Frame:RegisterEvent("PLAYER_LEAVING_WORLD")
It should show the message when you've entered the world after /reload
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-19-23 at 12:23 PM.
  Reply With Quote
08-20-23, 09:18 AM   #3
Robotron
A Murloc Raider
Join Date: May 2020
Posts: 5
Angry

This code works with a /reload, but it doesn't work on logount.
In my case, i need to leave the party (C_PartyInfo.LeaveParty()), but this code simply doesn't execute for either "PLAYER_LEAVING_WORLD" or "PLAYER_LOGOUT" event.
  Reply With Quote
08-20-23, 11:51 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Originally Posted by Robotron View Post
This code works with a /reload, but it doesn't work on logount.
In my case, i need to leave the party (C_PartyInfo.LeaveParty()), but this code simply doesn't execute for either "PLAYER_LEAVING_WORLD" or "PLAYER_LOGOUT" event.
Maybe reverse the logic, a macro/secure button that sends the message if you're in a party and then logs you out.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-20-23 at 03:04 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to do something on logout?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off