void main() { object oPlayer = GetLastPCRested(); if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED) { effect eSleep = EffectVisualEffect(VFX_IMP_SLEEP); int iLastHourRest = GetLocalInt(oPlayer, "LastHourRest"); int iLastDayRest = GetLocalInt(oPlayer, "LastDayRest"); int iLastYearRest = GetLocalInt(oPlayer, "LastYearRest"); int iLastMonthRest = GetLocalInt(oPlayer, "LastMonthRest"); int iHour = GetTimeHour(); int iDay = GetCalendarDay(); int iYear = GetCalendarYear(); int iMonth = GetCalendarMonth(); int iHowLong = 0; int iSum = iLastHourRest + iLastDayRest + iLastYearRest + iLastMonthRest; if (iLastYearRest != iYear) iMonth = iMonth + 12; if (iLastMonthRest != iMonth) iDay = iDay + 28; if (iDay != iLastDayRest) iHour = iHour + 24 * (iDay - iLastDayRest); iHowLong = iHour - iLastHourRest; if ((iHowLong < 8) && (iSum != 0)) { AssignCommand(oPlayer, ClearAllActions()); string msg = "You may rest again in " + IntToString(8-iHowLong) + " hours."; SendMessageToPC(oPlayer, msg); } else { ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, oPlayer, 7.0); DelayCommand(9.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, oPlayer, 7.0)); } } else if (GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED) { SetLocalInt(oPlayer, "LastHourRest", GetTimeHour()); SetLocalInt(oPlayer, "LastDayRest", GetCalendarDay()); SetLocalInt(oPlayer, "LastMonthRest", GetCalendarMonth()); SetLocalInt(oPlayer, "LastYearRest", GetCalendarYear()); } }