Not sure if it helps, but this is the lockable door script I used in Oblivion...
Spoiler
ScriptName ComplexSecretDoorScript
ref mySelf
short button
begin OnActivate
set mySelf to GetSelf
if IsActionRef Player == 1 && mySelf.GetOpenState == 3
if mySelf.GetLocked ==1 && player.GetItemCount SecretDoorKey > 0
mySelf.UnLock
Message " You unlock the door with a key."
mySelf.Activate Player
elseif mySelf.GetLocked == 0 && Player.GetItemCount SecretDoorKey > 0
MessageBox "Would you like to open or lock the door?", "Open", "Lock", "Cancel"
elseif mySelf.GetLocked == 1 && Player.GetItemCount SecretDoorKey == 0
Message " You need a key to unlock this door."
else
mySelf.Activate Player
endif
else
mySelf.Activate
endif
end
begin GameMode
set button to GetButtonPressed
if button > -1
if button == 0
mySelf.Activate Player
elseif button == 1
mySelf.Lock 100
Message " You lock the door with a key."
endif
endif
end
ref mySelf
short button
begin OnActivate
set mySelf to GetSelf
if IsActionRef Player == 1 && mySelf.GetOpenState == 3
if mySelf.GetLocked ==1 && player.GetItemCount SecretDoorKey > 0
mySelf.UnLock
Message " You unlock the door with a key."
mySelf.Activate Player
elseif mySelf.GetLocked == 0 && Player.GetItemCount SecretDoorKey > 0
MessageBox "Would you like to open or lock the door?", "Open", "Lock", "Cancel"
elseif mySelf.GetLocked == 1 && Player.GetItemCount SecretDoorKey == 0
Message " You need a key to unlock this door."
else
mySelf.Activate Player
endif
else
mySelf.Activate
endif
end
begin GameMode
set button to GetButtonPressed
if button > -1
if button == 0
mySelf.Activate Player
elseif button == 1
mySelf.Lock 100
Message " You lock the door with a key."
endif
endif
end

