diff --git a/CHANGELOG.md b/CHANGELOG.md index c40709f64ee..a28f60d6d44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,10 +27,11 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD - Player: ReloadColorPalettes() ### Changed -- Player: added bChatWindow parameter to FloatingTextStringOnCreature() +- Player: added bChatWindow parameter to FloatingTextStringOnCreature() - Damage: added iSpellId to the NWNX_Damage_DamageEventData struct. - Docker: Add dotnet-runtime-8.0, dotnet-apphost-pack-8.0 packages. - Item: Added parameter `bUpdateCreatureAppearance` to SetItemAppearance() to update the appearance of the item's possessor. +- Events: Added PLAYER_NAME, CDKEY as event data to the client disconnect events `NWNX_ON_CLIENT_DISCONNECT_{BEFORE|AFTER}`. ### Deprecated - DotNET: GetFunctionPointer() diff --git a/Plugins/Events/Events/ClientEvents.cpp b/Plugins/Events/Events/ClientEvents.cpp index ba14e89bf11..17beee0f5a8 100644 --- a/Plugins/Events/Events/ClientEvents.cpp +++ b/Plugins/Events/Events/ClientEvents.cpp @@ -81,8 +81,16 @@ void RemovePCFromWorldHook(CServerExoAppInternal *pServerExoAppInternal, CNWSPla { // NOTE: Events won't be processed for disconnecting characters, e.g. RemoveEffect events. // If we wanted that to happen, we'd need to process the event like CServerAIMaster__GetPendingEvent. + auto *pNetLayer = Globals::AppManager()->m_pServerExoApp->GetNetLayer(); + auto *pPlayerInfo = pNetLayer->GetPlayerInfo(pPlayer->m_nPlayerID); + auto playerName = pPlayerInfo->m_sPlayerName.CStr(); + auto cdKey = pPlayerInfo->m_lstKeys[0].sPublic.CStr(); + PushEventData("PLAYER_NAME", playerName); + PushEventData("CDKEY", cdKey); SignalEvent("NWNX_ON_CLIENT_DISCONNECT_BEFORE" , pPlayer->m_oidNWSObject); s_RemovePCFromWorldHook->CallOriginal(pServerExoAppInternal, pPlayer); + PushEventData("PLAYER_NAME", playerName); + PushEventData("CDKEY", cdKey); SignalEvent("NWNX_ON_CLIENT_DISCONNECT_AFTER", pPlayer->m_oidNWSObject); } diff --git a/Plugins/Events/NWScript/nwnx_events.nss b/Plugins/Events/NWScript/nwnx_events.nss index cd6ce5c8ec6..eeb0da46b31 100644 --- a/Plugins/Events/NWScript/nwnx_events.nss +++ b/Plugins/Events/NWScript/nwnx_events.nss @@ -562,6 +562,11 @@ _______________________________________ `OBJECT_SELF` = The player disconnecting from the server + Event Data Tag | Type | Notes + ----------------------|--------|------- + PLAYER_NAME | string | Player name of the disconnecting client + CDKEY | string | Public cdkey of the disconnecting client + @note This event also runs when a player connects to the server but cancels out of character select. OBJECT_SELF will be OBJECT_INVALID in this case.