How would I read how much ammo is in a players magazine?
How would I read what the players gun is?
And how would I read who killed who?
I couldnt find any of these in the assembly so im not sure.
Thanks in advance.
Getting ammo count, gun used?
Discussion in 'Rust Development' started by DylanSMR, Aug 8, 2015.
-
deathnotes uses a function to get info about who killed someone with what type of weapon
-
Yeah im looking into that, but what about the amount of ammo in a mag?
[DOUBLEPOST=1439030686][/DOUBLEPOST]Do you know of a way to see if a person has a weapon out and or true/false? -
The Infinite Ammo plugin probably has what you need: http://oxidemod.org/plugins/infinite-ammo.1083/
You can use GetActiveItem() to see what a player is using
Edit: code updated to include ammo countCode:[ChatCommand("checkitem")] private void checkItem(BasePlayer player, string command, string[] args) { Item item = player.GetActiveItem(); if (item != null) { SendReply(player, "Active Item: " + item.info.shortname); var weapon = item.GetHeldEntity() as BaseProjectile; if (weapon != null) { SendReply(player, "Ammo count: " + weapon.primaryMagazine.contents); } } else { SendReply(player, "No active item"); } }Last edited by a moderator: Aug 9, 2015 -
This is what Ownprox gave me one day
GetAmount(player, 498591726, 0); // from belt
GetAmount(player, 498591726, 1); // from main
GetAmount(player, 498591726, 2); // from wear
Code:int GetAmount(BasePlayer player, int itemid, int type) { switch(type) { case 0: return player.inventory.containerBelt.GetAmount(itemid, true); case 1: return player.inventory.containerMain.GetAmount(itemid, true); } return player.inventory.containerWear.GetAmount(itemid, true); }
