void main()
{
    // 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, "cas_meetingroom") == 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 from the player
    TakeGoldFromCreature(5000, oPC, TRUE);

    // Find the nearest door to the object used to trigger the script
    object oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF);
    if (oDoor != OBJECT_INVALID)
    {
        ActionUnlockObject(oDoor);
        SendMessageToPC(oPC, "The meeting room is now unlocked.");

        // Apply VFX to indicate the door is unlocked
        effect eKnock = EffectVisualEffect(VFX_IMP_KNOCK);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eKnock, oDoor);

        // Lock the door after 30 seconds
        DelayCommand(30.0, ActionLockObject(oDoor));
    }
    else
    {
        SendMessageToPC(oPC, "No door found to unlock.");
    }
}
