Ryuushu Posted December 23, 2016 Share Posted December 23, 2016 I've been digging around inventoryitem_replica and inventoryitem_classified to get a trap's percent usage, but I just can't figure for my life how to do this. This is what I've been doing: local items = player.replica.inventory:GetItems() local trap = nil for i,v in ipairs(items) do if v.prefab == "trap" then print(v.replica.inventoryitem.percentused) print(v.components.inventoryitem) trap = v --break end end Can anyone familiar with client side stuff point me in the right direction? Link to comment Share on other sites More sharing options...
zUsername Posted December 23, 2016 Share Posted December 23, 2016 4 hours ago, Ryuushu said: I've been digging around inventoryitem_replica and inventoryitem_classified to get a trap's percent usage, but I just can't figure for my life how to do this. This is what I've been doing: local items = player.replica.inventory:GetItems() local trap = nil for i,v in ipairs(items) do if v.prefab == "trap" then print(v.replica.inventoryitem.percentused) print(v.components.inventoryitem) trap = v --break end end Can anyone familiar with client side stuff point me in the right direction? local items = player.replica.inventory:GetItems() local trap = nil for i,v in ipairs(items) do if v.prefab == "trap" then local percentusedcomponent = v.components.finiteuses print(percentusedcomponent:GetPercent()) trap = v end end Link to comment Share on other sites More sharing options...
Ryuushu Posted December 23, 2016 Author Share Posted December 23, 2016 @zUsername That works on the server side, but if you try to run it as a client you'll crash (finiteuses = nil) since you can't access the components directly, it has to be through a replica. Still, thank you. Link to comment Share on other sites More sharing options...
zUsername Posted December 23, 2016 Share Posted December 23, 2016 32 minutes ago, Ryuushu said: @zUsername That works on the server side, but if you try to run it as a client you'll crash (finiteuses = nil) since you can't access the components directly, it has to be through a replica. Still, thank you. local items = player.replica.inventory:GetItems() for i,v in ipairs(items) do if v.prefab == "trap" then print(v.replica.inventoryitem.classified.percentused:value()) end end Link to comment Share on other sites More sharing options...
Ryuushu Posted December 23, 2016 Author Share Posted December 23, 2016 @zUsername Ahh, I totally overlooked the value() function when I tried that earlier. No wonder it was returning net_byte... I feel dumb now. Thank you! it worked quite nicely 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