D4rkh0bb1T Posted March 19, 2016 Share Posted March 19, 2016 Hi everyone, The title says it all. When playing as a server, my custom item causes a disconnection when I use it. Someone can help? There is no crash log as the game is not likely crashing... Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/ Share on other sites More sharing options...
Mobbstar Posted March 19, 2016 Share Posted March 19, 2016 (edited) If you are playing a local game without caves, the only thing you can do in this case is to place print("sample") all over your code to track the exact steps that lead up to the disconnection. Else, I assume the server is silently crashing. Check the server's log! Edited March 19, 2016 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735831 Share on other sites More sharing options...
D4rkh0bb1T Posted March 19, 2016 Author Share Posted March 19, 2016 (edited) No crashing, the server just disconnect. This is a edible item. I use a local inst = GetPlayer(), Telling me that inst has a nil value. It works well when I play in single player. It's like the server is not sending the right information to the client so it disconnect,,, something like that. Edited March 19, 2016 by D4rkh0bb1T Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735833 Share on other sites More sharing options...
D4rkh0bb1T Posted March 19, 2016 Author Share Posted March 19, 2016 The GetPlayer thing was to be able to use inst.component.talker, haven't found another way to do it. Plus, other ''inst'' would'nt be working. Now things being to get confused. Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735836 Share on other sites More sharing options...
Aquaterion Posted March 19, 2016 Share Posted March 19, 2016 1 hour ago, D4rkh0bb1T said: The GetPlayer thing was to be able to use inst.component.talker, haven't found another way to do it. Plus, other ''inst'' would'nt be working. Now things being to get confused. if its when its in the inventory u can use local player = inst.components.inventoryitem.owner to get the player holding it Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735848 Share on other sites More sharing options...
Muche Posted March 19, 2016 Share Posted March 19, 2016 (edited) GetPlayer() has no meaning in DST, because there can be multiple players, as opposed to single player in DS. 1 hour ago, Aquaterion said: if its when its in the inventory u can use local player = inst.components.inventoryitem.owner to get the player holding it IIRC, if it's in the backpack worn by a player, this returns the backpack, not the player. local player = inst.components.inventoryitem:GetGrandOwner() should return the player. Edited March 19, 2016 by Muche backpack Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735856 Share on other sites More sharing options...
D4rkh0bb1T Posted March 19, 2016 Author Share Posted March 19, 2016 (edited) Well, nothing should return in the backpack! That's a edible item and I wanted the character to say something when eaten. In single player, the code works very well, but not when playing with someone. I have three item based on the same frame, and they don't work in MP. The other items I have are coded in a different way and seems to work, I can't figure out what I should change, remove, place. I'll show you what it looks like, : Spoiler local function reduce3() local inst = GetPlayer() if breakcounter > 1 then breakcounter = breakcounter - 1 else intens = 0 inst.Light:SetIntensity(intens) inst.Light:Enable(false) print "Light off" breakcounter = breakcounter - 1 end inst.components.talker:Say("Light has gone...", 4) end local function oneaten(inst, eater) local inst = GetPlayer() addlight() inst.components.talker:Say("Let there be light!", 4) end function addlight() local inst = GetPlayer() if inst.Light then else inst.entity:AddLight() print "new light :(" end intens = 0.75 -- breakcounter = breakcounter + 1 print (breakcounter) -- inst.Light:Enable(true) inst.Light:SetIntensity(intens) -- 0.75 inst.Light:SetColour(197/255,197/255,50/255) inst.Light:SetFalloff( 1.0 ) -- 0.5 inst.Light:SetRadius( 4 ) -- 2 inst:DoTaskInTime(potiontime-3, reduce1) inst:DoTaskInTime(potiontime-2, reduce2) inst:DoTaskInTime(potiontime-1, reduce3) end The crash log : Spoiler [00:00:56]: [string "../mods/hadabra/scripts/prefabs/whitepotion..."]:68: attempt to index local 'inst' (a nil value) LUA ERROR stack traceback: ../mods/hadabra/scripts/prefabs/whitepotion.lua:68 in (global) addlight (Lua) <65-89> ../mods/hadabra/scripts/prefabs/whitepotion.lua:60 in (field) oneaten (Lua) <58-63> scripts/components/edible.lua:126 in (method) OnEaten (Lua) <124-135> scripts/components/eater.lua:163 in () ? (Lua) <115-178> =(tail call):-1 in () (tail) <-1--1> scripts/bufferedaction.lua:24 in (method) Do (Lua) <20-34> scripts/entityscript.lua:1233 in (method) PerformBufferedAction (Lua) <1225-1243> scripts/stategraphs/SGwilson.lua:2263 in (field) fn (Lua) <2259-2267> scripts/stategraph.lua:568 in (method) UpdateState (Lua) <536-580> scripts/stategraph.lua:607 in (method) Update (Lua) <599-627> scripts/stategraph.lua:125 in (method) Update (Lua) <109-148> scripts/update.lua:209 in () ? (Lua) <150-223> EDIT : I just tried to host a game without Caves and it works. Then I started a new game with Caves and I got disconnected. What's going wrong with Caves? What's wrong with the code? Something is missing isn it? Edited March 19, 2016 by D4rkh0bb1T Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735911 Share on other sites More sharing options...
Mobbstar Posted March 19, 2016 Share Posted March 19, 2016 2 hours ago, D4rkh0bb1T said: What's going wrong with Caves? When you enable caves, the game is no longer directly on the server, but rather you create a local server and connect using a seperate client. It's like a miniature model of actual server-client communication. GetPlayer() does not work in DST. Instead, pass along the player variable like this: 1. in oneaten, it's already available as "eater" 2. pass it to addlight like this: addlight(eater) 3. and then change the head of "addlight" function to: local function addlight(inst) 4. remove the "inst=GetPlayer()" line Repeat the last two steps for the reduce functions. (the player variable is already being given to the functions by DoTaskInTime, but they need to receive it properly) Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-735958 Share on other sites More sharing options...
Aquaterion Posted March 19, 2016 Share Posted March 19, 2016 ye change inst.components.talker:Say("Let there be light!", 4) to eater.components.talker:Say("Let there be light!", 4) Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-736032 Share on other sites More sharing options...
D4rkh0bb1T Posted March 20, 2016 Author Share Posted March 20, 2016 All right! I managed to fix that item among other that was not right. Replacing inst by eater at some places and adding variables the the functions. I went through a lot of crashes but I finally did it! Yeah! Thanx to you guys for helping me out! That character will be very fun to play with D4rkh0bb1T Link to comment https://forums.kleientertainment.com/forums/topic/65556-custom-item-causes-server-disconnection-when-used/#findComment-736138 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