Ok, here's what I've done for now but I still don't understand why it doesn't work without a server reset...
OnClientEnter#include "inc_database"
void main()
{
object oPC = GetEnteringObject();
if (GetLocalInt(GetModule(), "PW") == TRUE && NBDE_GetCampaignInt(DATA_NAME, "ExistingPlayer", oPC) == TRUE && !GetIsDM(oPC))
{
SetPlotFlag(oPC, FALSE);
SetImmortal(oPC, FALSE);
DelayCommand(0.2, DB_RestorePlayerStatus(oPC));
}
}
The "Save" functionvoid DB_SavePCStatus(object oPC, string sDatabase = DATA_NAME)
{
object oModule;
string sKey;
int nHP;
int bDead;
int nLastrest;
int nFatigue;
int nIvresse;
int nMort;
int nTues;
int nHD;
float fCR;
string sNom;
location lLocation;
location lDeathloc;
location lLasttown;
if (!GetIsDM(oPC) || !GetIsDMPossessed(oPC))
oModule = GetModule();
sKey = GetPCPlayerName(oPC) + GetName(oPC);
nHP = GetCurrentHitPoints(oPC);
bDead = GetIsDead(oPC);
nLastrest = GetTotalHours() - GetLocalInt(oPC, "lastrest");
nFatigue = GetLocalInt(oPC, "fatigue");
nIvresse = GetLocalInt(oPC, "ivresse");
nMort = GetLocalInt(oPC, "NW_L_PLAYER_DIED");
nTues = GetLocalInt(oPC, "nombretues");
nHD = GetLocalInt(oPC, "HD");
fCR = GetLocalFloat(oPC, "CR");
sNom = GetLocalString(oPC, "nommeilleur");
lLocation = GetLocation(oPC);
lDeathloc = GetLocalLocation(oPC, "ls_death_loc");
lLasttown = GetLocalLocation(oPC, "ls_town_loc");
SetLocalInt(oModule, sKey + "Present", TRUE);
SetLocalInt(oModule, sKey + "Current_HP", nHP);
SetLocalInt(oModule, sKey + "Dead", bDead);
NBDE_SetCampaignInt(sDatabase, "Current_HP", nHP, oPC);
NBDE_SetCampaignInt(sDatabase, "Dead", bDead, oPC);
NBDE_SetCampaignInt(sDatabase, "Lastrest", nLastrest, oPC);
NBDE_SetCampaignInt(sDatabase, "Fatigue", nFatigue, oPC);
NBDE_SetCampaignInt(sDatabase, "Ivresse", nIvresse, oPC);
NBDE_SetCampaignInt(sDatabase, "Morts", nMort, oPC);
NBDE_SetCampaignInt(sDatabase, "Tues", nTues, oPC);
NBDE_SetCampaignInt(sDatabase, "Best_HD", nHD, oPC);
NBDE_SetCampaignFloat(sDatabase, "Best_CR", fCR, oPC);
NBDE_SetCampaignString(sDatabase, "Best_Nom", sNom, oPC);
NBDE_SetCampaignLocation(sDatabase, "Location", lLocation, oPC);
NBDE_SetCampaignLocation(sDatabase, "Deathloc", lDeathloc, oPC);
NBDE_SetCampaignLocation(sDatabase, "Lasttown", lLasttown, oPC);
ExportSingleCharacter(oPC);
}
The "Restore" functionvoid DB_RestorePlayer(object oPC, string sDatabase = DATA_NAME)
{
int nHP;
int bDead;
int nHPmax = GetMaxHitPoints(oPC);
object oModule = GetModule();
string sKey = GetPCPlayerName(oPC) + GetName(oPC);
if (GetLocalInt(oModule, sKey + "Present") == TRUE)
{
nHP = GetLocalInt(oModule, sKey + "Current_HP");
bDead = GetLocalInt(oModule, sKey + "Dead");
}
else
{
nHP = NBDE_GetCampaignInt(sDatabase, "Current_HP", oPC);
bDead = NBDE_GetCampaignInt(sDatabase, "Dead", oPC);
}
int nLastrest = GetTotalHours() - NBDE_GetCampaignInt(sDatabase, "Lastrest", oPC);
int nFatigue = NBDE_GetCampaignInt(sDatabase, "Fatigue", oPC);
int nIvresse = NBDE_GetCampaignInt(sDatabase, "Ivresse", oPC);
int nMort = NBDE_GetCampaignInt(sDatabase, "Morts", oPC);
int nTues = NBDE_GetCampaignInt(sDatabase, "Tues", oPC);
int nHD = NBDE_GetCampaignInt(sDatabase, "Best_HD", oPC);
float fCR = NBDE_GetCampaignFloat(sDatabase, "Best_CR", oPC);
string sNom = NBDE_GetCampaignString(sDatabase, "Best_Nom", oPC);
location lLocation = NBDE_GetCampaignLocation(sDatabase, "Location", oPC);
location lDeathloc = NBDE_GetCampaignLocation(sDatabase, "Deathloc", oPC);
location lLasttown = NBDE_GetCampaignLocation(sDatabase, "Lasttown", oPC);
effect eEffect;
RebuildJournalQuestEntries(oPC);
SetLocalInt(oPC, "lastrest", nLastrest);
SetLocalInt(oPC, "fatigue", nFatigue);
SetLocalInt(oPC, "ivresse", nIvresse);
SetLocalInt(oPC, "NW_L_PLAYER_DIED", nMort);
SetLocalInt(oPC, "nombretues", nTues);
SetLocalInt(oPC, "HD", nHD);
SetLocalFloat(oPC, "CR", fCR);
SetLocalString(oPC, "nommeilleur", sNom);
SetLocalLocation(oPC, "ls_death_loc", lDeathloc);
SetLocalLocation(oPC, "ls_town_loc", lLasttown);
if (nFatigue == 1)
{
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_STRENGTH, 2));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_DEXTERITY, 2));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
SendMessageToPC(oPC, "Vous vous sentez fatigue, un peu de repos serait profitable!");
}
else if (nFatigue == 2)
{
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_STRENGTH, 4));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_DEXTERITY, 4));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
eEffect = ExtraordinaryEffect(EffectMovementSpeedDecrease(20));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
SendMessageToPC(oPC, "Vous vous sentez epuise, un peu de repos serait profitable!");
}
else if (nFatigue == 3)
{
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_STRENGTH, 6));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
eEffect = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_DEXTERITY, 6));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
eEffect = ExtraordinaryEffect(EffectMovementSpeedDecrease(40));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
SendMessageToPC(oPC, "Vous vous sentez a bout de forces, un peu de repos serait profitable!");
}
if (GetIsObjectValid(GetAreaFromLocation(lLocation)))
{
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionJumpToLocation(lLocation));
}
if (nHP != nHPmax && bDead == FALSE) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nHPmax - nHP, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_TWENTY), oPC);
else if (bDead == TRUE)
{
SetLocalInt(oPC, "Auto_Dead", TRUE);
DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oPC));
}
CheckIvresse(oPC);
SendMessageToPC(oPC, "Session restaurée!");
}
////////////////////////////////////////////////////////////////////////////////
void DB_RestorePlayerStatus(object oPC, string sDatabase = DATA_NAME)
{
object oArea = GetArea(oPC);
if (!GetIsObjectValid(oArea)) DelayCommand(0.1, DB_RestorePlayerStatus(oPC, sDatabase));
else DB_RestorePlayer(oPC, sDatabase);
}
As mentionned earlier, the database is effectively flushed every minute (using NBDE by knat)
If anyone sees the issue in my scripts please I'm really getting dissapointed