Sign in to follow this  
ShimakazeKai

Need Help with modding

Recommended Posts

Im new to modding and i went a little bit too ambitious with my first mod and now im having troubles fixing bugs. most of them only happen on the client side, and works fine on the host's side. 

I have been working on a backpack that has a level system, the stats are working properly, however i wanted the item's name to be updated too when it is upgraded. The updated name only shows on the host's screen and the client just sees the default name. Another problem im having is that I wanted it to be upgraded when a specific item is inserted into the inventory and the bag is then closed for the upgrade to trigger. (the item is consumed). This works as intended on the host, but the client must drop the backpack for this to happen. Im thinking maybe there is a different event it can listen to to trigger the checking and upgrading functions?

local function CheckForUpgrade(inst)

    local container = inst.components.container
    for i = 1, container:GetNumSlots() do
        local item = container:GetItemInSlot(i) or nil
        if item ~= nil and item.prefab == "screw" and inst.level < 5 then
            inst.level = inst.level+1
            container:RemoveItemBySlot(i)
            applyupgrades(inst)
        end

    end

end
function applyupgrades(inst)
  inst.name = "Daihatsu +"..inst.level
  inst.components.equippable.walkspeedmult = 0.8+ inst.level * 0.02 + inst.penalty
  inst.components.armor.absorb_percent = 0.3 + inst.level * 0.04
end

These are the functions im using to do the job, CheckForUpgrade triggered by ListenForEvent("onclose")

Any help is appreciated, thanks.

 

Share this post


Link to post
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
Sign in to follow this