FANDOM



What it Does Edit

This is a modified OnplayerRest Script, it allow's you to decide how often pc's may rest and whether you would like to save the character when they click rest.

Notes Edit

This goes on your modules OnPlayerRest Event

The Script Edit

// OnPlayerRest
// Written By Scarface
// Set the player resting time limit in minutes
const int RESTING_LIMIT = 5;
// Do you want players characters to be saved <span class="highlight">on</span> a full <span class="highlight">rest</span>?
const int SAVE_ON_REST = TRUE; //TRUE = YES   |   FALSE = NO
#include "x2_inc_switches"
void main()
{
    object oPC = GetLastPCRested(),
           oMod = GetModule();
    string sPlayerID = GetPCPlayerName(oPC) + GetName(oPC);
    effect eSleep = EffectVisualEffect(VFX_IMP_SLEEP);
    switch(GetLastRestEventType())
    {
        case REST_EVENTTYPE_REST_STARTED:
        {
            if (GetLocalInt(oMod, "REST_STATUS_" + sPlayerID))
            {
                AssignCommand(oPC, ClearAllActions());
                FloatingTextStringOnCreature("You may only <span class="highlight">rest</span> once per " +
                IntToString(RESTING_LIMIT) + " minutes.", oPC);
                DelayCommand(IntToFloat(RESTING_LIMIT) * 60,
                DeleteLocalInt(oMod, "REST_STATUS_" + sPlayerID));
                return;
            }
            else
            {
                SetLocalInt(oMod, "REST_STATUS_" + sPlayerID, TRUE);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eSleep, oPC);
            }
            break;
        }
        case REST_EVENTTYPE_REST_CANCELLED:
        {
            break;
        }
        case REST_EVENTTYPE_REST_FINISHED:
        {
            if (SAVE_ON_REST)
            {
                ExportSingleCharacter(oPC);
                SendMessageToPC(oPC, "<c ó ><span class="highlight">Character</span> Saved</c>");
            }
            break;
        }
    }

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.