Hi. I can't find the code to do this:
If any stack of player inventory is bigger than 50, then do something.Code:if (player.inventory.stacksize (<-- something like that i want to do) > 50) { // code }
I tried searching with a decopiler on class PlayerInventory, but i think there is nothing that can help me.
Calling @Wulf almighty ^^
Thank you!!
Solved Get stack amount from player inventory
Discussion in 'Rust Development' started by Reynostrum, Dec 4, 2015.
-
Calytic Community Admin Community Mod
You're going to have to loop through every item in the inventory and check the item.amount.
Code:foreach (Item i in player.inventory.AllItems()) { if (i.amount > 50) { // do something } }
-
Thank you!
I still have a problem.
This is my code:
Code:void Loaded() { timer.Repeat(10, 0, () => { foreach (Item i in player.inventory.AllItems()) { if (i.amount > 40000) { SendReply(player, "asd"); } } }); }
I know that's because there must be "BasePlayer player" in some place, but i don't know where.
Thank you! -
Calytic Community Admin Community Mod
Code:foreach(BasePlayer player in BasePlayer.activePlayerList) { // do stuff }
-
For some reason I always thoght is not possible foreach inside foreach.
Thank you @Calytic !