• Custom SWEP with Fists viewmodel?
    13 replies, posted
So I have a "hands" swep for an RP gamemode, and I want to replace the view model with the Fists viewmodel and animations. The following does not work: SWEP.ViewModel = "models/weapons/c_arms_citizen.mdl"; How can I make this possible? Also, I want it so that until the player primary fires, the player stands still instead of being in a fighting stance. The default FISTS swep also doesn't have a viewmodel, does any1 know what is the cause of this?
Try This [CODE]function SWEP:PreDrawViewModel( vm, wep, ply ) vm:SetMaterial( "engine/occlusionproxy" ) end[/CODE]
Didn't work :(
Have a look at default hands swep in gmod.
[QUOTE=Robotboy655;41044286]Have a look at default hands swep in gmod.[/QUOTE] Even the default SWEP doesn't have a viewmodel, I guess it's some other problem. Do you have any idea?
This might help: [url]http://wiki.garrysmod.com/page/Using_Viewmodel_Hands[/url]
"If a player model doesn't have a corresponding hands entry, it will default to the civilian hands." So, I'm guessing I don't need to use "AddValidHands" I tried: [code] local pMeta = FindMetaTable("Player") function pMeta:GetHandsModel() return { model = "models/weapons/c_arms_citizen.mdl", skin = 1, body = "0100000" } end [/code] But no avail.
[QUOTE=superdodo12;41044934]"If a player model doesn't have a corresponding hands entry, it will default to the civilian hands." So, I'm guessing I don't need to use "AddValidHands" I tried: [code] local pMeta = FindMetaTable("Player") function pMeta:GetHandsModel() return { model = "models/weapons/c_arms_citizen.mdl", skin = 1, body = "0100000" } end [/code] But no avail.[/QUOTE]I though you were making a SWEP, where did this come from? [editline]15th June 2013[/editline] Try using the same view model as you have now but also set the world model to " " and add SWEP:UseHands = true as well as the code that AirBlack suggested.
I literally just made a duplicate swep using the Fists code and still no view model.
Bump...still have the problem :(
[QUOTE=superdodo12;41056055]Bump...still have the problem :([/QUOTE]Did you try my suggestion in the edit to my last post?
@ShadowRanger, Yes I did, it seems that hands just don't work in my custom gamemode. They work in single player.
To your GM:PlayerSpawn [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] To your GM:PostDrawViewModel, cl_init.lua [code] function GM:PostDrawViewModel( vm, ply, weapon ) if weapon.UseHands or (not weapon:IsScripted()) then local hands = LocalPlayer():GetHands() if IsValid(hands) then hands:DrawModel() end end end[/code] Why don't you just learn how other gamemodes did it?
[QUOTE=Robotboy655;41056472]To your GM:PlayerSpawn [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] To your GM:PostDrawViewModel, cl_init.lua [code] function GM:PostDrawViewModel( vm, ply, weapon ) if weapon.UseHands or (not weapon:IsScripted()) then local hands = LocalPlayer():GetHands() if IsValid(hands) then hands:DrawModel() end end end[/code] Why don't you just learn how other gamemodes did it?[/QUOTE] Thanks a lot, I really should have just searched through other gamemodes. Next time, I'll do that before making a help thread. :)
Sorry, you need to Log In to post a reply to this thread.