|
| 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 | +} |
0 commit comments