Well our on load event is this:#include "aps_include"
#include "wys_i_common"
#include "wys_i_booze"
#include "x2_inc_switches"
#include "pf_autosave"
#include "pc_export_inc"
void BootPCs()
{
object oPC = GetFirstPC();
while(GetIsObjectValid(oPC))
{
BootPC(oPC);
oPC = GetNextPC();
}
}
void ClearRecentRestart( )
{
WriteTimestampedLogEntry( "[Location] Clearing RecentRestart Flag" );
DeleteLocalInt( GetModule( ), "RecentRestart" );
string sSQL = "TRUNCATE " + MODULE_PC_LOCATION_TABLE;
SQLExecDirect( sSQL );
}
void main()
{
//Added in the new shifter fix's auto save system
pc_export_onmoduleload();
// Init placeholders for ODBC gateway
SQLInit( );
WriteTimestampedLogEntry( "*** Started module " + GetModuleName( ));
// Add standard alcoholic Beverages
DelayCommand( 230.0, WysAddStdBooze( ));
//wait 5 minutes after module is started to do the first save
ExecuteScript( MODULE_NAME_INIT, OBJECT_SELF );
// Save locations of PC's
// Save characters to the vault
DelayCommand( MODULE_INITIAL_AUTOSAVE_INTERVAL * 60.0, pf_autosave( ));
//Crafting exploit
SetLocalInt( GetModule( ), "X2_L_DO_NOT_ALLOW_CRAFTSKILLS", TRUE );
if ( GetGameDifficulty( ) == GAME_DIFFICULTY_CORE_RULES || GetGameDifficulty( ) == GAME_DIFFICULTY_DIFFICULT )
{
// * Setting the switch below will enable a seperate Use Magic Device Skillcheck for
// * rogues when playing on Hardcore+ difficulty. This only applies to scrolls
SetModuleSwitch( MODULE_SWITCH_ENABLE_UMD_SCROLLS, TRUE );
// * Activating the switch below will make AOE spells hurt neutral NPCS by default
SetModuleSwitch( MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS, FALSE );
}
// * AI: Activating the switch below will make the creaures using the WalkWaypoint function
// * able to walk across areas
SetModuleSwitch( MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS, TRUE );
// * Spells: Activating the switch below will make the Glyph of Warding spell behave differently:
// * The visual glyph will disappear after 6 seconds, making them impossible to spot
// SetModuleSwitch( MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDING, TRUE);
// * Craft Feats: Want 50 charges on a newly created wand? We found this unbalancing,
// * but since it is described this way in the book, here is the switch to get it back...
// SetModuleSwitch( MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGES, TRUE);
// * Craft Feats: Use this to disable Item Creation Feats if you do not want
// * them in your module
SetModuleSwitch( MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATS, TRUE );
// * Palemaster: Deathless master touch in PnP only affects creatures up to a certain size.
// * We do not support this check for balancing reasons, but you can still activate it...
// SetModuleSwitch( MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCH, TRUE);
// * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
// * did not fit into NWNs spell system and was confusing, so we took it out...
// SetModuleSwitch( MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER, TRUE);
// * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
// * did not fit into NWNs spell system and was confusing, so we took it out...
// SetModuleSwitch( MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEAT, TRUE);
// * Spellcasting: Some people don't like caster's abusing expertise to raise their AC
// * Uncommenting this line will drop expertise mode whenever a spell is cast by a player
SetModuleSwitch( MODULE_VAR_AI_STOP_EXPERTISE_ABUSE, TRUE );
// * Item Event Scripts: The game's default event scripts allow routing of all item related events
// * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
// * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
// * is triggered. Check "x2_it_example.nss" for an example.
// * This feature is disabled by default.
SetModuleSwitch( MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE );
SetLocalString( GetModule( ), "X2_S_UD_SPELLSCRIPT", "mod_spellhook" );
SetLocalInt( GetModule( ), "RecentRestart", 1 );
DelayCommand( 600.0, ClearRecentRestart( ));
}
And our on logout event is this:
#include "pf_dupchk"
#include "k_inc_leto"
//Function that cleans up Local ints if the character has not logged back in
//This does not clean up the "death status" or hp status only spellstatus to free up memory
void Cleanup( string sName )
{
int nCount;
if ( GetLocalInt( GetModule( ), sName + "_logged" ) == 1 )
{
for ( nCount = 0; nCount <= 413; ++nCount )
{
DeleteLocalInt( GetModule( ), sName + "_Spell_" + IntToString( nCount ) + "_" );
}
DeleteLocalInt( GetModule( ), sName + "_losefeatsuses" );
}
}
void ClearDominated( object oPC )
{
effect eBuff = GetFirstEffect( oPC );
while ( GetIsEffectValid( eBuff ))
{
if ( GetEffectType( eBuff ) == EFFECT_TYPE_DOMINATED )
{
RemoveEffect( oPC, eBuff );
}
eBuff = GetNextEffect( oPC );
}
}
void main( )
{
object oPC = GetExitingObject( );
string sName = GetName( oPC );
string sAccount = GetLocalString( oPC, "AccountName" );
RemoveDupeCheckEntry( oPC );
int nSpell; //Spell interger by SPELL_* constants
int nFeat; //Feat represented by Feat_* constants
int nCount; //Number of spell casts memorized and uncast
DeleteLocalInt( GetModule( ), sName + "LoggedIn" );
SetLocalInt( GetModule( ), sName + sAccount + "_SessionActive", 2 );
//Clear dominated effect from player
ClearDominated( oPC );
SetLocalInt( GetModule( ), sName + "_hp", GetCurrentHitPoints( oPC ));
SetLocalInt( GetModule( ), sName + "_logged", 1 );
//SetLocalInt( GetModule( ), sName + "_losefeatsuses", 1 );
//Load up psudo array with spells memorized
for ( nSpell = 0; nSpell <= 413; nSpell++ )
{
nCount = GetHasSpell( nSpell ,oPC );
SetLocalInt( GetModule( ), sName + "_Spell_" + IntToString( nSpell ) + "_", nCount );
}
//Clean up Variables if player does not log in for 5 minutes
DelayCommand( 160.0, Cleanup( sName ));
DelayCommand( 1200.0, SetLocalInt( GetModule( ), sName + sAccount + "_SessionActive", 1 ));
// Leto
string Script = GetLocalString(oPC, "LetoScript");
if( Script != "" )
{
SetLocalString(oPC, "LetoScript", "");
LetoScript(Script);
}
}
You can see there are quite a few things related to clearing recent restart flags, and sessions being active or not. As I said, I am not sure of how it all works, but it does work as I described above, with regards to locations being preserved after a reset.
The core of the whole issue however, is that we need all characters to be saved just prior to restarting. I am going to try:
void pf_reset( string sModuleName )
{
WriteTimestampedLogEntry( "*** Executing restart module on " + sModuleName );
ExportAllCharacters();
DelayCommand(3.0,SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"));
}
I am wondering if the export all function I posted initially was not working because it was happening simultaneously with the reset command. I am hoping putting a delay on the reset command will allow all characters to be exported (saved.) Can anyone see any reason why this would not work?
Modifié par Lazarus Magni, 05 décembre 2012 - 09:24 .