void main()
{
    // Define the tag of the door
    string sDoorTag = "CAS_MEETINGROOM";

    // Get the area of the object that triggered this script
    object oArea = GetArea(OBJECT_SELF);

    // Iterate through all objects in the area to check if someone is in a meeting
    object oCurrentObject = GetFirstObjectInArea(oArea);
    while (oCurrentObject != OBJECT_INVALID)
    {
        if (GetIsPC(oCurrentObject) && GetLocalInt(oCurrentObject, "iAmInMeeting") == 1)
        {
            // Inform the user that the meeting room is in use
            SendMessageToPC(GetLastUsedBy(), "Someone is in the meeting room, it cannot be used.");
            return;
        }
        oCurrentObject = GetNextObjectInArea(oArea);
    }

    // Check if the player has enough gold
    object oPC = GetLastUsedBy();
    if (GetGold(oPC) < 5000)
    {
        SendMessageToPC(oPC, "You need 5,000 gold to use the meeting room.");
        return;
    }

    // Deduct gold and unlock the door
    TakeGoldFromCreature(5000, oPC, TRUE);
    object oDoor = GetNearestObjectByTag(sDoorTag, OBJECT_SELF);
    if (oDoor != OBJECT_INVALID)
    {
        ActionUnLockObject(oDoor);
        SendMessageToPC(oPC, "The meeting room is now unlocked.");

        // Lock the door after 30 seconds
        DelayCommand(30.0, ActionLockObject(oDoor));
    }
}
