I'm having a strange issue right now where the view model of the tool gun will appear to be the world model. The only thing that's missing is the hand holding it. I've written a small script in an attempt to debug this issue:
[lua]
local function WhatsMyVM( ply, cmd, args )
local ent = ply:GetViewModel()
if IsValid( ent ) then
local mdl = ent:GetModel()
print( "Current view model: "..mdl )
end
local wep = ply:GetActiveWeapon()
if IsValid( wep ) then
print( "You are currently holding "..wep:GetClass() )
print( "Wep's model is: "..wep:GetModel() )
print( "The weapons table is as follows:" )
PrintTable( wep:GetTable() )
end
end
concommand.Add( "ldrp_dbgvm", WhatsMyVM, nil, "Prints the view model and other information of the currently held weapon." )
[/lua]
Which outputs the following (minus the table):
[quote]
Current view model: models/weapons/c_toolgun.mdl
You are currently holding gmod_tool
Wep's model is: models/weapons/w_toolgun.mdl
[/quote]
As I understand it, c_toolgun is supposed to be a proper view model. However, for what ever reason, my game mode is still drawing it as the world model. I don't have gmod_tool defined in my game mode's entities/weapons folder, nor can I think of anything that would override the view model (without somehow changing what GetViewModel() receives).
I know this is really shooting in the dark, but can anyone think of any code that might be changing the tool gun's view model in a such a way that the game doesn't seem to [i]perceive[/i] it as being changed?
Is this when you are using the built in toolgun, or a weapon with the toolgun model?
If it's a weapon, you could try adding SWEP.UseHands = true
If it's the built in toolgun, sorry but I don't know what would cause that.
You said that the hand holding it is missing. I think you can only have the hands if you either declare the player class or reroute the functions.
[QUOTE=Icebomb;40822706]You said that the hand holding it is missing. I think you can only have the hands if you either declare the player class or reroute the functions.[/QUOTE]
What do you mean by declare the player class or reroute the functions?
[QUOTE=tgp1994;40822739]What do you mean by declare the player class or reroute the functions?[/QUOTE]
Hopefully I'm not reading what you posted wrong.
In [base/gamemode/player_class/player_default]:
[CODE]
function PLAYER:Spawn()
local oldhands = self.Player:GetHands();
if ( IsValid( oldhands ) ) then
oldhands:Remove()
end
local hands = ents.Create( "gmod_hands" )
if ( IsValid( hands ) ) then
hands:DoSetup( self.Player )
hands:Spawn()
end
end
[/CODE]
If you set the player class to that (player_manager.SetPlayerClass( ply, "player_default" )) and you make sure to run the Spawn function, the hands spawn. Thats what the hands really are in the c_ viewmodels: Its an entity.
What I mean by rerouting the functions is if you don't want to use the classes, you just have to take that stuff and just put it in the gamemode spawn or whatever.
And yeah, make sure you do this if it is a weapon:
[QUOTE=wh1t3rabbit;40822547]
If it's a weapon, you could try adding SWEP.UseHands = true
[/QUOTE]
Shoot, I had no idea the hands were actually an entity. You were right Icebomb, in fact, there were several things wrong with what I was doing. For one, I wasn't calling the base class of PlayerSpawn (so like you said, I was actually re-routing a few important functions). Besides that, I was not setting the player class. Now that I have that all fixed up, the hands are back. This whole player class thing looks really interesting!
Thanks for helping me out, guys.
Sorry, you need to Log In to post a reply to this thread.