• Set the owner of an entity?
    7 replies, posted
How would I go about setting the owner of the entity to the person who spawned it? Currently I have a console command that spawns my entity. It is just a prop for now that can take damage. How can I set it so that I own this entity, and not the world / map when I spawn it?
[lua]Entity:SetOwner( Someone );[/lua]
[QUOTE=Walrus Viking;40490171][lua]Entity:SetOwner( Someone );[/lua][/QUOTE] This isn't actually how its done. I've tried this, and this simply disables collisions between the player and the entity. And the person can't physgun the object either. I'm talking about setting ownership, mainly in terms of prop protect. I use FPP, and FPP tells me who owns what prop, but even when I do that, it still says it's owned by world. Any other ways?
[lua]Entity.Owner = ply Entity.OwnerID = ply:SteamID()[/lua]
[QUOTE=Dreken;40490367]This isn't actually how its done. I've tried this, and this simply disables collisions between the player and the entity. And the person can't physgun the object either. I'm talking about setting ownership, mainly in terms of prop protect. I use FPP, and FPP tells me who owns what prop, but even when I do that, it still says it's owned by world. Any other ways?[/QUOTE] I had a whole thread about that problem and no one told me SHIT about that... Figured out the SetOwner being the cause on my own. I really think that function name needs to be changed.
[QUOTE=BL00DB4TH;40490692] Entity.Owner = ply Entity.OwnerID = ply:SteamID() [/QUOTE] I don't really understand how to implement this. This is my code: concommand.Add("SpawnRobot", function (ply) local mrobot = ents.Create("mrobot-isr-r1") mrobot:SetPos(ply:GetPos()+Vector(-50,0,50)) mrobot:SetAngles(Angle(0,0,0)) mrobot.Owner = ply mrobot.OwnerID = ply:SteamID() mrobot:Spawn() --ply:ChatPrint(tostring(mrobot:GetOwner())) end) The above works, however, it still registers as a world prop with FPP. Any advice?
[lua] concommand.Add("SpawnRobot", function(ply) local mrobot = ents.Create("mrobot-isr-r1") mrobot:SetPos(ply:GetPos()+Vector(-50,0,50)) mrobot:SetAngles(Angle(0,0,0)) mrobot:CPPISetOwner( ply ) mrobot:Spawn() --ply:ChatPrint(tostring(mrobot:GetOwner())) end) [/lua]
[QUOTE=Derek_SM;40492763][lua] concommand.Add("SpawnRobot", function(ply) local mrobot = ents.Create("mrobot-isr-r1") mrobot:SetPos(ply:GetPos()+Vector(-50,0,50)) mrobot:SetAngles(Angle(0,0,0)) mrobot:CPPISetOwner( ply ) mrobot:Spawn() --ply:ChatPrint(tostring(mrobot:GetOwner())) end) [/lua][/QUOTE] Thank you so much.
Sorry, you need to Log In to post a reply to this thread.