Jump to content

lose a item and then get other 2 items. (solved)


Pudge

Recommended Posts

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 by Pudge
solved
Link to comment
Share on other sites

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 by Sky_Orc_Mm
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...