Hey I haven't made a TTT SWEP in a REALLY long while so I thought i'd give it a shot.
So, I created this using the primary attack function but it dosnt seem to work, would anyone happen to have any pointers?
[code]
//General Settings \\
SWEP.AdminSpawnable = true
SWEP.ViewModelFOV = 64
SWEP.ViewModel = "models/props/cs_office/plant01.mdl"
SWEP.WorldModel = "models/props/cs_office/plant01.mdl"
SWEP.AutoSwitchTo = false
SWEP.Slot = 6
SWEP.HoldType = "Plant Disguiser Test"
SWEP.PrintName = "Plant Disguiser"
SWEP.Author = "kpj"
SWEP.Spawnable = true
SWEP.AutoSwitchFrom = false
SWEP.Weight = 5
SWEP.DrawCrosshair = true
SWEP.Category = "Stuffz"
SWEP.SlotPos = 6
SWEP.DrawAmmo = true
SWEP.ReloadSound = "Weapon_Pistol.Reload"
SWEP.Instructions = "Left click to disguise yourself as a Plant!"
SWEP.Contact = "test@fuckoff.org"
SWEP.Purpose = "Nothing at all"
SWEP.base = "weapon_tttbase"
SWEP.Kind = WEAPON_EQUIP1
SWEP.CanBuy = { ROLE_TRAITOR }
SWEP.AllowDrop = false
SWEP.LimitedStock = true
//General settings\\
//PrimaryFire Settings\\
SWEP.Primary.Sound = "Weapon_Pistol.Single"
SWEP.Primary.Damage = 0
SWEP.Primary.TakeAmmo = 1
SWEP.Primary.ClipSize = 5
SWEP.Primary.Ammo = "none"
SWEP.Primary.DefaultClip = 5
SWEP.Primary.Spread = 0.1
SWEP.Primary.NumberofShots = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Recoil = 1
SWEP.Primary.Delay = 0.1
SWEP.Primary.Force = 10
//PrimaryFire settings\\
//Secondary Fire Variables\\
SWEP.Secondary.NumberofShots = 1
SWEP.Secondary.Force = 10
SWEP.Secondary.Spread = 0.1
SWEP.Secondary.Sound = "Weapon_RPG.Single"
SWEP.Secondary.DefaultClip = 32
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "Pistol"
SWEP.Secondary.Recoil = 1
SWEP.Secondary.Delay = 0.2
SWEP.Secondary.TakeAmmo = 1
SWEP.Secondary.ClipSize = 10
SWEP.Secondary.Damage = 0
//Secondary 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
ply:SetModel( "models/props/cs_office/plant01.mdl" )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
end
//SWEP:PrimaryFire()\\
[/code]
All help is appreciated.
[CODE]function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumberofShots //The number of shots fired
bullet.Src = self.Owner:GetShootPos() //Gets where the bullet comes from
bullet.Dir = self.Owner:GetAimVector() //Gets where you're aiming
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
//The above, sets how far the bullets spread from each other.
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:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end [/CODE]
[QUOTE=crazymankills;42248784]Completely irrelevant code.[/QUOTE]
KPJ, you have to define ply somewhere and i'm assuming you're using the owner of the SWEP, so in this case your PrimaryAttack function would look something like this.
[lua]
function SWEP:PrimaryAttack()
local ply = self.Owner
if (!self:CanPrimaryAttack() or !IsValid(ply)) then return end
ply:SetModel("models/props/cs_office/plant01.mdl")
self:TakePrimaryAmmo(1)
end
[/lua]
[QUOTE=brandonj4;42248822]KPJ, you have to define ply somewhere and i'm assuming you're using the owner of the SWEP, so in this case your PrimaryAttack function would look something like this.
[lua]
function SWEP:PrimaryAttack()
local ply = self.Owner
if (!self:CanPrimaryAttack() or !IsValid(ply)) then return end
ply:SetModel("models/props/cs_office/plant01.mdl")
self:TakePrimaryAmmo(1)
end
[/lua][/QUOTE]
Ahh that makes alot of sense. Thanks!
I will test now.
[editline]19th September 2013[/editline]
[QUOTE=brandonj4;42248822]KPJ, you have to define ply somewhere and i'm assuming you're using the owner of the SWEP, so in this case your PrimaryAttack function would look something like this.
[lua]
function SWEP:PrimaryAttack()
local ply = self.Owner
if (!self:CanPrimaryAttack() or !IsValid(ply)) then return end
ply:SetModel("models/props/cs_office/plant01.mdl")
self:TakePrimaryAmmo(1)
end
[/lua][/QUOTE]
Edit: Alright sorry for another post but it was glitching out a bit (sorry for spam)
but anyways, it seems that it does not show up in the traitor menu, and when I try to spawn it (with sv_cheats on) Nothing happens. There is probably 1,000,000 why this happens but if you could lead me to some pointers on something I may have missed it would be very helpful!
Thanks again.
Sorry, you need to Log In to post a reply to this thread.