DarkRP F4 Entities are World entities

So this really bugs me that all things bought from the f4 menu are world entities.
I understand why some of them need to be.
Is there a way to make a singe item from the F4 menu a player entity not a world entity?
Like for example, making printers player entities but not gun shipments?

Thanks, Xunofar

Tell it to CPPISetOwner() to the buyer when it spawns.

[sp]Yes, I realize CPPISetOwner is unsupported but still, it might work.[/sp]

so where would i put this? does it go in the entities.lua?

-BUMP- Still need this fixed!!



hook.Add("playerBoughtCustomEntity", "SetOwnerOnEntBuy", function(ply, enttbl, ent, price)

	ent:CPPISetOwner(ply)

end)


CPPI is supported by FPP.

ok so by putting this where? the entity? or in fpp files?

Make a new file in lua/autorun/server called setentityowner.lua. Put the code in there.

ok, thanks for this. But i have one concern. I want to have it for certain entities. Is this possible?

Yes, make a table of the entities, the key being their class and the value being true so:



local entTable = { ["ent_1"] = true, ["ent_2"] = true }


Make sure you create that table outside of the hook to save resources

Then have a check inside the hook:



if entTable[ent:GetClaas()] then
	ent:CPPISetOwner(ply)
end


Thank you for this!!! I will try it out!

can someone come up with a fix for this it doesnt work anymore

[editline]3rd April 2015[/editline]

hook.Add(“playerBoughtCustomEntity”, “SetOwnerOnEntBuy”, function(ply, enttbl, ent, price)

ent:CPPISetOwner(ply)

end)

This doesnt work ive tested it

just use anon’s post

Is there an error? Have you checked to see if the hook is being called by adding a print statement?

it does load in but it doesnt set the entity owner , when you physgun it it comes with the blocked name