Files
dsrc/sku.0/sys.server/compiled/game/script/player/player_logout.script
T
2013-09-10 23:17:15 -07:00

81 lines
2.1 KiB
Plaintext

// ======================================================================
//
// player.player_logout.script
//
// Copyright 2002 Sony Online Entertainment
//
// ======================================================================
const string_id SID_LOGOUT_TIME_LEFT = new string_id("logout", "time_left");
const string_id SID_LOGOUT_SAFE_TO_LOG_OUT = new string_id("logout", "safe_to_log_out");
const string_id SID_LOGOUT_ABORTED = new string_id("logout", "aborted");
const string_id SID_LOGOUT_MUST_BE_SITTING = new string_id("logout", "must_be_sitting");
// ======================================================================
trigger OnInitialize()
{
removeObjVar(self, "safeLogout");
detachScript(self, "player.player_logout");
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnLogin()
{
removeObjVar(self, "safeLogout");
detachScript(self, "player.player_logout");
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnEnteredCombat()
{
abortLogout(self);
return SCRIPT_CONTINUE;
}
// ======================================================================
void abortLogout(obj_id self)
{
sendSystemMessage(self, SID_LOGOUT_ABORTED);
detachScript(self, "player.player_logout");
}
// ======================================================================
messageHandler OnLogoutPulse()
{
if (getPosture(self) != POSTURE_SITTING)
{
sendSystemMessage(self, SID_LOGOUT_MUST_BE_SITTING);
abortLogout(self);
}
else
{
int timeLeft = params.getInt("timeLeft");
int countInterval = params.getInt("countInterval");
if (timeLeft <= 0)
{
setObjVar(self, "safeLogout", 1);
disconnectPlayer(self);
}
else
{
prose_package pp = new prose_package();
pp.stringId = SID_LOGOUT_TIME_LEFT;
pp.digitInteger = timeLeft;
sendSystemMessageProse(self, pp);
params.put("timeLeft", timeLeft-countInterval);
messageTo(self, "OnLogoutPulse", params, countInterval, false);
}
}
return SCRIPT_CONTINUE;
}
// ======================================================================