Hi all;
I added the viewmodel for hands to applejack. It works perfect, but on every model they are the same.
How can I other hands to other playermodels?
Thanks,
Darrell
You need to have a "SWEP.UseHands" option that is marked as "true". Are the viewmodel hands imbedded inside the viewmodel itself? Because, that wouldn't be the right way.
I'm not talking about sweps.
The hands are working, however they are all the same on every model.
When a player switeches job his hands should change to the hands of that model. But because Applejack doesn't have a player_manager.lua where the hands get connected to the models using a name, there is no way to connect the hands to the model in applejack. How could I make that possible?
Oh okay, I looked in the player_manager.lua in "lua/includes/modules", and it says there are two strings; AddValidModel and AddValidHands.
[CODE]AddValidModel( "male01", "models/player/Group01/male_01.mdl" )
AddValidHands( "male01", "models/weapons/c_arms_citizen.mdl", 1, "0000000" )
[/CODE]
I suppose that the model name for your "Applejack" has to connect to the string. If the playermodel is named "applejack", the [B]AddValidHands[/B] need to have "applejack" and then the modelname of the hands. Those other two numbers are for skingroups and bodygroups respectively.
You know that applejack is a gamemode?
That AddValidModel and AddValidHands are not possible in Applejack because it has no player_manager.lua. So you're unable to connect to hands to the model.
[QUOTE=Darrell;45358656]You know that applejack is a gamemode?
That AddValidModel and AddValidHands are not possible in Applejack because it has no player_manager.lua. So you're unable to connect to hands to the model.[/QUOTE]
player_manager.lua is available in all gamemodes.
[QUOTE=Robotboy655;45358717]player_manager.lua is available in all gamemodes.[/QUOTE]
If I add player_manager.lua to it, add all the models and hands, and spawn using job, will it auto change the hands too?
[QUOTE=Darrell;45358839]If I add player_manager.lua to it, add all the models and hands, and spawn using job, will it auto change the hands too?[/QUOTE]
You don't add it, it is used by default. It is shipped with GMod by default. If the gamemode is not using the correct hooks, that's its problem.
[lua]
-- Called when a player initially spawns.
function GM:PlayerInitialSpawn(ply)
if ( IsValid(ply) ) then
ply:LoadData();
ply._ModelChoices = {}
for _,team in pairs(hl2rp2.team.stored) do
for gender,models in pairs(team.models) do
ply._ModelChoices[gender] = ply._ModelChoices[gender] or {}
if #models ~= 1 then
ply._ModelChoices[gender][team.index]
= math.random(1,#models)
else
ply._ModelChoices[gender][team.index] = 1
end
end
end
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
-- PrintTable(player._ModelChoices)
-- print(#player._ModelChoices)
timer.Simple(0.2,function(ply)
--[[ print"------------------"
print"------------------"
print("Starting model choices for "..player:Name()..".")
print"------------------"
print"------------------"
]] if IsValid(ply) then
umsg.Start("hl2rp2_ModelChoices",ply)
umsg.Short(table.Count(ply._ModelChoices))
for name,gender in pairs(ply._ModelChoices) do
-- print("name","amount")
-- print(name,#gender)
umsg.String(name)
umsg.Short(#gender)
for team,choice in ipairs(gender) do
-- print("team","choice")
-- print(team,choice)
umsg.Short(team)
umsg.Short(choice)
end
end
umsg.End()
net.Start("hl2rp2_Laws")
net.WriteTable(hl2rp2.laws.stored)
net.Send(ply)
else
--ErrorNoHalt"!!!\n"
--print(player)
end
end,ply)
-- A table to store every contraband entity.
local contraband = {}
-- Loop through each contraband class.
for k, v in pairs( self.Config["Contraband"] ) do
table.Add( contraband, ents.FindByClass(k) )
end
-- Loop through all of the contraband.
for k, v in pairs(contraband) do
if (ply:UniqueID() == v._UniqueID) then v:SetPlayer(ply) end
end
-- Kill them silently until we've loaded the data.
ply:KillSilent()
else
timer.Simple(0.2,function(ply)
ply._Timeout = ply._Timeout or 0
ply._Timeout = ply._Timeout + 1
if ply._Timeout <= 300 then
GAMEMODE:PlayerInitialSpawn(ply)
else
print("player timeout in PlayerInitialSpawn()")
end
end,ply)
end
end
[/lua]
[lua]
-- Hands!
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
[/lua]
[lua]
TEAM_LEADER = hl2rp2.team.add("Leader", Color(0, 0, 255, 255), "models/player/breen.mdl", "models/player/mossman.mdl", {gang = 1, access = "bdgeD", level = 3, group = GROUP_OFFICIALS},"Runs city17 and keeps it in shape.", 300, 1, nil, true, nil, {CATEGORY_WEAPONS,CATEGORY_ILLEGAL_GOODS,CATEGORY_ILLEGAL_WEAPONS,CATEGORY_POLICE_WEAPONS,CATEGORY_EXPLOSIVES},{0,10})
[/lua]
Will the hands now sync with it's playermodel?
Replace
[code]
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[/code]
with
[code]
ply:SetupHands()[/code]
Awesome, but the handmodels doesn't change to it's job model. How can I do that?
Call ply:SetupHands() after the player model has changed.
This works, but I don't have to tell you that.
Dude you're awesome. Thanks you so much!
Sorry, you need to Log In to post a reply to this thread.