144 lines
7.1 KiB
Plaintext
144 lines
7.1 KiB
Plaintext
/******************************************************************************/
|
|
/* NWNX_SYSTEM Function Include */
|
|
/******************************************************************************/
|
|
/* Copyright(c) Krynnhaven - Xanas */
|
|
/* Created: January 18, 2004 */
|
|
/* Updated: January 19, 2004 */
|
|
/******************************************************************************/
|
|
#include "string_inc"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************** Prototypes ************************************/
|
|
// Object param is used to get player name (so players can only delete their own characters
|
|
// charname is the name of the character name to delete, excluding the .bic
|
|
void DeleteCharacterFile(object oObject, string sCharName);
|
|
|
|
// As DeleteCharacterFile but for dms and use a string of player name (object is the dm)
|
|
void DMDeleteCharacterFile(object oObject, string sCharName, string sPlayerName);
|
|
|
|
// Object supplied produces the character name, players can only retrieve their own characters listing
|
|
string RetrieveCharacterFiles(object oObject);
|
|
|
|
// Same as RetrieveCharacterFiles only a string of the playername is supplied for the listing (for dm usage)
|
|
string DMRetrieveCharacterFiles(string sPlayerName);
|
|
|
|
// Same as DeleteCharacterFile but performs a backup, in example this is used previous to DeleteCommand in case of problems
|
|
void BackupCharacterFile(object oObject, string sCharName);
|
|
|
|
// Same as BackupCharacterFile but for dms, uses string of PlayerName as well
|
|
void DMBackupCharacterFile(object oObject, string sCharName, string sPlayerName);
|
|
|
|
// Handles listener commands for NWNX System - requires string_inc
|
|
void NWNXSystemCommandHandler(object oPlayer, string sParameter);
|
|
|
|
/****************************** Prototypes ************************************/
|
|
|
|
|
|
/**************************** Implementation *********************************/
|
|
void DeleteCharacterFile(object oObject, string sCharName)
|
|
{
|
|
string sPlayerName = GetPCPlayerName(oObject);
|
|
DelayCommand(5.0, SetLocalString(oObject, "NWNX!SYSTEM!DELETE", "./servervault/"+sPlayerName+"/"+sCharName+".bic"));
|
|
}
|
|
string RetrieveCharacterFiles(object oObject)
|
|
{
|
|
string sPlayerName = GetPCPlayerName(oObject);
|
|
// long long string for storage buffering.
|
|
SetLocalString(GetModule(), "NWNX!SYSTEM!RETRIEVE", sPlayerName+"! "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" ");
|
|
string sCharReturn = GetLocalString(GetModule(), "NWNX!SYSTEM!RETRIEVE");
|
|
if(sCharReturn == "")
|
|
{
|
|
sCharReturn = "Call this again to retrieve character files";
|
|
}
|
|
return sCharReturn;
|
|
}
|
|
void BackupCharacterFile(object oObject, string sCharName)
|
|
{
|
|
string sPlayerName = GetPCPlayerName(oObject);
|
|
SetLocalString(oObject, "NWNX!SYSTEM!BACKUP", sPlayerName+"/"+sCharName+".bic");
|
|
}
|
|
|
|
void DMDeleteCharacterFile(object oObject, string sCharName, string sPlayerName)
|
|
{
|
|
DelayCommand(5.0, SetLocalString(oObject, "NWNX!SYSTEM!DELETE", "./servervault/"+sPlayerName+"/"+sCharName+".bic"));
|
|
}
|
|
|
|
void DMBackupCharacterFile(object oObject, string sCharName, string sPlayerName)
|
|
{
|
|
SetLocalString(oObject, "NWNX!SYSTEM!BACKUP", sPlayerName+"/"+sCharName+".bic");
|
|
}
|
|
string DMRetrieveCharacterFiles(string sPlayerName)
|
|
{
|
|
SetLocalString(GetModule(), "NWNX!SYSTEM!RETRIEVE", sPlayerName+"! "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" "+
|
|
" ");
|
|
string sCharReturn = GetLocalString(GetModule(), "NWNX!SYSTEM!RETRIEVE");
|
|
if(sCharReturn == "")
|
|
{
|
|
sCharReturn = "Call this again to retrieve character files";
|
|
}
|
|
return sCharReturn;
|
|
}
|
|
void NWNXSystemCommandHandler(object oPlayer, string sParameter)
|
|
{
|
|
if(GetStringLeft(sParameter, 4) == "list" || GetStringLeft(sParameter, 4) == "help")
|
|
{
|
|
SendMessageToPC(oPlayer, "nwnx::DeleteMyChar CharNameToDelete (don't use bic extension) \n"+
|
|
"nwnx::ListMyChars (lists chars in your folder \n"+
|
|
"nwnx::ListPlayerChars PlayerName (lists players chars - dm tool) \n"+
|
|
"nwnx::DeletePlayerChar PlayerName CharName (don't use bic extension");
|
|
return;
|
|
}
|
|
if(GetStringLeft(sParameter, 12) == "DeleteMyChar")
|
|
{
|
|
BackupCharacterFile(oPlayer, ReturnWord(sParameter, 2));
|
|
DeleteCharacterFile(oPlayer, ReturnWord(sParameter, 2));
|
|
SendMessageToPC(oPlayer, "Character with name "+sParameter+" deleted");
|
|
return;
|
|
}
|
|
if(GetStringLeft(sParameter, 11) == "ListMyChars")
|
|
{
|
|
SendMessageToPC(oPlayer, RetrieveCharacterFiles(oPlayer));
|
|
return;
|
|
}
|
|
if(GetStringLeft(sParameter, 16) == "DeletePlayerChar" && GetIsDM(oPlayer))
|
|
{
|
|
string sParam1 = ReturnWord(sParameter, 2);
|
|
string sParam2 = ReturnWord(sParameter, 3);
|
|
DMBackupCharacterFile(oPlayer, sParam2, sParam1);
|
|
DMDeleteCharacterFile(oPlayer, sParam2, sParam1);
|
|
SendMessageToPC(oPlayer, "Character with name "+sParam1+" deleted from folder of player "+sParam2);
|
|
return;
|
|
}
|
|
|
|
if(GetStringLeft(sParameter, 15) == "ListPlayerChars" && GetIsDM(oPlayer))
|
|
{
|
|
string sParam = ReturnWord(sParameter, 2);
|
|
SendMessageToPC(oPlayer, DMRetrieveCharacterFiles(sParam));
|
|
SendMessageToPC(oPlayer, "Retrieving "+sParam);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**************************** Implementation *********************************/
|
|
|