Jump to content

Get ammo count


shavkacagarikia

Recommended Posts

There is no way to get the current ammo count in the magazine, but you can get how much ammo the player has by using this code:

 

Weapon currentweapon = Game.GetPlayer().GetEquippedWeapon(0)
Ammo playerammo = currentweapon.GetAmmo()
Link to comment
Share on other sites

Thanks I am aware how to do that, but I need the amount of ammo in magazine

You can't get that kind of info, unfortunately. The best you could do would be to divide the player's current total ammo by the number of rounds held in the magazine, but that would require that you figure out what magazine is equipped on the current weapon.

Link to comment
Share on other sites

See this thread https://forums.nexusmods.com/index.php?/topic/4586285-papyrus-f4-detecting-when-the-player-fires-a-weapon/?hl=%2Bjam&do=findComment&comment=40864335

 

Use this script to count shots after every reload, once you setup a script to get the magazine size of the weapon.

 

RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire")

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
If (akSource == Game.GetPlayer() && asEventName == "weaponFire")
Debug.Notification("The player fired his weapon.")
EndIf
EndEvent

 

Then on the reload event reset the shot counter of which the animation event or that is supposed to be "reloadComplete" but I could never make a script trigger :cool: off that event and have not yet used the noted method to find the reload specific animations.

 

Also make sure to use the "currentweapon.GetAmmo()" method to verify that there are enough rounds to fully load the mag, and adjust logic accordingly.

 

If you want to make a more detailed description of what you are trying accomplish, assuming its not classified, lemme know and I might be better able to point you in the right direction.

Link to comment
Share on other sites

See this thread https://forums.nexusmods.com/index.php?/topic/4586285-papyrus-f4-detecting-when-the-player-fires-a-weapon/?hl=%2Bjam&do=findComment&comment=40864335

 

Use this script to count shots after every reload, once you setup a script to get the magazine size of the weapon.

 

RegisterForAnimationEvent(Game.GetPlayer(), "weaponFire")

 

Event OnAnimationEvent(ObjectReference akSource, string asEventName)

If (akSource == Game.GetPlayer() && asEventName == "weaponFire")

Debug.Notification("The player fired his weapon.")

EndIf

EndEvent

 

Then on the reload event reset the shot counter of which the animation event or that is supposed to be "reloadComplete" but I could never make a script trigger :cool: off that event and have not yet used the noted method to find the reload specific animations.

 

Also make sure to use the "currentweapon.GetAmmo()" method to verify that there are enough rounds to fully load the mag, and adjust logic accordingly.

 

If you want to make a more detailed description of what you are trying accomplish, assuming its not classified, lemme know and I might be better able to point you in the right direction.

I can't catch that onanimation event, I register it oninit and then have the onanimationevent but i get no notification when firing a weapon. My script extends activemagiceffect can that be the problem?

Link to comment
Share on other sites

I can't catch that onanimation event, I register it oninit and then have the onanimationevent but i get no notification when firing a weapon. My script extends activemagiceffect can that be the problem?

You should post the script if you want people to help you with it. :smile:
Link to comment
Share on other sites

  • Recently Browsing   0 members

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