Well, im just now starting to get into the wonders of gmod contributing. Right now I have about a %0.05 knowledge of lua. But the code is fimilar as i am good with flash's actionscript and San andreas multiplayer pawno scripting. But to the problem:
Well, for a first try, I used a 9mm luger i found for CSS. I followed a bunch of hexing tutorials and everything turned out so good so far. Until i get to teh SWEP'ing part that envolves lua. I tried using SWEP generators for my first go. And it has worked. When i get ingame for my luger, theres no icon but its in the weapons menu okay. But when I spawn it...
1st off, its apparently in the left hand.
2nd, theres no firing sound. The download did not come with any scripts. I tried copying 1 from another weapon that did, but no dice.
3rd, for some odd reason, theres a secondary fire enabled and it blasts out rapid shotgun shells.
Heres the lua code:
[code]
//General Variables\\
SWEP.AdminSpawnable = true
SWEP.ViewModelFOV = 64
SWEP.ViewModel = "models/weapons/v_pist_luge.mdl"
SWEP.WorldModel = "models/weapons/w_pist_luge.mdl"
SWEP.AutoSwitchTo = false
SWEP.Slot = 1
SWEP.HoldType = "Pistol"
SWEP.PrintName = "9mm Luger"
SWEP.Author = "Sgt.Pepper"
SWEP.Spawnable = true
SWEP.AutoSwitchFrom = false
SWEP.FiresUnderwater = true
SWEP.Weight = 5
SWEP.DrawCrosshair = true
SWEP.Category = "Weapons"
SWEP.SlotPos = 0
SWEP.DrawAmmo = true
SWEP.Instructions = "addons folder."
SWEP.Contact = "none"
SWEP.Purpose = "A kewl WWII gun"
SWEP.base = "weapon_base"
//General Variables\\
//Primary Fire Variables\\
SWEP.Primary.Sound = "sound\weapons\luger\luger-1.wav"
SWEP.Primary.Damage = 56
SWEP.Primary.TakeAmmo = 1
SWEP.Primary.ClipSize = 8
SWEP.Primary.Ammo = "pistol"
SWEP.Primary.DefaultClip = 32
SWEP.Primary.Spread = 0.1
SWEP.Primary.NumberofShots = 1
SWEP.Primary.Automatic = true
SWEP.Primary.Recoil = 0.6
SWEP.Primary.Delay = 0.6
SWEP.Primary.Force = 3
//Primary Fire Variables\\
//SWEP:Initialize()\\
function SWEP:Initialize()
util.PrecacheSound(self.Primary.Sound)
util.PrecacheSound(self.Secondary.Sound)
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType )
end
end
//SWEP:Initialize()\\
//SWEP:PrimaryFire()\\
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumberofShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
bullet.Tracer = 0
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
local rnda = self.Primary.Recoil * -1
local rndb = self.Primary.Recoil * math.random(-1, 1)
self:ShootEffects()
self.Owner:FireBullets( bullet )
self.Weapon:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end
//SWEP:PrimaryFire()\\
//SWEP:SecondaryFire()\\
function SWEP:SecondaryFire()
return false
end
//SWEP:SecondaryFire()\\
[/code]
I just want to get help with this and get my sweps and possibly future models working.
[editline]08:10PM[/editline]
Oh shi-, i realized this is not the right forum. Can a mod move this to the lua forum?
Sorry, you need to Log In to post a reply to this thread.