Prevent & log reconnect on dying

Moderator: Event DM

Post Reply
User avatar
Neve
Prince of Bloated Discourse
Posts: 192
Joined: Mon Apr 14, 2003 4:09 pm
Location: The Netherlands
Contact:

Prevent & log reconnect on dying

Post by Neve » Tue Nov 18, 2003 7:05 pm

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);
}
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
User avatar
Titanium Dragon
Sage
Posts: 2916
Joined: Sun Apr 27, 2003 5:18 pm
Location: Corvallis, OR (GMT - 7)
Contact:

Post by Titanium Dragon » Tue Nov 18, 2003 8:21 pm

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).
User avatar
Korrigan
Prince of Bloated Discourse
Posts: 280
Joined: Sat Apr 12, 2003 4:21 pm
Location: Jester of the Fey Vivian, Lady of the Lake ...

Post by Korrigan » Sat Dec 13, 2003 11:22 am

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 :)
Post Reply