Page 1 of 1

Prevent & log reconnect on dying

Posted: Tue Nov 18, 2003 7:05 pm
by Neve
This script logs the number of times a player logged off while dying, send him/her a message with the number of times this cheat was attempted, logs it in the logfile and sends a message to all DM's. I hope it's of any use :)

OnClientLeave :

Code: Select all

void main(){
    object oPlayer = GetExitingObject();
    int iLeavingPlayerHP = GetCurrentHitPoints(oPlayer);
    string sHPString = GetName(oPlayer) + "_Health";
    string sLogDeath = GetName(oPlayer) + "_LogDeath";

    SetLocalInt(GetModule(), sHPString, iLeavingPlayerHP);

    if(iLeavingPlayerHP <= 0){
        SetLocalInt(GetModule(), sLogDeath, GetLocalInt(GetModule(), sLogDeath) + 1);
        WriteTimestampedLogEntry("****** Player " + GetName(oPlayer) + " has logged out while dying. This was attempted " + IntToString(GetLocalInt(GetModule(), sLogDeath)) + " time(s) during this session.");
    }
}

OnClientEnter :

Code: Select all

int CheckHealth(object oPlayer){
    int iDamage = 0;
    string sLogString = GetName(oPlayer) + "_Relogged";
    string sHPString = GetName(oPlayer) + "_Health";
    string sLogDeath = GetName(oPlayer) + "_LogDeath";

    if(GetLocalInt(GetModule(), sLogString)){
        iDamage = GetMaxHitPoints(oPlayer) - GetLocalInt(GetModule(), sHPString);
        SendMessageToPC(oPlayer, "You last logged out with " + IntToString(GetLocalInt(GetModule(), sHPString)) + " remaining hitpoints.");
        SendMessageToPC(oPlayer, "You logged off " + IntToString(GetLocalInt(GetModule(), sLogDeath)) + " time(s) to prevent death.");
        SendMessageToAllDMs(GetName(oPlayer) + " logged off " + IntToString(GetLocalInt(GetModule(), sLogDeath)) + " time(s) to prevent death.");
    }
    else
        SetLocalInt(GetModule(), sLogString, 1);

    return iDamage;
}

void main(){
    object oPlayer = GetEnteringObject();

    SetPlotFlag(oPlayer, FALSE);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(CheckHealth(oPlayer)), oPlayer);
}

Posted: Tue Nov 18, 2003 8:21 pm
by Titanium Dragon
Problem is, a lot of people crash while dying too; also, if you log out while in the death script, when you log back in you keel over. This would flood the DM channel with these messages, as almost every character has crashed at least once in the death script (I know I have).

Posted: Sat Dec 13, 2003 11:22 am
by Korrigan
I made a nice working system with the native NWN database system.
If a player logs dead, he will reappear dead and at the same place, even if the server went down inbetween. Also, it manages persistant player location (you log out in a dungeon, server reboots, you still relog in the same dungeon). I use timed database flushing, so there is no lag created by this.

Neve : Send me a mail if you want the code :)