Restrict how often PC's can rest[edit | edit source]

This script will allow you to set how many minutes of real time must pass between rests. Note that real time minutes and game minutes are actually the same, and the same for seconds. The difference comes in when going from minutes to hours. This script takes this into account with the HoursToSeconds function:

// By Orion Light
// Gets the current time in minutes as an integer
int GetTotalTimeMinutes()
int nTimeMinutes;// Declaring a variable
int nMinutes = GetTimeMinute();// get number of minutes
int nHours = GetTimeHour();// get hours
int nDays = GetCalendarDay();// Get days
int nMonths = GetCalendarMonth();// Get months
int nYears = GetCalendarYear();// Get years
float fMinutesPerHour = HoursToSeconds(1);// Get number of seconds in 1 hour
int nMinutesPerHour = FloatToInt(fMinutesPerHour);// Change to int
nMinutesPerHour /= 60;// Divide by 60 to get minutes in an hour
// If you don't do this, any variance in the module hours/minutes can mess it up
nHours *= nMinutesPerHour;// Convert hours into minutes
nDays *= (nMinutesPerHour * 24);// Convert days into minutes
nMonths *= (nMinutesPerHour * 672);// Convert months into minutes
nYears *= (nMinutesPerHour * 8064);// Convert years into minutes
nTimeMinutes = (nMinutes + nHours + nDays + nMonths + nYears);// Add all together
return nTimeMinutes;// The return of the function is the total number of minutes
// Does not allow rest untill nLimit minutes have passed
// Cancelled rest counts as rest and will reset the timer
void main()
object oPC = GetLastPCRested();// Gets the PC
int nRestType = GetLastRestEventType();// Get the last rest event type
int nTotalTimeMinutes = GetTotalTimeMinutes();// Record the current time
int nLastRestTimeMinutes = GetLocalInt(oPC, "lastrested");// Check when PC last rested
int nTimeElapsed = (nTotalTimeMinutes - nLastRestTimeMinutes);// Get the difference
int nTimeLeft = (nLimit - nTimeElapsed);// Calculate how long left untill rest allowed
if (nRestType == REST_EVENTTYPE_REST_STARTED)// If rest just started
    if (nTimeElapsed < nLimit)// And elapsed time is less than the limit allowed
        AssignCommand(oPC, ClearAllActions());// Cancel the rest
        SendMessageToPC(oPC, "You may not rest for " + IntToString(nTimeLeft) + " minutes");
        // Sends the PC a message
if ((nRestType = REST_EVENTTYPE_REST_FINISHED) && (nTimeElapsed >= nLimit))
// If rest is finished and time elapsed is greater than time allowed
// Prevents the timer resetting if rest was cancelled because of the limit
    SetLocalInt(oPC, "lastrested", GetTotalTimeMinutes());
    // Set the time PC rested as a local int

There are simpler ways to do it, but this method allows feedback on how long it will be untill being allowed to rest.

Community content is available under CC-BY-SA unless otherwise noted.