Skip to content

Instantly share code, notes, and snippets.

@samuelmaddock
Last active December 17, 2015 00:19
Show Gist options
  • Save samuelmaddock/5520502 to your computer and use it in GitHub Desktop.
Save samuelmaddock/5520502 to your computer and use it in GitHub Desktop.
Alternate implementation of Garry's Mod view model hands without using player classes.
function GM:PostDrawViewModel( vm, ply, weapon )
if ( !IsValid( weapon ) ) then return false end
if ( weapon.UseHands || !weapon:IsScripted() ) then
local hands = ply:GetHands()
if ( IsValid( hands ) ) then
hands:DrawModel()
end
end
if ( weapon.PostDrawViewModel == nil ) then return false end
return weapon:PostDrawViewModel( vm, weapon, ply )
end
function GM:PlayerSpawn( ply )
local oldhands = ply:GetHands();
if ( IsValid( oldhands ) ) then
oldhands:Remove()
end
local hands = ents.Create( "gmod_hands" )
if ( IsValid( hands ) ) then
hands:DoSetup( ply )
hands:Spawn()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment