I found this odd issue with setessential using either a script or in the console command. It seems to only update and take hold if the npc is actually in the same cell as the player.
Not even loaded in memory works, it had to be the cell. I did a test several times that went like this:
in the console:
typed in: coc riverwoodriverwoodtrader
in game:
clicked on carlotta once to leave her info on screen (using mfg console plugin to get the base name and reference name)
in the console:
typed in: isessential
results on essential status: 0
great so far, we've confirmed she is not essential.
with Carlotta's information still up on screen in the console
in console:
typed in: coc riftenbeeandbarb
opened up console and checked status again on Carlotta:
in console: isessential
results on essential status: 0
in console: SetEssential xxxxxxxx 1 (x's are the base id of carlotta - get that from the information on the screen if using mfg console)
close console to go back in game.
open console and type in:
isEssential
results on carlotta's essential status: 0 ;at this point we've set her essential status to 1 while the player is at the bee and barb in riften yet results are showing a status of 0.
now in console with carlotta's info still up on screen type:
moveto player
close console, verify carlotta is near you then back to the console type:
isessential
results for essential status: 1
that just tells me, set essential won't take hold until that reference is near the player. But what about when they leave the area? well i checked that too.
with her now being essential and in riften, she'll start to walk back home, wait for her to walk out the door and type into the console
Isessential
results: 1,
now type: setessential xxxxxxxx 0
then back to game screen.
back to console type in:
IsEssential
results of status: 1
at this point carlotta just left the building, should still be in memory, loaded by the game, yet the status won't update her till she is in the same cell area as the player. if you
moveto player again her status will update.
I did this with several other characters as well, all in the area and all across skyrim and the results were the same.
I've also done tests in my own mod by putting npc's into a referenceAlias with the essential flag on. adding and removing them thereby clearing or unclearing their essential flag.
the results were the same: they didn't update their status till they were in the same cell as the player.
I just want to see if this is confirmed and known in the modding community because it's kind of putting a pause on my mcm status screen when trying to get updates on the npc's essential status. Especially when they aren't near the player.
I haven't tried on the invulnerable status yet. it may yield the same results. Going to test that in a few minutes and get back with results.
Update: can't check invulnerable with the console: isInv just yeilds a blank. And can't find any commands to set invulnerable status through the console.