Author Sticky: Post Working Scripts Here
Mortok Posted: Sunday, 07 July 10:47PM
1. Easy Chest Contents Respawn

2. 1 Single script to respawn items in a chest after certain time.

3. Just use this script in the OnDeath and OnOpen Event of your script. It will check the ingame hour to see if it's time to refill the chest

NWScript:
#include "NW_O2_CONINCLUDE"

void main()

{

    if(GetFirstItemInInventory(OBJECT_SELF) != OBJECT_INVALID) {

        return;

    }

    object oLastOpener = GetLastOpener();

    if ((GetLocalInt(OBJECT_SELF,"NW_INITIALISED") == 0)||(GetLocalInt(OBJECT_SELF,"NW_NEXT_TIME") < GetTimeHour()))

    {

        GenerateMediumTreasure(oLastOpener, OBJECT_SELF);

        int nextTime = (GetTimeHour()+5);//Loot will respawn after 5 game hours. Replace with whatever interval you need.

        if(nextTime >= 24) {

            nextTime = nextTime - 24;

        }

        SetLocalInt(OBJECT_SELF,"NW_NEXT_TIME",nextTime);

        SetLocalInt(OBJECT_SELF,"NW_INITIALISED",1);

        ShoutDisturbed();

    }

}