Thompson Contender G2 Reloading without Reloading...
1 replies, posted
I can't find anything wrong with the code, but when you fire a shot, the animation for reloading plays without the gun actually reloading. You have to manually initiate a reload either by left clicking or hitting your reload key. Any ideas?
[url]http://pastebin.com/PYBUTtNf[/url]
[CODE]---- Example TTT custom weapon
-- First some standard GMod stuff
if SERVER then
AddCSLuaFile( "shared.lua" )
end
if CLIENT then
SWEP.PrintName = "Thompson Contender G2"
SWEP.Slot = 1 -- add 1 to get the slot number key
SWEP.Kind = WEAPON_PISTOL
SWEP.ViewModelFOV = 72
SWEP.ViewModelFlip = false
end
-- Always derive from weapon_tttbase.
SWEP.Base = "weapon_tttbase"
--- Standard GMod values
SWEP.HoldType = "pistol"
SWEP.Primary.Delay = 1.5
SWEP.Primary.Recoil = 7
SWEP.Primary.Automatic = false
SWEP.Primary.Damage = 74
SWEP.Primary.Cone = 0.000
SWEP.Primary.Ammo = "357"
SWEP.Primary.ClipSize = 1
SWEP.Primary.ClipMax = 1
SWEP.Primary.DefaultClip = 10
SWEP.Primary.Sound = Sound("weapons/g2/g2_shot_hum.wav")
SWEP.Secondary.Sound = Sound("Default.Zoom")
SWEP.HeadshotMultiplier = 4
SWEP.IronSightsPos = Vector( 6.05, -5, 2.4 )
SWEP.IronSightsAng = Vector( 2.2, -0.1, 0 )
SWEP.ViewModel = "models/weapons/v_snip_g2_hum.mdl"
SWEP.WorldModel = "models/weapons/w_snip_g2_hum.mdl"
--- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_PISTOL
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "item_ammo_357_ttt"
-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_DETECTIVE }
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil
-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true
-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true
-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false
-- Equipment menu information is only needed on the client
if CLIENT then
-- Path to the icon material
SWEP.Icon = "vgui/ttt/icon_ms_contender.png"
-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Thompson G2 Contender Handheld Rifle",
desc = "Description"
};
end
-- Tell the server that it should download our icon to clients.
if SERVER then
-- It's important to give your icon a unique name. GMod does NOT check for
-- file differences, it only looks at the name. This means that if you have
-- an icon_ak47, and another server also has one, then players might see the
-- other server's dumb icon. Avoid this by using a unique name.
resource.AddFile("materials/VGUI/ttt/icon_humility_ttt_g2.vmt")
end
function SWEP:SetZoom(state)
if CLIENT then
return
elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
if state then
self.Owner:SetFOV(20, 0.3)
else
self.Owner:SetFOV(0, 0.2)
end
end
end
function SWEP:SecondaryAttack()
if not self.IronSightsPos then return end
if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
bIronsights = not self:GetIronsights()
self:SetIronsights( bIronsights )
if SERVER then
self:SetZoom(bIronsights)
else
self:EmitSound(self.Secondary.Sound)
end
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end
function SWEP:PreDrop()
self:SetZoom(false)
self:SetIronsights(false)
return self.BaseClass.PreDrop(self)
end
function SWEP:Reload()
self.Weapon:DefaultReload( ACT_VM_RELOAD );
self:SetIronsights( false )
self:SetZoom(false)
end
function SWEP:Holster()
self:SetIronsights(false)
self:SetZoom(false)
return true
end
if CLIENT then
local scope = surface.GetTextureID("scope/gdcw_scopesight2") ----- sprites/gdcw_scopesight for SNIPERS
function SWEP:DrawHUD()
if self:GetIronsights() then
surface.SetDrawColor( 0, 0, 0, 255 )
local x = ScrW() / 2
local y = ScrH() / 2
local scope_size = ScrH()
-- scope
surface.SetTexture(scope)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
else
return self.BaseClass.DrawHUD(self)
end
end
function SWEP:AdjustMouseSensitivity()
return (self:GetIronsights() and 0.2) or nil
end
end[/CODE]
My weapon :D
As far as I know, it's a problem with the animations. You might be able to fix it by calling self:Reload() in the weapons SWEP:PrimaryAttack() function.
[lua]
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:EmitSound( self.Primary.Sound )
self:ShootBullet( self.Primary.Damage, 1, self.Primary.Cone )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
self:Reload()
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.