Entity.SetPhysicsAttacker

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:SetPhysicsAttacker( Player )
Description:
Sets the player who gets credit if this entity kills something with physics damage.
Returns: nil
In Object: Entity
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.SetPhysicsAttacker]Entity.SetPhysicsAttacker [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionFires a sawblade for which the player gets kill credit.
Used onNewerShared.png
Code
function SWEP:PrimaryAttack()
	if CLIENT then return end
	local blade = ents.Create("prop_physics")
	blade:SetModel("models/props_junk/sawblade001a.mdl")
	blade:SetPos(self.Owner:GetShootPos())
	blade:SetAngles(self.Owner:EyeAngles())
	blade:SetOwner(self.Owner)
	blade:SetPhysicsAttacker(self.Owner)
	blade:Spawn()
	local bPhy = blade:GetPhysicsObject()
	if bPhy:IsValid() then
		bPhy:ApplyForceCenter(self.Owner:GetAimVector() * 120000)
	end
	blade:Fire("kill",0,3)
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox