int FlipSwitch(object oLever = OBJECT_SELF)
{
if (GetLocalInt(OBJECT_SELF, "nToggle") == 0)
 {
 PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE, 1.0, 1.0);
 SetLocalInt(OBJECT_SELF, "nToggle", 1);
 return TRUE;
 }
else
 {
 PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE, 1.0, 1.0);
 SetLocalInt(OBJECT_SELF, "nToggle", 0);
 return FALSE;
 }
}

void main()
{
if (FlipSwitch())
 {
 //Code when lever is activated
 }
else
 {
 //Code when lever is deactivated
 }

}
