Skip to content

Commit 9b93e74

Browse files
committed
NWNX_Vault
1 parent 3720d0e commit 9b93e74

File tree

5 files changed

+1344
-0
lines changed

5 files changed

+1344
-0
lines changed

Core/NWNXCore.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ void NWNXCore::CreateServerHandler(CAppManager* app)
613613

614614
g_core->m_createServerHook.reset();
615615
app->CreateServer();
616+
MessageBus::Broadcast("NWNX_CORE_SIGNAL", { "ON_CREATE_SERVER" });
616617
}
617618

618619
void NWNXCore::DestroyServerHandler(CAppManager* app)

Plugins/Vault/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_plugin(Vault "Vault.cpp")
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/// @addtogroup vault Vault
2+
/// @brief Provides various character/servervault related functions.
3+
/// @{
4+
/// @file nwnx_vault.nss
5+
#include "nwnx"
6+
7+
const string NWNX_Vault = "NWNX_Vault"; ///< @private
8+
9+
/// @name Vault Event Types
10+
/// @anchor vault_event_types
11+
/// @{
12+
const int NWNX_VAULT_EVENT_TYPE_CREATED = 1;
13+
const int NWNX_VAULT_EVENT_TYPE_LOGIN = 2;
14+
const int NWNX_VAULT_EVENT_TYPE_LOGOUT = 3;
15+
const int NWNX_VAULT_EVENT_TYPE_MIGRATED = 4;
16+
/// @}
17+
18+
/// @brief Switch oPlayer's character to another one.
19+
/// @warning THIS FUNCTION IS EXPERIMENTAL, BACKUP YOUR SERVERVAULT BEFORE EVEN ATTEMPTING TO USE THIS.
20+
/// @note If something goes catastrophically wrong the player will be disconnected.
21+
/// @param oPlayer The player.
22+
/// @param nCharacterId The Id of the character in the server vault database.
23+
/// @param bSaveCurrentCharacter TRUE to save the current character.
24+
void NWNX_Vault_SwitchCharacter(object oPlayer, int nCharacterId, int bSaveCurrentCharacter = TRUE);
25+
26+
// @brief Get oPlayer's character as json.
27+
// @param oPlayer A player character.
28+
// @return The player character as json or JsonNull().
29+
json NWNX_Vault_GetCharacterJson(object oPlayer);
30+
31+
/// @}
32+
33+
void NWNX_Vault_SwitchCharacter(object oPlayer, int nCharacterId, int bSaveCurrentCharacter = TRUE)
34+
{
35+
NWNX_PushArgumentInt(bSaveCurrentCharacter);
36+
NWNX_PushArgumentInt(nCharacterId);
37+
NWNX_PushArgumentObject(oPlayer);
38+
NWNX_CallFunction(NWNX_Vault, "SwitchCharacter");
39+
}
40+
41+
json NWNX_Vault_GetCharacterJson(object oPlayer)
42+
{
43+
NWNX_PushArgumentObject(oPlayer);
44+
NWNX_CallFunction(NWNX_Vault, "GetCharacterJson");
45+
return NWNX_GetReturnValueJson();
46+
}

Plugins/Vault/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page vault Readme
2+
@ingroup vault
3+
4+
Provides various character/servervault functions.
5+
6+
## NWNX_Vault_SwitchCharacter Notes
7+
8+
### Before even attempting to do anything with this function, make sure to (regularly) backup your servervault. You have been warned.
9+
10+
Things of note:
11+
12+
* **Backup your servervault.**
13+
* Will disconnect the player if something goes catastrophically wrong.
14+
* OnClientEnter/Leave and OnAreaEnter/Exit will fire for the appropriate creature objects.
15+
* Players will switch characters on the spot, it's up to you to move them if needed.
16+
* Probably has weird quirks and/or bugs.

0 commit comments

Comments
 (0)