Primalflower Posted January 24, 2019 Share Posted January 24, 2019 (edited) A glitch is happening within a mod that I am tweaking around with. in said mod, a structure built on top of a lake, is harvestable after a short period of time. The glitch that I am referring to is that when a player leaves a server and comes back, the graphic that is shown to signify that said structure is harvestable, is gone. Does anybody know of a function that activates when a player joins a server, so I can make it so that upon joining the server, the mod can check whether or not the structure is harvestable, and re-enable the graphic as a result. I have tried to use "Onload" to fix this problem as follows: But nothing happens, the structure still shows to be empty when it is harvestable. tl;dr: What is a function that activates when a player joins the game, or alternatively what is a better way to implement what is shown in the picture? Edited January 24, 2019 by lbphero Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 24, 2019 Share Posted January 24, 2019 (edited) If the issue is like that, probably the ultimate solution is not the way like this. But there's an event that activates every time someone joins. inst:ListenForEvent("ms_playerjoined", somefunc, TheWorld) Edited January 24, 2019 by YakumoYukari Link to comment Share on other sites More sharing options...
Primalflower Posted January 24, 2019 Author Share Posted January 24, 2019 (edited) 1 hour ago, YakumoYukari said: If the issue is like that, probably the ultimate solution is not the way like this. But there's an event that activates every time someone joins. inst:ListenForEvent("ms_playerjoined", somefunc, TheWorld) So, Like this? EDIT: I tried to use this as depicted, but the game seems to want me to put a name next to the ms_playerjoined, somehow. Edited January 24, 2019 by lbphero Link to comment Share on other sites More sharing options...
DarkXero Posted January 25, 2019 Share Posted January 25, 2019 It would help if you posted the mod or more data. AnimState should propagate correctly to clients when changing (using "Show"). As an example, here's the correct usage: -- prefab file local function PlayerFix(inst) if not inst:HasTag("depleted") then inst.extractor.AnimState:Show("salt") end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() -- ... inst.entity:AddNetwork() -- here inst:ListenForEvent("ms_playerjoined", function(world, player) PlayerFix(inst) end, TheWorld) -- ... inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end -- ... return inst end More interesting would be to see the extractor prefab. It's probably missing a AddNetwork that would solve this without hassle. 1 Link to comment Share on other sites More sharing options...
HeilerderWelten Posted January 5, 2021 Share Posted January 5, 2021 Dark Xeros last post 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