Basically I've have a prop launcher but I'd like to use it for TTT and can't figure out how to limit the ammo on it since it's PrimaryAttack function creates a prop. Is there a way to limit the calls to that function?
This is what I have for firing the prop
[CODE]
function SWEP:FireProp(model)
local tr = self.Owner:GetEyeTrace()
self.Weapon:EmitSound(ShootSound)
self.BaseClass.ShootEffects(self)
if not SERVER then return end
local ent = ents.Create("prop_physics")
ent:SetModel(model)
ent:SetPos(self.Owner:EyePos())
ent:SetOwner(self.Owner)
local ang = self.Owner:EyeAngles()
ang:RotateAroundAxis(ang:Up(), 90)
ang:RotateAroundAxis(ang:Forward(), 90)
ent:SetAngles(ang)
ent:Spawn()
ent:SetColor(math.Rand(0, 1) * 255, math.Rand(0, 1) * 255, math.Rand(0, 1) * 255, 255)
local phys = ent:GetPhysicsObject()
phys:SetMass(500)
phys:SetMaterial("gmod_bouncy")
local shot_length = tr.HitPos:Length()
phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(shot_length, 3))
cleanup.Add(self.Owner, "props", ent)
undo.Create("Dildooo")
undo.AddEntity(ent)
undo.SetPlayer(self.Owner)
undo.Finish()
end
function SWEP:PrimaryAttack()
self:FireProp("models/xero/cookie/cookie.mdl")
end[/CODE]
Just do something like
[lua]
SWEP.CookieAmmo = 5
function SWEP:PrimaryAttack()
if self.CookieAmmo <= 0 then return end
self:FireP..
self.CookieAmmo = self.CookieAmmo - 1
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.