• SWEP questions
    8 replies, posted
Hey guys. I run a TTT server, and I made a custom SWEP for it (Jihad Bomb). I know that some of you think that it's a horrible idea, but please ignore that fact, and help me if you can. Basically, there are two problems with it: Problem 1: The world model is inside the player's thighs. Problem 2: The view model animation doesn't work. All I need you to help me with is: 1. Find a way to set the world model position of the bomb to be seen in the player's hand (he holds it like a grenade). 2. Make it play the view model animation when the player presses the primary fire. Here is a link to the SWEP I based it off of - [url]http://www.garrysmod.org/downloads/?a=view&id=33601[/url]
Please, I need an answer for this as fast as possible.
Can you post your code?
[lua] resource.AddFile( "sound/siege/jihad.wav" ); resource.AddFile( "sound/siege/big_explosion.wav" ); resource.AddFile( "models/weapons/v_jb.mdl" ); resource.AddFile( "models/weapons/v_jb.dx80" ); resource.AddFile( "models/weapons/v_jb.dx90" ); resource.AddFile( "models/weapons/v_jb.sw.vtx" ); resource.AddFile( "models/weapons/v_jb.vvd" ); resource.AddFile( "models/weapons/w_jb.mdl" ); resource.AddFile( "models/weapons/w_jb.dx80" ); resource.AddFile( "models/weapons/w_jb.dx90" ); resource.AddFile( "models/weapons/w_jb.sw.vtx" ); resource.AddFile( "models/weapons/w_jb.vvd" ); resource.AddFile( "models/weapons/w_jb.phy" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb1.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb1.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb1_planted.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb1_ref.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb2.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb2.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb3b.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb3b.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/and.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/hand.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_04.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_04.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_45.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_45.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_active.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_active.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_off.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_off.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_off_ref.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_on.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_on.vtf" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/screen_on_ref.vtf" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/bomb1.vmt" ); resource.AddFile( "materials/models/weapons/v_models/pr0d.c4/bomb1_planted.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/bomb2.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/bomb3b.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/hand.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/screen_04.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/screen_45.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/screen_active.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/screen_on.vmt" ); resource.AddFile( "materials/models/weapons/w_models/pr0d.c4/screen_off.vmt" ); if SERVER then AddCSLuaFile("shared.lua") resource.AddFile("materials/VGUI/ttt/icon_jihad.vmt") end SWEP.HoldType = "slam" SWEP.Base = "weapon_tttbase" SWEP.WeaponID = JIHAD_BOMB if CLIENT then SWEP.PrintName = "Jihad Bomb" SWEP.Slot = 6 SWEP.ViewModelFOV = 72 SWEP.ViewModelFlip = false SWEP.Icon = "VGUI/ttt/icon_jihad" SWEP.EquipMenuData = { type = "Weapon", desc = "Perfect to take out\nlarge amounts of innocents,\nas well as yourself." }; end SWEP.Primary.Delay = 0.08 SWEP.Primary.Recoil = 1.9 SWEP.Primary.Automatic = false SWEP.Primary.Damage = 20 SWEP.Primary.Cone = 0.025 SWEP.Primary.Ammo = "none" SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Sound = Sound( "sound/siege/jihad.wav" ) SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.ViewModel = "models/weapons/v_jb.mdl" SWEP.WorldModel = "models/weapons/w_jb.mdl" SWEP.Kind = WEAPON_EQUIP1 SWEP.AutoSpawnable = false SWEP.AmmoEnt = "none" SWEP.CanBuy = { ROLE_TRAITOR } SWEP.InLoadoutFor = nil SWEP.LimitedStock = true SWEP.AllowDrop = true SWEP.IsSilent = false SWEP.NoSights = true function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + 3) if (SERVER) then timer.Simple(2, function() self:Explode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) self.AllowDrop = false self.Owner:ResetLuaAnimation("Jihad_Scare") end end function SWEP:Explode() local k, v local ent = ents.Create( "env_explosion" ) ent:SetPos( self.Owner:GetPos() ) ent:SetOwner( self.Owner ) ent:Spawn() ent:SetKeyValue( "iMagnitude", "250" ) ent:Fire( "Explode", 0, 0 ) ent:EmitSound( "siege/big_explosion.wav", 500, 500 ) self:Remove() self.Owner:Kill( ) for k, v in pairs( player.GetAll( ) ) do v:ConCommand( "play siege/big_explosion.wav" ) end end function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire( CurTime() + 1 ) local TauntSound = Sound( "vo/npc/male01/overhere01.wav" ) self.Weapon:EmitSound( TauntSound ) if (!SERVER) then return end self.Weapon:EmitSound( TauntSound ) end function SWEP:Initialize() util.PrecacheSound("siege/big_explosion.wav") util.PrecacheSound("siege/jihad.wav") self:SetWeaponHoldType("slam") end function SWEP:Reload() return false end function SWEP:Think() end [/lua]
[QUOTE=Bumbanut;28479679]1. Find a way to set the world model position of the bomb to be seen in the player's hand (he holds it like a grenade). [/QUOTE] [url]http://www.facepunch.com/threads/1032378-SWEP-Construction-Kit-developer-tool-for-modifying-viewmodels-ironsights[/url]
[QUOTE=Brandan;28519663][url]http://www.facepunch.com/threads/1032378-SWEP-Construction-Kit-developer-tool-for-modifying-viewmodels-ironsights[/url][/QUOTE]I tried that. Doesn't seem to work. I need an easier fix that doesn't require mods and stuff. On top of that, I need help with the other problems. Please help me.
Have you tried changing the SWEP.Holdtype to "grenade" instead of "slam"? Here this might work for problem #2 (line #7) [lua] function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + 3) if (SERVER) then timer.Simple(2, function() self:Explode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // Try adding this line in self.AllowDrop = false self.Owner:ResetLuaAnimation("Jihad_Scare") end end [/lua] By the way if the hold style change doesn't fix that problem your probably going to need to parent it to the users hand bone.
[QUOTE=wazanator;28627625]Have you tried changing the SWEP.Holdtype to "grenade" instead of "slam"? Here this might work for problem #2 (line #7) [lua] function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + 3) if (SERVER) then timer.Simple(2, function() self:Explode() end ) self.Owner:EmitSound( "siege/jihad.wav" ) self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // Try adding this line in self.AllowDrop = false self.Owner:ResetLuaAnimation("Jihad_Scare") end end [/lua] By the way if the hold style change doesn't fix that problem your probably going to need to parent it to the users hand bone.[/QUOTE] I want the weapon to be hold like a slam. Either way, the first person animation now works, thanks for the help. I wanted to try to do that earlier, but thought that it wouldn't work. I dun goof'd. Now, I need to parent it to the user's hand bone. How exactly do I do that without mods?
Please, help me with this.
Sorry, you need to Log In to post a reply to this thread.