poolcool2 Posted December 18, 2022 Share Posted December 18, 2022 I have been working on a silly gimmick mod for a while now that is supposed to force all players to share the same inventory and it actually worked first try easily with no issues server side. The only problem was that the items would not show up in the player's inventory. After months of going nuts trying to figure out why this is, I came to a few interesting discoveries. Through some messing around with pushevents I found out that "refreshinventory" and the likes are not working and "itemget" works exactly as I want it to except that it only works if the item is nearby on the ground. After some more recent messing around I found out that forcing SetCanSleep to false made it work at any range, but still only on the ground. I have come to the conclusion that the issue I am having comes from the item not being loaded on the client when it's in another player's inventory even with SetCanSleep set to false. I have a feeling that if I can get around that, I can get everything to work. TLDR: I want everyone to share the same inventory and I need help finding a way to get around items unloading when put in other player's inventories. And if it somehow helps I have the modmain that I have been working with attached but be warned it is a jumbled mess of the madness I have been trying to solve for months. modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/145267-having-trouble-with-items-unloading-from-client-when-in-other-players-inventory/ Share on other sites More sharing options...
Hornete Posted December 18, 2022 Share Posted December 18, 2022 6 hours ago, poolcool2 said: I have been working on a silly gimmick mod for a while now that is supposed to force all players to share the same inventory and it actually worked first try easily with no issues server side. The only problem was that the items would not show up in the player's inventory. After months of going nuts trying to figure out why this is, I came to a few interesting discoveries. Through some messing around with pushevents I found out that "refreshinventory" and the likes are not working and "itemget" works exactly as I want it to except that it only works if the item is nearby on the ground. After some more recent messing around I found out that forcing SetCanSleep to false made it work at any range, but still only on the ground. I have come to the conclusion that the issue I am having comes from the item not being loaded on the client when it's in another player's inventory even with SetCanSleep set to false. I have a feeling that if I can get around that, I can get everything to work. TLDR: I want everyone to share the same inventory and I need help finding a way to get around items unloading when put in other player's inventories. And if it somehow helps I have the modmain that I have been working with attached but be warned it is a jumbled mess of the madness I have been trying to solve for months. modmain.lua 2.42 kB · 1 download First off, super awesome mod idea. Second off, perhaps you want to look into the Network:SetClassifiedTarget function? This is the function that makes an entity available to certain clients and whatnot and might be the issue you're having here. You can see in inventoryitem_replica.lua in the SetOwner function, it passes nil to inst.Network:SetClassifiedTarget to make it available to every client if a chest has two or more openers, otherwise it passes the person opening the container so it's available to only them. Your mod not properly allowing the items to be available to all the clients could be the issue. 1 Link to comment https://forums.kleientertainment.com/forums/topic/145267-having-trouble-with-items-unloading-from-client-when-in-other-players-inventory/#findComment-1615534 Share on other sites More sharing options...
poolcool2 Posted December 19, 2022 Author Share Posted December 19, 2022 8 hours ago, Hornete said: First off, super awesome mod idea. Second off, perhaps you want to look into the Network:SetClassifiedTarget function? This is the function that makes an entity available to certain clients and whatnot and might be the issue you're having here. You can see in inventoryitem_replica.lua in the SetOwner function, it passes nil to inst.Network:SetClassifiedTarget to make it available to every client if a chest has two or more openers, otherwise it passes the person opening the container so it's available to only them. Your mod not properly allowing the items to be available to all the clients could be the issue. Thank you so much, you are a legend! After some messing with it, it seems to work perfectly except for a few crashes here and there that don't have a crash log or anything, but that's to be expected. I'll keep working on this and as long as I don't run into any major snags, I should have a update uploaded soon to the steam workshop. 2 Link to comment https://forums.kleientertainment.com/forums/topic/145267-having-trouble-with-items-unloading-from-client-when-in-other-players-inventory/#findComment-1615559 Share on other sites More sharing options...
xlsean Posted January 24, 2023 Share Posted January 24, 2023 @HorneteI am a new modder. Though I can find some posts to study replica patterns, I am still not clearly about inst.Network:SetClassifiedTarget and container_proxy, and other stuff like that. I found an entity/inst created on the server and was put into a container, then the inst will be removed from client after the container is closed. When the container is opened again, a new inst with same prefab will be spawned again. I have no idea how this happens. I appreciate if you have any refences which I can read or briefly explain the source code about this. Link to comment https://forums.kleientertainment.com/forums/topic/145267-having-trouble-with-items-unloading-from-client-when-in-other-players-inventory/#findComment-1618635 Share on other sites More sharing options...
xlsean Posted January 25, 2023 Share Posted January 25, 2023 19 hours ago, xlsean said: @HorneteI am a new modder. Though I can find some posts to study replica patterns, I am still not clearly about inst.Network:SetClassifiedTarget and container_proxy, and other stuff like that. I found an entity/inst created on the server and was put into a container, then the inst will be removed from client after the container is closed. When the container is opened again, a new inst with same prefab will be spawned again. I have no idea how this happens. I appreciate if you have any refences which I can read or briefly explain the source code about this. Never mind. I have studied this discussion and it seems caused by Network:SetClassifiedTarget logic. Link to comment https://forums.kleientertainment.com/forums/topic/145267-having-trouble-with-items-unloading-from-client-when-in-other-players-inventory/#findComment-1618710 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