Jump to content

Recommended Posts

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.

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 checking

player.components.age.GetAgeInDays() > somenumber

Something 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	endend

then 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 :p.

local banned = falsefor k,v in pairs(TheNet:GetBlacklist()) do	if player.userid == v.userid then		banned = true		break	endend
Edited by Sarcen
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.

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)end

http://forums.kleientertainment.com/topic/53790-overwriting-a-function-in-thenet/?p=636274

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...