• Attaching props to players (hats)
    7 replies, posted
I've seen many people create "hats" which when used appear on the player's head. Could someone please explain to me how I could do this? Thank you.
Usually Pac3 Or Pointshop addons that the server has... as well as Expression 2
Create a clientsideprop and I'm a PostPlayerDraw hook set the position of it to the players head (which you can find by using Player:LookupBone("bone name")).
[QUOTE=YourStalker;50553252]Create a clientsideprop and I'm a PostPlayerDraw hook set the position of it to the players head (which you can find by using Player:LookupBone("bone name")).[/QUOTE] Would this be the best way to do it? [CODE]hook.Add("PostPlayerDraw", "BackPack", function(ply) local backpack = ents.CreateClientProp( "models/fallout 3/campish_pack.mdl" ) backpack:SetPos(ply:GetBonePosition(1)) end)[/CODE]
From looking at the documentation on the wiki, you would need to do something like this - correct me if I'm wrong. NOTE: I haven't tested any of this - I just read up on the wiki and made an attempt. [CODE]hook.Add( "PostPlayerDraw", "SomeHookName", function( ply ) if( !IsValid( ply ) )then return end if( ply == LocalPlayer() )then return end -- remove this if you want the client to see their own hat. if( !ply:Alive() )then return end if( !IsValid( ply.hat ) )then ply.hat = ents.CreateClientProp() ply.hat:SetParent( ply ) ply.hat:SetModel( "my_prop.mdl" ) ply.hat:Spawn() end local vector, angle = ply:GetBonePosition( ply:LookupBone( ValveBiped.Bip01_Head1 ) ) ply.hat:SetPos( vector ) ply.hat:SetAngles( angle ) end )[/CODE]
[QUOTE=Joshpai;50584147]From looking at the documentation on the wiki, you would need to do something like this - correct me if I'm wrong. NOTE: I haven't tested any of this - I just read up on the wiki and made an attempt. [CODE]hook.Add( "PostPlayerDraw", "SomeHookName", function( ply ) if( !IsValid( ply ) )then return end if( ply == LocalPlayer() )then return end -- remove this if you want the client to see their own hat. if( !ply:Alive() )then return end if( !IsValid( ply.hat ) )then ply.hat = ents.CreateClientProp() ply.hat:SetParent( ply ) ply.hat:SetModel( "my_prop.mdl" ) ply.hat:Spawn() end local vector, angle = ply:GetBonePosition( ply:LookupBone( ValveBiped.Bip01_Head1 ) ) ply.hat:SetPos( vector ) ply.hat:SetAngles( angle ) end )[/CODE][/QUOTE] It will work just make sure to put the lookupbone in quotes
You could try moving them to the desired position once and then running [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/FollowBone]Entity:FollowBone[/url] to finish the job.
[QUOTE=dannyf127;50579304]Would this be the best way to do it? [CODE]hook.Add("PostPlayerDraw", "BackPack", function(ply) local backpack = ents.CreateClientProp( "models/fallout 3/campish_pack.mdl" ) backpack:SetPos(ply:GetBonePosition(1)) end)[/CODE][/QUOTE] Danny taking my backpack idea?
Sorry, you need to Log In to post a reply to this thread.