kokoboko 1 Report post Posted June 14, 2023 I am looking to make a chest for equipments when i use that chest i get a single item from the items put inside the chest, it would be much appreciated if someone could tell me at which file i could find functions for this Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted June 15, 2023 Please be a bit more clear on what you want to do. Do you want to create a chest that will randomly give the player an item? Or do you want a chest to store items and randomly pop them out once the player uses it? For the last option you will have to store this data somewhere - database table or text files. Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites
kokoboko 1 Report post Posted June 15, 2023 5 hours ago, Mdrst said: Please be a bit more clear on what you want to do. Do you want to create a chest that will randomly give the player an item? Or do you want a chest to store items and randomly pop them out once the player uses it? For the last option you will have to store this data somewhere - database table or text files. I want to make a random uns85 weapon chest Quote Share this post Link to post Share on other sites
kokoboko 1 Report post Posted June 15, 2023 12 hours ago, Mdrst said: Please be a bit more clear on what you want to do. Do you want to create a chest that will randomly give the player an item? Or do you want a chest to store items and randomly pop them out once the player uses it? For the last option you will have to store this data somewhere - database table or text files. By items i mean the items i put from files lile all of the uns85 weapon but i get only one random Quote Share this post Link to post Share on other sites
kyleflow 35 Report post Posted June 15, 2023 2 hours ago, kokoboko said: By items i mean the items i put from files lile all of the uns85 weapon but i get only one random You just need to edit your ItemEffect.lua for the created chest in the iteminfo.txt . First you need to specify what conditions you want that one item will be chosen from. Either it classed based or totally random. This code are an example from Chaos chest. function ItemUse_FightingBox( role , Item ) local Item_CanGet = GetChaFreeBagGridNum ( role ) if Item_CanGet < 2 then SystemNotice(role ,"You need at least 2 empty inventory slots to open the Chaos Chest") UseItemFailed ( role ) return end GiveItem ( role , 0 , 2610 , 1 , 4 ) local rad = math.random ( 1, 4 ) if rad ==1 then GiveItem ( role , 0 , 1124 , 1 , 15 ) end if rad ==2 then GiveItem ( role , 0 , 1125 , 1 , 15 ) end if rad ==3 then GiveItem ( role , 0 , 1126 , 1 , 15 ) end if rad ==4 then GiveItem ( role , 0 , 1127 , 1 , 15 ) end end Based on the code, it used a math.random outcome to decide which item to be given. Since it have 4 item, the probability is 1/4 for each item and the outcome of the math.random is specified with each item after the result. If its classed based and want to give 1 item only, you need to specified the class check and called for the math.random for each class. 1 Quote Share this post Link to post Share on other sites
kokoboko 1 Report post Posted June 16, 2023 On 6/15/2023 at 8:39 AM, Mdrst said: On 6/15/2023 at 11:58 PM, kyleflow said: You just need to edit your ItemEffect.lua for the created chest in the iteminfo.txt . First you need to specify what conditions you want that one item will be chosen from. Either it classed based or totally random. This code are an example from Chaos chest. function ItemUse_FightingBox( role , Item ) local Item_CanGet = GetChaFreeBagGridNum ( role ) if Item_CanGet < 2 then SystemNotice(role ,"You need at least 2 empty inventory slots to open the Chaos Chest") UseItemFailed ( role ) return end GiveItem ( role , 0 , 2610 , 1 , 4 ) local rad = math.random ( 1, 4 ) if rad ==1 then GiveItem ( role , 0 , 1124 , 1 , 15 ) end if rad ==2 then GiveItem ( role , 0 , 1125 , 1 , 15 ) end if rad ==3 then GiveItem ( role , 0 , 1126 , 1 , 15 ) end if rad ==4 then GiveItem ( role , 0 , 1127 , 1 , 15 ) end end Based on the code, it used a math.random outcome to decide which item to be given. Since it have 4 item, the probability is 1/4 for each item and the outcome of the math.random is specified with each item after the result. If its classed based and want to give 1 item only, you need to specified the class check and called for the math.random for each class. Ty man I've made it 1 Quote Share this post Link to post Share on other sites