mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
80 lines
2.1 KiB
Plaintext
80 lines
2.1 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// player.player_logout.script
|
|
//
|
|
//
|
|
// ======================================================================
|
|
|
|
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;
|
|
}
|
|
|
|
// ======================================================================
|
|
|