Jump to content

OnControlDown script not working


213410

Recommended Posts

Hello!

 

I recently searched for mod that prevents player from running and sprinting and found idea, that it could be realised via SKSE and controls. So I tried to make a script, that checks if user equipped specific item (my script is attached to ebony boots), it then checks if player is running or sprinting and if so, holds shift button with player controls. The problem - nothing is happening in game. I think I made something horribly wrong with code, so I need help. I made only "Forward" for testing purposes, later I want to extend script for other controls.

Scriptname ForceWalk extends Form

;Actor Property PlayerREF Auto
;Armor Property EbonyBoots Auto
int bEquipped = 0

Event OnEquipped(Actor akActor)
    if akActor == Game.GetPlayer()
            bEquipped = 1
            RegisterForControl("Forward")
    endif
endEvent

Event OnUnequipped(Actor akActor)
    if akActor == Game.GetPlayer()
            bEquipped = 0
            UnregisterForControl("Forward")
    endif
endEvent

event OnControlDown(string control)
    if (control == "Forward")
      if Game.GetPlayer().IsRunning() == 1 || Game.GetPlayer().IsSprinting() == 1
        if bEquipped == 1
            Input.HoldKey(42)
            Debug.Notification("Forward")
        endif
      endif
    endif
endEvent

Please, help.

Edited by 213410
Link to comment
Share on other sites

I cannot be certain. I think the problem may be that the script is on the boots itself. Try redoing the script with it attached to a player alias on a quest. Some objects when they are in inventories and containers will not process certain functions or events. I always found it better to be safe than sorry and script from the player's perspective instead. I.E. OnObjectEquipped instead of OnEquipped, OnObjectUnequipped instead of OnUnequipped, etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...