Prevent & log reconnect on dying
Posted: 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 :
OnClientEnter :

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);
}