Entity.SetOwner

From GMod Wiki

Revision as of 15:35, 30 October 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:SetOwner( Entity )
Description:
Sets the 'owner' of an entity. This disables collision between the entity and its owner. If the prop kills another entity, the owner of the prop will be the inflictor and will get credit for the kill.
Returns: nil
In Object: Entity
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.SetOwner]Entity.SetOwner [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Notepad-48.png Entity:SetOwner should not normally be used unless you want to disable collision between two entities. Sure, Entity:GetOwner gets what's set by Entity:SetOwner, but Entity:SetOwner also disables collisions and gives kill credit to the "owner". If you simply want to give kill credit, use Entity:SetPhysicsAttacker


Examples

DescriptionSets target entity to be owned by you
Used onNewerServer.png
Code
function ownd(ply)
local tr = utilx.GetPlayerTrace( ply, ply:GetCursorAimVector() )
local trace = util.TraceLine( tr )
trace.Entity:SetOwner(ply)
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox