G.DropEntityIfHeld

From GMod Wiki

Jump to: navigation, search
Function
Syntax DropEntityIfHeld( Entity HeldEntity )
Where is this used?
Description:
Causes a player to drop an entity being held with a Gravity Gun.
Returns: nil
Part of Library: Global Functions
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.DropEntityIfHeld]G.DropEntityIfHeld [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDetermine whether or not a player is allowed to 'punt' an entity with the Gravity gun and drop the entity if not.
Used onNewerServer.png
Code
function gravgunPunt( userid, target )
	if userid:IsAdmin() then
		return true // Only let admins punt items.
	else
		if SERVER then
			 DropEntityIfHeld( target ) end // Drop the entity
		end
		return false // Don't let the minge's punt items at people!
	end
end
 
hook.Add( "GravGunPunt", "gravgunPunt", gravgunPunt )
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox