Kuldiin Posted May 10, 2015 Share Posted May 10, 2015 I've been looking at a mod that does the below:- AddComponentPostInit("playerspawner", function(PlayerSpawner, inst) inst:ListenForEvent("ms_playerdespawn", function (inst, player) if player and player.components.inventory then player.components.inventory:DropEverything(false,false) end end) end) Is it difficult to amend this so that it makes a player only drop their inventory when they are either below a set amount of days played, or banned ? Thank you. Link to comment https://forums.kleientertainment.com/forums/topic/53756-only-drop-inventory-if-playerdays-is-below-a-certain-thresholdbanned/ Share on other sites More sharing options...
Sarcen Posted May 10, 2015 Share Posted May 10, 2015 (edited) Both are doable, although, banned is probably slightly trickier depending on if the banned player is still on the client table at the moment of the event... age would simply be checkingplayer.components.age.GetAgeInDays() > somenumberSomething along the lines of this would probably work...local clientinfo = nilfor k,v in pairs(TheNet:GetClientTable()) do if v.userid == player.userid then clientinfo = v break endendlocal banned = falsefor k,v in pairs(TheNet:GetBlacklist()) do if clientinfo.steamid == v.steamid then banned = true break endendthen checking if banned is true. But this is assuming the banned player is still in the ClientTable at the moment despawn is called. It could be that he is not. If not you could check him by name. *edit* you could also possibly check by user id, but I'm not sure how unique that is, but it seems pretty unique .local banned = falsefor k,v in pairs(TheNet:GetBlacklist()) do if player.userid == v.userid then banned = true break endend Edited May 10, 2015 by Sarcen Link to comment https://forums.kleientertainment.com/forums/topic/53756-only-drop-inventory-if-playerdays-is-below-a-certain-thresholdbanned/#findComment-636095 Share on other sites More sharing options...
DarkXero Posted May 10, 2015 Share Posted May 10, 2015 local DAYS = 4AddComponentPostInit("playerspawner", function(PlayerSpawner, inst) inst:ListenForEvent("ms_playerdespawn", function(inst, player) if player.components.inventory then if player.components.age and player.components.age:GetAgeInDays() < DAYS then player.components.inventory:DropEverything(false, false) end end end)end)local function isPlayerAdmin(player) for k, v in pairs(GLOBAL.TheNet:GetClientTable()) do if v.userid == player.userid then return v.admin end endendlocal function returnPlayer(userid) for k, v in pairs(GLOBAL.TheNet:GetClientTable()) do if v.userid == userid then return v end endendAddModRPCHandler(modname, "dropeverything", function(player, userid) if not isPlayerAdmin(player) then return end local target = returnPlayer(userid) if target.components.inventory then target.components.inventory:DropEverything(false, false) endend)AddClassPostConstruct("screens/playerstatusscreen", function(self) if self.scroll_list and self.scroll_list.items then if self.scroll_list.items.kick then self.scroll_list.items.kick:SetOnClick(function() GLOBAL.TheFrontEnd:PushScreen( GLOBAL.PopupDialogScreen( GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.KICKCONFIRM_TITLE.." "..displayName, GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.KICKCONFIRM_BODY.." "..displayName.."?", { {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.OK, cb = function() SendModRPCToServer(MOD_RPC[modname]["dropeverything"], v.userid) GLOBAL.TheNet:Kick(v.userid) GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end}, {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.CANCEL, cb = function() GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end} } ) ) end) end if self.scroll_list.items.ban then self.scroll_list.items.ban:SetOnClick(function() GLOBAL.TheFrontEnd:PushScreen( GLOBAL.PopupDialogScreen( GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.BANCONFIRM_TITLE.." "..displayName, GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.BANCONFIRM_BODY.." "..displayName.."?", { {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.OK, cb = function() SendModRPCToServer(MOD_RPC[modname]["dropeverything"], v.userid) GLOBAL.TheNet:Ban(v.userid) GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end}, {text=GLOBAL.STRINGS.UI.PLAYERSTATUSSCREEN.CANCEL, cb = function() GLOBAL.TheFrontEnd:PopScreen() GLOBAL.TheFrontEnd:PopScreen() end} } ) ) end) end endend)I modify the function of the kick and ban buttons. Link to comment https://forums.kleientertainment.com/forums/topic/53756-only-drop-inventory-if-playerdays-is-below-a-certain-thresholdbanned/#findComment-636102 Share on other sites More sharing options...
DarkXero Posted May 10, 2015 Share Posted May 10, 2015 Update:local TableNet = GLOBAL.getmetatable(GLOBAL.TheNet).__indexlocal old = TableNet.KickTableNet.Kick = function(self, userid) print("My code would go here!") return old(self, userid)endlocal old2 = TableNet.BanTableNet.Ban = function(self, userid) print("My other code would go here!") return old2(self, userid)endhttp://forums.kleientertainment.com/topic/53790-overwriting-a-function-in-thenet/?p=636274 Link to comment https://forums.kleientertainment.com/forums/topic/53756-only-drop-inventory-if-playerdays-is-below-a-certain-thresholdbanned/#findComment-636275 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