#include "channel_include"
#include "cas_casinoinc" // for LogPotentialAbuse (or include where it's defined)

const float COOLDOWN_SECONDS = 3600.0f; // 1 hour
const string LOC_COOLDOWN = "CAS_SEX_ANNOUNCE_COOLDOWN";

void main()
{
    object oPC = GetLastUsedBy();
    if (!GetIsObjectValid(oPC) || !GetIsPC(oPC)) return;

    // Cooldown check on the placeable itself
    if (GetLocalInt(OBJECT_SELF, LOC_COOLDOWN) == 1)
    {
        SendMessageToPC(oPC, "This announcer is cooling down. Try again later.");
        return;
    }

    // Message
    string sMsg = "Someone has entered the gloryhole at the Casino of Coins.";

    // One-call wrapper that:
    //  - broadcasts locally with chat source = OBJECT_SELF (placeable name shown)
    //  - relays to other servers
    BroadcasteMessageToCustomPublicChannel()
        OBJECT_SELF,
        sMsg,
        CHANNEL_CUSTOM_PUBLIC_SEX
    );

    // Staff log of who triggered it (still logs the PC privately)
    LogPotentialAbuse(oPC, 0, 0, 0, 0, "ANNOUNCER_SEX_PLACEABLE");

    // Feedback + cooldown
    SendMessageToPC(oPC, "Announcement sent (placeable as sender, cross-server). Cooldown started.");
    SetLocalInt(OBJECT_SELF, LOC_COOLDOWN, 1);
    DelayCommand(COOLDOWN_SECONDS, DeleteLocalInt(OBJECT_SELF, LOC_COOLDOWN));
}
