ff_u_v_rest_msg

Custom “no resting” message per area.

Replaces the “No resting is allowed in this area.” message while a PC is in the area.

Variables

ENABLE__FF_U_REST_MSG: (string) (opt-out) Set to "N" on module to disable the unit.

REST_MSG: (string) Set on area to the message to show. REST_MESSAGE is read as a fallback.

Source code

// @code

#include "ff_i_core"

const string ENABLE__FF_U_REST_MSG = "ENABLE__FF_U_REST_MSG";
const string REST_MSG = "REST_MSG";


// -----------------------------------------------------------------------------

//! @brief Set the area rest message for the entering PC.
void SetMessage();
void SetMessage()
{
  object oPC = GetEnteringObject();
  if (!GetIsPC(oPC))
    return;

  string sMessage = GetLocalString(OBJECT_SELF, REST_MSG);
  if (sMessage == "")
    sMessage = GetLocalString(OBJECT_SELF, "REST_MESSAGE");
  if (sMessage == "")
    return;

  // 10492,,,"No resting is allowed in this area."
  NWNX_Player_SetTlkOverride(oPC, 10492, sMessage, FALSE);
}


// -----------------------------------------------------------------------------

//! @brief Restore the default rest message for the exiting PC.
void RemoveMessage();
void RemoveMessage()
{
  object oPC = GetExitingObject();
  if (!GetIsPC(oPC))
    return;

  // 10492,,,"No resting is allowed in this area."
  NWNX_Player_SetTlkOverride(oPC, 10492, "", FALSE);
}


// -----------------------------------------------------------------------------

void main()
{
  string sEvent = NWNX_Events_GetCurrentEvent();
  if (sEvent == ON_REGISTER)
  {
    if (!GetModuleFlag(ENABLE__FF_U_REST_MSG, TRUE))
      return;

    SubscribeToEvent(ON_DEFAULT_AREA_ENTER, __FILE__);
    SubscribeToEvent(ON_DEFAULT_AREA_EXIT, __FILE__);
  }
  else if (sEvent == ON_DEFAULT_AREA_ENTER)
    SetMessage();
  else if (sEvent == ON_DEFAULT_AREA_EXIT)
    RemoveMessage();
}