Pudge Posted July 17, 2016 Share Posted July 17, 2016 (edited) Hellow to all example-> if X player have Shoes on bakpack , then Player Lose Shoes and obtan Milk and Honey. i try something like that, but it dont work -> function Itemcool() if getPlayer():getInventory():contains("Shoes") == true then getPlayer():getInventory():removeItem("Base.Shoes"); getPlayer():getInventory():AddItem("Base.Honey"); getPlayer():getInventory():AddItem("Base.Milk"); end end Events.Every 1 sec.Add(Itemcool); thanks for read >_< Update Solution: function Itemcool() local inv = getPlayer():getInventory(); it = inv:FindAndReturn("Base.Shoes"); if it then inv:Remove("Shoes"); inv:AddItem("Base.Honey"); inv:AddItem("Base.Milk"); end end Events.OnPlayerUpdate.Add(Itemcool); solved by: Sky_Orc_Mm Edited July 19, 2016 by Pudge solved Link to comment Share on other sites More sharing options...
ProjectSky Posted July 17, 2016 Share Posted July 17, 2016 (edited) function Itemcool() local inv = getPlayer():getInventory(); it = inv:FindAndReturn("Base.Shoes"); if it then inv:Remove("Shoes"); inv:AddItem("Base.Honey"); inv:AddItem("Base.Milk"); end end Events.OnPlayerUpdate.Add(Itemcool); As far as I know, there is no Every 1 sec this event But you can use the OnPlayerUpdate event to replace it. Edited July 17, 2016 by Sky_Orc_Mm Link to comment Share on other sites More sharing options...
RoboMat Posted July 17, 2016 Share Posted July 17, 2016 It might be a better idea to hook into the TimedAction for transferring items from one container to another and then filter out the item and replace it with a different one. Although of course editing a basefile means it would break compatibility with other mods which edit the same files. Link to comment Share on other sites More sharing options...
Pudge Posted July 17, 2016 Author Share Posted July 17, 2016 10 hours ago, Sky_Orc_Mm said: function Itemcool() local inv = getPlayer():getInventory(); it = inv:FindAndReturn("Base.Shoes"); if it then inv:Remove("Shoes"); inv:AddItem("Base.Honey"); inv:AddItem("Base.Milk"); end end Events.OnPlayerUpdate.Add(Itemcool); As far as I know, there is no Every 1 sec this event But you can use the OnPlayerUpdate event to replace it. Work Perfect, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now