Spawn an entity with a input variable?

I want to make an entity that a player drops when they’re dead. When another player picks it up they will receive their equipment.

I need a way to input a table or variable into a spawned entity.

Any suggestions?

[lua]function ENT:Initialize()
– This function isn’t necessary but shows how variables can be set before the entity is initialized

-- This part removes the entity if EquipmentClass hasn't been set
-- It's not necessary either but makes sure nothing weird can happen
if not self.EquipmentClass then
	print("spawned entity", self, "without an equipment class, removing")
	self:Remove()
	return
end

print("spawned entity", self, "equipment class = ", self.EquipmentClass)

end

function ENT:Use(activator)
– When a player presses USE on us, give them whatever we’re supposed to give
– then disappear
activator:Give(self.EquipmentClass)
self:Remove()
end
[/lua]

[lua]local ent = ents.Create(“sent_whatever”)
ent:SetPos(pos)
ent:SetAngles(ang)

– Set your variables here
ent.EquipmentClass = “weapon_crowbar”

– This is when Initialize gets called
ent:Spawn()[/lua]

Hopefully that’s self explanatory enough. By the way, just a piece of advice:

http://vinh.peniscorp.com/2014-05-16_11-05-43.png

While it is ok to ask for help here, you are asking a lot of questions about fairly trivial things that you could have easily figured out by experimenting or by doing some research on the wiki. Most of the things you want to do are also used in many gamemodes and addons, so you might be interested in downloading a few interesting ones and figuring out how they work. You can extract workshop addons using this.

There’s only so much a forum can do for you, you’ll understand things a lot better if you take some effort to figure them out on your own.

You’re right, I do use the forums quite a bit, but the last few questions have legitimately boggled my head. I have investigated this method by opening the spawned_shipments entity in darkrp and I thought maybe some of you skilled coders can explain it differently than the code.

For the record the last thread I posted was a problem caused from an external script which told all entities if used return false end, which prevented me from properly executing my entities.