Jump to content

Toggle weapon on hotkey


ShadyMick23

Recommended Posts

Hi, I'm doing mod that allows to change WMK weapons by button, namely switch laser sight on/off while ingame - like activation of nightvision

Please, do not tell me that there are hotkeys slots etc

 

I've tried to compose a script for it, but none worked. Here's one I currently stuck with:

scn WMKLSToggleScript

short LStoggle
short doOnce
short weapIndex
float WeaponCondition
ref equippedWeap
ref weapToggleListA
ref weapToggleListB
ref newWeap

Begin OnEquip
  set equippedWeap to Player.GetEquippedObject 5
  set WeaponCondition to Player.GetWeaponHealthPerc / 100
  set weapToggleListA to ListGetNthForm aaaLSguns2OrderedList weapIndex		;// LS OFF LIST
  set weapToggleListB to ListGetNthForm aaaLSguns1OrderedList weapIndex		;// LS ON LIST
End

Begin GameMode
  if ( equippedWeap.IsWeaponInList aaaLSguns2OrderedList == 1 ) || ( equippedWeap.IsWeaponInList aaaLSguns1OrderedList == 1 )
    if IsKeyPressed LSglobalHotkey
      if LStoggle == 0
        set LStoggle to 1
        if ( doOnce == 0 )
          set weapIndex to ListGetFormIndex weapToggleListA equippedWeap
          set newWeap to ListGetNthForm weapToggleListB weapIndex
          player.removeitem equippedWeap 1 1
          player.additemhealthpercent newWeap 1 WeaponCondition 1
          player.equipitem newWeap
          set doOnce to 1
        elseif ( doOnce == 1 )
          set weapIndex to ListGetFormIndex weapToggleListB equippedWeap
          set newWeap to ListGetNthForm weapToggleListA weapIndex
          player.removeitem equippedWeap 1 1
          player.additemhealthpercent newWeap 1 WeaponCondition 1
          player.equipitem newWeap
          set doOnce to 0
        endif
      endif
    else
      Set LStoggle to 0
    endif
  else
    return
  endif
End 

Help, please

Edited by ShadyMick23
Link to comment
Share on other sites

  • Recently Browsing   0 members

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