Deadeye_Rob 908 Posted October 8, 2019 Hi guys! I've been racking my brains to figure this out but with no success. How do I create a script that will check a player's inventory for a predetermined quantity of objects say; 10 Iron Ore. If they possess the required item/quantity it will remove/despawn it from their inventory and in exchange will spawn another object. See where I'm going? ? Many help would be fantastic. Thanks guys! Rob Share this post Link to post Share on other sites
RedEagle_P1. 905 Posted October 8, 2019 Ping me on discord, i got some great scripts just like that. Not sure how they work, we have them in the P1 library. 1 Share this post Link to post Share on other sites
Deadeye_Rob 908 Posted October 11, 2019 Very kind mate thanks! I'll drop you guys a line at some point! Share this post Link to post Share on other sites
Oliver Hope 261 Posted October 14, 2019 If you want to try work it out by yourself here is the basic idea, you need to do a for each loop with the array of items in the player's inventory, inside the for each loop you need to use an if statement to see if the item is equal to the type you are looking for, then you can check if there is enough of that item and from there you spawn the new item in the players inventory. does this make any sense whats so ever? Share this post Link to post Share on other sites
Igor Q. 519 Posted October 14, 2019 (edited) You all should be ashamed of yourselves for being so lazy as not to provide a half decent answer with a real explanation. @RedEagle_P1. @Oliver Hope@Deadeye_Rob Click on the image to make it bigger to see it! Here, we made an instruction using a global storage. (Global Storage is useful because it can be used anywhere, anytime) The instruction "Player Has Item?" has 3 variables, the player, the item type, and the quantity. First it checks for each slot in the players inventory. It then checks if we have the correct item type AND If the amount is correct. If TRUE -> pay the amount we need to get the thing. Ex: Player Buys Spear If (Player) has 3 Old Coins If its true, the player will then pay 3 Old Coins and after a Spear will spawn in the players inventory. Edited October 14, 2019 by Igor Q. 2 Share this post Link to post Share on other sites
Deadeye_Rob 908 Posted October 14, 2019 You sir, are an absolute genius! Thanks very much Igor! I had to make a minor adjustment for it to work properly however. On the "Player Has Item?" chain; the 'Set Stack Count Entity' should just have the 'Item' box within its parameters. Not the 'Get Stack Count Entity -Item'. Otherwise this will generate an error. I'm going to toy around with this script to include templated items to see what I can create. You've repeaked my interest on this matter again! My Vault project will have to wait! *Here is a quick visual breakdown of what I corrected to adapt the script for my purposes so far! Thanks again Igor! 1 Share this post Link to post Share on other sites
Igor Q. 519 Posted October 14, 2019 oops, sorry about that! XD Atleast it *almost* worked on the first try 1 Share this post Link to post Share on other sites
Deadeye_Rob 908 Posted October 15, 2019 Hey no worries at all! I've never attempted to use Arrays, instructions or variables! But you've definitely got my old cogs turning! ? Share this post Link to post Share on other sites
Oliver Hope 261 Posted October 15, 2019 @Igor Q. I am admittedly ashamed ? ,seeing as I hadnt touched ylands editor for a good few months I didnt trust my self to be too specific. Share this post Link to post Share on other sites