• Player models uses different hands
    14 replies, posted
How can i change my player models so when they are holding a gun it will look like there hands And im on my server TTT
Place this in the playerspawn hook([B]GM:PlayerSpawn[/B]) [CODE]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 ply:SetHands( hands ) hands:SetOwner( ply ) -- Which hands should we use? local cl_playermodel = ply:GetInfo( "cl_playermodel" ) local info = player_manager.TranslatePlayerHands( cl_playermodel ) if ( info ) then hands:SetModel( info.model ) hands:SetSkin( info.skin ) hands:SetBodyGroups( info.body ) end -- Attach them to the viewmodel local vm = ply:GetViewModel( 0 ) hands:AttachToViewmodel( vm ) vm:DeleteOnRemove( hands ) ply:DeleteOnRemove( hands ) hands:Spawn() end end[/CODE] And paste this in your cl_init this is the viewmodel : [CODE]function GM:PostDrawViewModel( vm, ply, weapon ) if ( weapon.UseHands || !weapon:IsScripted() ) then local hands = LocalPlayer():GetHands() if ( IsValid( hands ) ) then hands:DrawModel() end end end[/CODE]
Just to make sure where is gm hook [editline]16th January 2014[/editline] Can you tell me where to put it for a TTT server [editline]16th January 2014[/editline] please [editline]16th January 2014[/editline] well i tried doing what you said but i just got !weapons then srcds crashed
Searched for GM:PlayerSpawn on the TTT Git (Your name suggests it so w/e) terrortown / gamemode / player.lua Line 56 (On the newest rev)
Ok let me see if this works
[QUOTE=Royal's TTT;43567339]should i replace the code thats there with the one she gave me?[/QUOTE] Remove the section where it defines hands (lines 88-100 on the git) [URL="http://i.imgur.com/XlHjrGi.png"]Funny because he's a guy :v:[/URL]
Ok im startin up my server Thanks for the Help sir/mam [editline]16th January 2014[/editline] hold up [editline]16th January 2014[/editline] i get a error when i set up my game
Post your GM:PlayerSpawn func
i got a new problem now [editline]16th January 2014[/editline] [error] gamemodes/terrortown/gamemode/player.lua:1157: 'end' expected <to close 'function' at line 58> near '<eof>' 1. unknown - gamemodes/terrortown/gamemode/player.lua:0
You deleted a needed 'end' to close off the function Still waiting for that code
function GM:PlayerSpawn(ply) -- Some spawns may be tilted ply:ResetViewRoll() -- Clear out stuff like whether we ordered guns or what bomb code we used ply:ResetRoundFlags() -- latejoiner, send him some info if GetRoundState() == ROUND_ACTIVE then SendRoundState(GetRoundState(), ply) end [editline]16th January 2014[/editline] the other problem was fixed [editline]16th January 2014[/editline] this is where its at now
[code]function GM:PlayerSpawn(ply) -- Some spawns may be tilted ply:ResetViewRoll() -- Clear out stuff like whether we ordered guns or what bomb code we used ply:ResetRoundFlags() -- latejoiner, send him some info if GetRoundState() == ROUND_ACTIVE then SendRoundState(GetRoundState(), ply) end ply.spawn_nick = ply:Nick() ply.has_spawned = true -- let the client do things on spawn net.Start("TTT_PlayerSpawned") net.WriteBit(ply:IsSpec()) net.Send(ply) if ply:IsSpec() then ply:StripAll() ply:Spectate(OBS_MODE_ROAMING) return end ply:UnSpectate() -- ye olde hooks hook.Call("PlayerLoadout", GAMEMODE, ply) hook.Call("PlayerSetModel", GAMEMODE, ply) local oldhands = ply:GetHands() if ( IsValid( oldhands ) ) then oldhands:Remove() end local hands = ents.Create( "gmod_hands" ) if ( IsValid( hands ) ) then ply:SetHands( hands ) hands:SetOwner( ply ) -- Which hands should we use? local cl_playermodel = ply:GetInfo( "cl_playermodel" ) local info = player_manager.TranslatePlayerHands( cl_playermodel ) if ( info ) then hands:SetModel( info.model ) hands:SetSkin( info.skin ) hands:SetBodyGroups( info.body ) end -- Attach them to the viewmodel local vm = ply:GetViewModel( 0 ) hands:AttachToViewmodel( vm ) vm:DeleteOnRemove( hands ) ply:DeleteOnRemove( hands ) hands:Spawn() end SCORE:HandleSpawn(ply) end[/code] That's it in it's entirety, including the wanted changes
im checking now [editline]16th January 2014[/editline] I get a error [editline]16th January 2014[/editline] do i have to replace any thing in init
[QUOTE=Royal's TTT;43567693]im checking now do i have to replace any thing in init[/QUOTE] Yes. You're changing this [code] function GM:PlayerSpawn(ply) -- Some spawns may be tilted ply:ResetViewRoll() -- Clear out stuff like whether we ordered guns or what bomb code we used ply:ResetRoundFlags() -- latejoiner, send him some info if GetRoundState() == ROUND_ACTIVE then SendRoundState(GetRoundState(), ply) end ply.spawn_nick = ply:Nick() ply.has_spawned = true -- let the client do things on spawn net.Start("TTT_PlayerSpawned") net.WriteBit(ply:IsSpec()) net.Send(ply) if ply:IsSpec() then ply:StripAll() ply:Spectate(OBS_MODE_ROAMING) return end ply:UnSpectate() -- ye olde hooks hook.Call("PlayerLoadout", GAMEMODE, ply) hook.Call("PlayerSetModel", GAMEMODE, ply) local oldhands = ply:GetHands() if IsValid(oldhands) then oldhands:Remove() end local hands = ents.Create( "gmod_hands" ) if IsValid(hands) then ply:SetHands(hands) hands:SetOwner(ply) -- Find model and attach to vm, currently ours ply:SetPlayerHands(ply) ply:DeleteOnRemove(hands) hands:Spawn() end SCORE:HandleSpawn(ply) end[/code] To this [code] function GM:PlayerSpawn(ply) -- Some spawns may be tilted ply:ResetViewRoll() -- Clear out stuff like whether we ordered guns or what bomb code we used ply:ResetRoundFlags() -- latejoiner, send him some info if GetRoundState() == ROUND_ACTIVE then SendRoundState(GetRoundState(), ply) end ply.spawn_nick = ply:Nick() ply.has_spawned = true -- let the client do things on spawn net.Start("TTT_PlayerSpawned") net.WriteBit(ply:IsSpec()) net.Send(ply) if ply:IsSpec() then ply:StripAll() ply:Spectate(OBS_MODE_ROAMING) return end ply:UnSpectate() -- ye olde hooks hook.Call("PlayerLoadout", GAMEMODE, ply) hook.Call("PlayerSetModel", GAMEMODE, ply) local oldhands = ply:GetHands() if ( IsValid( oldhands ) ) then oldhands:Remove() end local hands = ents.Create( "gmod_hands" ) if ( IsValid( hands ) ) then ply:SetHands( hands ) hands:SetOwner( ply ) -- Which hands should we use? local cl_playermodel = ply:GetInfo( "cl_playermodel" ) local info = player_manager.TranslatePlayerHands( cl_playermodel ) if ( info ) then hands:SetModel( info.model ) hands:SetSkin( info.skin ) hands:SetBodyGroups( info.body ) end -- Attach them to the viewmodel local vm = ply:GetViewModel( 0 ) hands:AttachToViewmodel( vm ) vm:DeleteOnRemove( hands ) ply:DeleteOnRemove( hands ) hands:Spawn() end SCORE:HandleSpawn(ply) end[/code] If you can't grasp that Learn to program and basic logic, even the slightest helps
This does not work
Sorry, you need to Log In to post a reply to this thread.