ForenSmurf Posted May 10, 2015 Share Posted May 10, 2015 (edited) Hi, i tried to overwrite the functions TheNet:Kick(userid) and TheNet:Ban(userid) with the purpose to drop the stuff of the player who was kicked or banned: local function returnPlayer(userid) for k, v in pairs(GLOBAL.TheNet:GetClientTable()) do if v.userid == userid then return v end end end local kickTheNetOld = GLOBAL.TheNet.Kick or function(...) return true end function GLOBAL.TheNet:Kick(userid,...) local player = returnPlayer(userid) if player and player.components.inventory then player.components.inventory:DropEverything(false,false) end return kickTheNetOld(self,userid,...) end local banTheNetOld = GLOBAL.TheNet.Ban or function(...) return true end function GLOBAL.TheNet:Ban(userid,...) local player = returnPlayer(userid) if player and player.components.inventory then player.components.inventory:DropEverything(false,false) end return banTheNetOld(self,userid,...) end But it doesn't work because TheNet is "a UserData Value", what does that mean exactly? Edited May 10, 2015 by ForenSmurf Link to comment https://forums.kleientertainment.com/forums/topic/53790-overwriting-a-function-in-thenet/ Share on other sites More sharing options...
DarkXero Posted May 10, 2015 Share Posted May 10, 2015 I assume you read: http://forums.kleientertainment.com/topic/53756-only-drop-inventory-if-playerdays-is-below-a-certain-thresholdbanned/ Userdata means it's on the C side of the C/Lua relationship.There are two things you can do. 1) If you are going to use the console to enter TheNet:Ban(userid), then you may as well make a custom command.function GLOBAL.myban(userid) local player = returnPlayer(userid) player.components.inventory:DropEverything(false,false) GLOBAL.TheNet:Ban(userid)endThen you ban people via console with your custom command. 2) You want the little buttons in the table that appears pressing TAB to do the same as the command Then copy the rest of the code that was with the returnPlayer function. Regardless, I'm going to look if it's possible to do something to modify userdata. Link to comment https://forums.kleientertainment.com/forums/topic/53790-overwriting-a-function-in-thenet/#findComment-636262 Share on other sites More sharing options...
DarkXero Posted May 10, 2015 Share Posted May 10, 2015 UPDATE:Use the followinglocal function returnPlayer(userid) for k, v in pairs(GLOBAL.TheNet:GetClientTable()) do if v.userid == userid then return v end endendlocal TableNet = GLOBAL.getmetatable(GLOBAL.TheNet).__indexlocal old = TableNet.KickTableNet.Kick = function(self, userid) local player = returnPlayer(userid) if player and player.components.inventory then player.components.inventory:DropEverything(false, false) end return old(self, userid)end Link to comment https://forums.kleientertainment.com/forums/topic/53790-overwriting-a-function-in-thenet/#findComment-636274 Share on other sites More sharing options...
ForenSmurf Posted May 18, 2015 Author Share Posted May 18, 2015 Hi, i tried that but it didn't work, it seems that the returned user object from client table isn't the same user object as in AllPlayers[index] and it doesn't have any components. I'm just using GLOBAL.AllPlayers instead of GLOBAL.TheNet:GetClientTable() now and it works fine Link to comment https://forums.kleientertainment.com/forums/topic/53790-overwriting-a-function-in-thenet/#findComment-638514 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