//Script Name: onclientexit
//////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On: 5/20/08 (Updated 8/10/08)
/////////////////////////////////////////
/*
This script goes in your OnClientExit
Module Properties Event for this event

*/
////////////////////////////////////////

//Required Include for SimTools
//#include "fky_chat_inc"


//PROTOTYPE DECLARED
void SendMessageToAllPC(string sMessage);

//This is used to send messages to all
//PCs on the module
/////////////////////////////////////////

//Main Script
void main()
{
ExecuteScript("prc_onleave", OBJECT_SELF);
object oPC = GetExitingObject();

if(GetIsDM(oPC))
{return; }


//Prevent Accidental Death Logging for any reason!
//If they are truly dead, then set them as dead for when they return!
if(GetIsDead(oPC))
{
//Make sure we record this kind of action...
WriteTimestampedLogEntry(GetName(oPC) + " LOGGED OUT TO CHEAT DEATH " +
GetPCPublicCDKey(oPC, FALSE) + " " + GetPCPlayerName(oPC));

SendMessageToAllDMs(GetName(oPC) + " HAS LOGGED OUT TO CHEAT DEATH");

//Temporarially Disabled...
//SetCampaignInt(GetName(GetModule()), "DEATH_LOG", 1, oPC);
}

////////////////////////////////////////////////////////////////
//DISABLED
//SimTools
/*
 Speech_OnClientExit(oPC);
    if ((VAULTPATH_CHAT != "") && (!ALREADY_USING_LETO))
    {
        string Script = GetLocalString(oPC, "LetoScript");
        if( Script != "" ) Leto(Script);
    }
*/
/////////////////////////////////////////////////////////////

if(!GetIsPC(oPC)) return;

location lMyLoc = GetLocation(oPC);

string sLeave;
sLeave = GetName(oPC);
sLeave += " / ";
sLeave += GetPCPlayerName(oPC);
sLeave += " / ";
sLeave += GetPCIPAddress(oPC);
sLeave += " / ";
sLeave += GetPCPublicCDKey(oPC);
sLeave += " /";
sLeave += "<c B+> Has left as a player.";

//Write a log entry of the info
WriteTimestampedLogEntry(sLeave);

//Send the info to all DMs online
//SendMessageToAllDMs(sLeave);

//Tell ALL the Players who just left
//SendMessageToAllPC(GetName(oPC) + " Has left this world.");


//Main Script End
}

//PROTOTYPE DEFINED
void SendMessageToAllPC(string sMessage)
{
   object oPC = GetFirstPC();
   while(GetIsObjectValid(oPC))
   {
      FloatingTextStringOnCreature(sMessage, oPC);
      oPC = GetNextPC();
   }


}