Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/NWNXCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ void NWNXCore::CreateServerHandler(CAppManager* app)

g_core->m_createServerHook.reset();
app->CreateServer();
MessageBus::Broadcast("NWNX_CORE_SIGNAL", { "ON_CREATE_SERVER" });
}

void NWNXCore::DestroyServerHandler(CAppManager* app)
Expand Down
1 change: 1 addition & 0 deletions Plugins/Vault/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_plugin(Vault "Vault.cpp")
46 changes: 46 additions & 0 deletions Plugins/Vault/NWScript/nwnx_vault.nss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// @addtogroup vault Vault
/// @brief Provides various character/servervault related functions.
/// @{
/// @file nwnx_vault.nss
#include "nwnx"

const string NWNX_Vault = "NWNX_Vault"; ///< @private

/// @name Vault Event Types
/// @anchor vault_event_types
/// @{
const int NWNX_VAULT_EVENT_TYPE_CREATED = 1;
const int NWNX_VAULT_EVENT_TYPE_LOGIN = 2;
const int NWNX_VAULT_EVENT_TYPE_LOGOUT = 3;
const int NWNX_VAULT_EVENT_TYPE_MIGRATED = 4;
/// @}

/// @brief Switch oPlayer's character to another one.
/// @warning THIS FUNCTION IS EXPERIMENTAL, BACKUP YOUR SERVERVAULT BEFORE EVEN ATTEMPTING TO USE THIS.
/// @note If something goes catastrophically wrong the player will be disconnected.
/// @param oPlayer The player.
/// @param nCharacterId The Id of the character in the server vault database.
/// @param bSaveCurrentCharacter TRUE to save the current character.
void NWNX_Vault_SwitchCharacter(object oPlayer, int nCharacterId, int bSaveCurrentCharacter = TRUE);

// @brief Get oPlayer's character as json.
// @param oPlayer A player character.
// @return The player character as json or JsonNull().
json NWNX_Vault_GetCharacterJson(object oPlayer);

/// @}

void NWNX_Vault_SwitchCharacter(object oPlayer, int nCharacterId, int bSaveCurrentCharacter = TRUE)
{
NWNXPushInt(bSaveCurrentCharacter);
NWNXPushInt(nCharacterId);
NWNXPushObject(oPlayer);
NWNXCall(NWNX_Vault, "SwitchCharacter");
}

json NWNX_Vault_GetCharacterJson(object oPlayer)
{
NWNXPushObject(oPlayer);
NWNXCall(NWNX_Vault, "GetCharacterJson");
return NWNXPopJson();
}
16 changes: 16 additions & 0 deletions Plugins/Vault/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@page vault Readme
@ingroup vault

Provides various character/servervault functions.

## NWNX_Vault_SwitchCharacter Notes

### Before even attempting to do anything with this function, make sure to (regularly) backup your servervault. You have been warned.

Things of note:

* **Backup your servervault.**
* Will disconnect the player if something goes catastrophically wrong.
* OnClientEnter/Leave and OnAreaEnter/Exit will fire for the appropriate creature objects.
* Players will switch characters on the spot, it's up to you to move them if needed.
* Probably has weird quirks and/or bugs.
Loading