SWEP Shooting invisible grenades?

[lua]SWEP.Author = “Scipher”
SWEP.Contact = “sciphersp@yahoo.com
SWEP.Purpose = “Abakan Assault Rifle”
SWEP.Instructions = “Primary to fire a bullet.”
SWEP.Category = “SWeps”

SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;

SWEP.ViewModel = “models/srp/weapons/v_fn2000.mdl”;
SWEP.WorldModel = “models/srp/weapons/w_fn2000.mdl”;

SWEP.Primary.ClipSize = 30; – Clip Size
SWEP.Primary.DefaultClip = 30; – Extra Ammo
SWEP.Primary.Automatic = true; – Automatic or single shot
SWEP.Primary.Ammo = “ar2”; – What kind of ammo the gun takes

SWEP.Secondary.ClipSize = 1; – see above
SWEP.Secondary.DefaultClip = 3; – see above
SWEP.Secondary.Automatic = false; – see above
SWEP.Secondary.Ammo = “smg1_grenade”; – see above
SWEP.Secondary.Model = “models/FoodNHouseholdItems/cake.mdl”

SWEP.Sound = Sound (“ak47-1.wav”)
SWEP.Damage = 65
SWEP.Spread = 0.02
SWEP.NumBul = 1
SWEP.Delay = 0.7
SWEP.Force = 3

function SWEP:Deploy()
return true
end

function SWEP:Holster()
return true
end

function SWEP:Think()
end

function SWEP:PrimaryAttack() – when +attack1 happens

–Make sure we can shoot first if ( !self:CanPrimaryAttack() ) then return end
if ( !self:CanPrimaryAttack() ) then return end

local bullet = {} – creates a table for the properties of the bullet
bullet.Num = self.NumBul – number of bullets you are shooting
bullet.Src = self.Owner:GetShootPos() – source, where your standing
bullet.Dir = self.Owner:GetAimVector() – direction of bullet, where your looking
bullet.Spread = Vector( self.Spread, self.Spread, 0 ) --spread of bullet, how accurate spread is
bullet.Tracer = 0 – no effect
bullet.Force = self.Force – how powerful it is
bullet.Damage = self.Damage – how much damage it does to people
bullet.AmmoType = self.Primary.Ammo – what type of ammo used

self.Owner:FireBullets( bullet ) – actually shoots the bullet

self:EmitSound ( self.Sound )
– this makes the sound, specified earlier

self.BaseClass.ShootEffects (self);
– this makes the shooting animation for the 357 view/world model

self:SetNextPrimaryFire( CurTime() + self.Delay )
–sets time for next fire

self:TakePrimaryAmmo(1) – removes 1 ammo from clip when shot
end

function SWEP:SecondaryAttack()

if ( !self:CanPrimaryAttack() ) then return end

local bullet = {}
bullet.Num = self.NumBul
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Spread, self.Spread, 0 )
bullet.Tracer = 0
bullet.Force = self.Force
bullet.Damage = self.Damage
bullet.AmmoType = self.Secondary.Ammo

self:SetNextSecondaryFire( CurTime() + self.Delay )
– This sets the delay for the next fires

self:TakeSecondaryAmmo(1) – removes 1 ammo from our clip

end – end of function

function SWEP:Reload()
self:DefaultReload( ACT_VM_RELOAD )
end

– Put self.whatever when inside functions, SWEP.whatever when outside funcs.
[/lua]

Can anyone help me with this? Primary fire works fine, but my secondary is supposed to shoot a grenade, and the grenade is invisible and doesn’t blow up, but removes a secondary ammo. This is with or without the secondary.ammo.model line, help?

EDIT: I added the BulletFire line to the secondary fire function, derp, but now it fires an SMG bullet ?

It doesn’t shoot a grenade because you don’t have any code to create said grenade in your secondary fire function…

All there is is a bullet table and some SWEP functions - you need to code in the grenade launching.

  • snip -
    Nevermind, just some weird javascript crap that showed up.

Why is this in there?



<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.className;if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>

[lua]Blahblah.Email = “it_shows_up@for_only_emails.com”
Blahblah.but = “it fails because the javascript is corrupted”[/lua]
^Huh, it showed it on the preview, but not when I actually post it. strange.

I snipped my post because it was exactly what you mentioned.

[editline]12/9/2011 2:07[/editline]
second test:
[lua]Blahblah.Email = “test@yahoo.com
Blahblah.but = “it fails because the javascript is corrupted”[/lua]

[editline]9th December 2011[/editline]

Wizard of Ass do you have a plugin that automatically rates everything on a page dumb?