Getting the specific bullet-count in a players' active weapon's magazine
Posted: Tue Sep 13, 2022 6:06 pm
Hey guys, I'm trying to get the bullet count in order to determine whether or not a player is shooting.
I was originally running:
But this triggers even if the player is just holding down SPACE or C - so my logic was to capture their bullet count and see whether or not it is changing.
So what I've done so far, was loop through the players, grabbing their ammo inventory:
But obviously this just returns string -> int, which is great for magazine count, but I'm trying to capture the bullet count. And from what I'm seeing in the docs, I need to use .ammo on an AmmoItem, I'm just not sure how to get this from a player.
Any help is always appreciated, thank you!
And if there's any better way to determine whether or not a player is actively shooting instead of this method, that's awesome too!!
I was originally running:
Code: Select all
if p.shooting_state.state ~= defines.shooting.not_shooting then
So what I've done so far, was loop through the players, grabbing their ammo inventory:
Code: Select all
local this_player_ammo = p.get_inventory(defines.inventory.character_ammo).get_contents()
Any help is always appreciated, thank you!
And if there's any better way to determine whether or not a player is actively shooting instead of this method, that's awesome too!!