Ah okay, I got it now! Turns out there is an error in Morrowind where AddItem doesn't always work on empty containers. This is apparently a well known issue (which I've never heard of before lol), and it's descriped http://www.uesp.net/wiki/Tes3Mod:AddItem in detail.
So this is why the chest just stopped functioning after the player took all gold from it, because it was empty. The script was still running and completing everything it was supposed to, but AddItem didn't work so no new gold could be added to the chest.
The way I've come up with to get around this issue is to disable the chest entirely after the player steals all gold from it, and replace it with another identical chest that only contains the steal note.
There are 3 scripts, now. The first one is attached to the chest itself:
Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( PE_LlavamGoldChestChange >= 1 ) Returnendifset PE_LlavamGoldChestChange to 1StartScript, "PE_LlavamGoldChestscript_g"if ( local_day == Day ) Returnendifset local_day to Dayif ( GetItemCount, "gold_001" == 0 ) if ( local_gold != 0 ) set PE_LlavamGoldChestChange to 2 Disable Return endifendifif ( local_gold == 10 ) RemoveItem, "gold_001", 2147elseif ( local_gold == 9 ) RemoveItem, "gold_001", 1836elseif ( local_gold == 8 ) RemoveItem, "gold_001", 1705elseif ( local_gold == 7 ) RemoveItem, "gold_001", 1589elseif ( local_gold == 6 ) RemoveItem, "gold_001", 1262elseif ( local_gold == 5 ) RemoveItem, "gold_001", 1018elseif ( local_gold == 4 ) RemoveItem, "gold_001", 891elseif ( local_gold == 3 ) RemoveItem, "gold_001", 653elseif ( local_gold == 2 ) RemoveItem, "gold_001", 424elseif ( local_gold == 1 ) RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 ) AddItem, "gold_001", 2147elseif ( local_gold == 9 ) AddItem, "gold_001", 1836elseif ( local_gold == 8 ) AddItem, "gold_001", 1705elseif ( local_gold == 7 ) AddItem, "gold_001", 1589elseif ( local_gold == 6 ) AddItem, "gold_001", 1262elseif ( local_gold == 5 ) AddItem, "gold_001", 1018elseif ( local_gold == 4 ) AddItem, "gold_001", 891elseif ( local_gold == 3 ) AddItem, "gold_001", 653elseif ( local_gold == 2 ) AddItem, "gold_001", 424elseif ( local_gold == 1 ) AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript
I've made a few adjustments to the respawn system as well, so now gold respawn is more consistent with the player waiting/leaving/returning.
The second script is the global script, it's not attached to anything:
Begin PE_LlavamGoldChestscript_g; script by Adulif ( GetPCCell, "Pelagiad, The Ascadian Anvil" == 1 ) Returnendifif ( PE_LlavamGoldChestChange == 1 ) set PE_LlavamGoldChestChange to 0endifStopScript, "PE_LlavamGoldChestscript_g"End PE_LlavamGoldChestscript_g
And the third script is the one attached to the clone chest. This chest should look identical to the original and should be in the exact same place (copy/paste the coordinates). Here's the script:
Begin PE_LlavamGoldChestscript_b; script by Adulif ( PE_LlavamGoldChestChange != 2 ) if ( GetDisabled == 0 ) Disable endifelseif ( GetDisabled == 1 ) EnableendifEnd PE_LlavamGoldChestscript_b