Sorry... I haven't done ANY papyrus scripting yet, but from my programming experience, I think there is an error in the OnUnequipped function.
Since we set has=1 when the player already has the spell, we want to make sure we only want to remove the spell when has
is not 1. Thus, shouldn't it be as follows?
bool Property alreadyHasSpell = false autoEvent OnEquipped(Actor akActor) if !akActor.hasSpell(Spell) ;if actor doesn't have spell akActor.addSpell(Spell) ;add the spell else alreadyHasSpell=true ;if the actor already has the spell endIfendEventEvent OnUnequipped(Actor akActor) if !alreadyHasSpell ;if the actor didn't already have the spell remove it (this was set in onEquipped) akActor.removeSpell(Spell) ;Removes spell endIfendEvent
Edited after reading several comments about using bools instead of ints (Like the one from Redwood Elf below). Also changed variable name to make it more human-readable. Hope there are no variable naming limits!
(Edit 2 - Simplified "alreadyHasSpell == false" to "!alreadyHasSpell") Thanks Redwood Elf