Need Help With A script

Bassicly,Iam Trying to make A currently equipped swep/Entity Stay with the player if they quit and rejoin Would anyone know how to do that?

You would have to write the entities to a file or database

Untested, but should work fine.


local players = {}

hook.Add("PlayerDisconnected", "SaveWeps", function(ply)
	local weps = ply:GetWeapons() // returns table with weapons
	local tbl = {}
	for _, wep in pairs(weps) do
		if IsValid(wep) then
			table.insert(tbl, wep:GetClass())
		end
	end
	// So we're saving all weapons to the table on player disconnect.
	players[ply:SteamID()] = tbl
end)

hook.Add("PlayerInitialSpawn", "LoadoutSavedWeps", function(ply) 
	// And here we're giving them back
	local weps = players[ply:SteamID()]
	if weps then
		for _, wep in pairs(weps) do
			ply:Give(wep)
		end
		players[ply:SteamID()] = nil
	end
end)

Alright thanks,But How could someone do it with a currently equipped entity such as a equipped helmet

How is the helmet entity being applied to the player? Parented? Is there an accessor function you could call that would see if the player has a helmet?

[editline]5th August 2015[/editline]

Until the server crashes/goes down :v:

Using a function called “ArmorUpdate”

What’s done in there? Is it parented to the player?

It sets playermodel

Give the section of code that runs when the helmet is applied

function ENT:Use(activator,caller)
if(activator:IsPlayer())then
if((not(activator.Armor.Helmet))and(not(activator.Armor.Suit)))then
ArmorUpdate(activator,“Helmet”,“HelmetA”,self:GetColor())
activator:EmitSound(“Flesh.ImpactSoft”)
JackaGenericUseEffect(activator)
self:Remove()
end
end
end

Player.Armor.Helmet is what you want to see it the player has it

He should change that because Armor is already a function on the player meta. Unless he turns Armor into a metatable and sets __call to the old Player.Armor function, he’ll break a lot of stuff.