Entity.LookupAttachment

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:LookupAttachment( String attachmentName )
Description:
Converts an attachment name to an attachment ID. If 0 is returned, an attachment by the given name couldn't be found on this entity's model.
Returns: Integer
In Object: Entity
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.LookupAttachment]Entity.LookupAttachment [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionGet the attachmentID of a players head, then convert it to an attachment, and return the position.
Used onNewerClient.png
Code
function GetOurAttachment(ply) // Create a selfmade function, that takes 1 argument.
local ID = ply:LookupAttachment("eyes") // this will return a number corresponding with the given attachment.
return ply:GetAttachment( ID ) // this will return a small table, see GetAttachment for more information.
end // end our function.
 
function GetHeadPos() // create yet another function.
LocalPlayer():ChatPrint("The position of your own head is: "..tostring(GetOurAttachment(LocalPlayer()).Pos).."!") // call our earlier function, and get the position from it so we can display it in our chat.
end // and end this one as well.
OutputThe position of your own head is: 8938.7734 1442.3248 -6127.0186!


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox