Bell ring -

Need a script I can put on the area that will toll a bell every 4 hours. No Idea where to begin as its got to keep track of the time on the server as well

Help Please?

here’s an idea …

// 'tollbell4hr'
//
// in the Heartbeat of the area

void main()
{
    object oArea = OBJECT_SELF;

    if (!GetTimeHour() % 4) // true when the hour is evenly divisible by 4
    {
        if (!GetLocalInt(oArea, "BellTolled"))
        {
            SetLocalInt(oArea, "BellTolled", TRUE); // only once per 4 hrs

            object oBell = GetObjectByTag("tollbell"); // placed sound object
            SoundObjectPlay(oBell);
        }
    }
    else
        SetLocalInt(oArea, "BellTolled", FALSE);
}

alternately, if every player in the area has to hear the bell (ie, if a sound-object is too localized) it could play a sound on each controlled character perhaps. But i’m unsure what you mean by “keep track of time on the server” - why not just the gametime

needs to be heard in the entire area they are in not just in a local spot . I will see if one sound object will cover the majority of the area. Skullport keeps time by tolling bells every 4 hours to mark the quarter day.
its a PW so server is up most the time but game time is probably fine now that I think about it .

Thanks

I think the quarter day is every 6 hrs but feel free to disagree

// 'tollbell6hr'
/*
    in the Heartbeat of the area
    Plays a sound resource on each controlled-character in the Area.
*/

void main()
{
    if (!GetTimeHour() % 6) // true when the hour is evenly divisible by 6
    {
        object oArea = OBJECT_SELF;
        if (!GetLocalInt(oArea, "BellTolled"))
        {
            SetLocalInt(oArea, "BellTolled", TRUE); // only once on the hour

//          object oBell = GetObjectByTag("tollbell"); // placed sound object
//          SoundObjectPlay(oBell);

            // play sound as an Action for all players
            // note: PlaySound() is an action - it's not instant.

            object oPC = GetFirstPC(FALSE);
            while (GetIsObjectValid(oPC))
            {
                if (GetArea(oPC) == oArea)
                {
                    AssignCommand(oPC, PlaySound("tollbell")); // sound file resource
                }
                oPC = GetNextPC(FALSE);
            }
        }
    }
    else
        SetLocalInt(OBJECT_SELF, "BellTolled", FALSE);
}

if you really want every 4 hours, just change “6” back to “4”. i’m not sure it’ll work as-is but it might …

if it does, it could get kinda loud if say a party of 6 PCs are huddled together

To get a sound to play across the area, I think you can make it a sound object and then disable ‘Positional?’ in the blueprint.

that’s a much better idea, even several sound-objects sprinkled in an area is better than playing sound directly on the PCs

I did this for a 6 hour bell in TLoS. It was done with a placeable sound as Rjs suggested. Change it to not positional and you will hear it over the whole area.

PJ