• Shuriken Gun Glitch
    10 replies, posted
Hi. When I spawn or buy this shuriken it will not give the item or take take the credits. Here is the code: [CODE]if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "melee" end if ( CLIENT ) then SWEP.PrintName = "Shurikens" SWEP.Author = "Jaanus" SWEP.Slot = 1 SWEP.SlotPos = 7 SWEP.ViewModelFOV = 86 SWEP.IconLetter = "x" killicon.Add( "shuricon", "shuriken/deathicon", Color( 180, 0, 0, 255 ) ); killicon.AddAlias( "weapon_shuriken", "shuricon" ); killicon.AddAlias( "ent_shuriken", "shuricon" ); end ------------General Swep Info--------------- SWEP.Author = "Jaanus" SWEP.Contact = "Jaanus@jaanus.cc" SWEP.Purpose = "Kill stuff - Ninja style." SWEP.Instructions = "Left click throws a shuriken." SWEP.Spawnable = true SWEP.AdminSpawnable = true ----------------------------------------------- ------------Models--------------------------- SWEP.ViewModel = "models/jaanus/v_shuriken.mdl" SWEP.WorldModel = "models/jaanus/w_shuriken.mdl" ----------------------------------------------- -------------Primary Fire Attributes---------------------------------------- SWEP.Primary.Delay = 0.9 --In seconds SWEP.Primary.Recoil = 0.5 --Gun Kick SWEP.Primary.Damage = 100 --Damage per Bullet SWEP.Primary.NumShots = 1 --Number of shots per one fire SWEP.Primary.Cone = 0 --Bullet Spread SWEP.Primary.ClipSize = 1 --Use "-1 if there are no clips" SWEP.Primary.DefaultClip = -1 --Number of shots in next clip SWEP.Primary.Automatic = true --Pistol fire (false) or SMG fire (true) SWEP.Primary.Ammo = "none" --Ammo Type -------------End Primary Fire Attributes------------------------------------ -------------Secondary Fire Attributes------------------------------------- SWEP.Secondary.Delay = 0.9 SWEP.Secondary.Recoil = 0 SWEP.Secondary.Damage = 100 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Cone = 0 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" -------------End Secondary Fire Attributes-------------------------------- -- function SWEP:Reload() --To do when reloading -- end if ( CLIENT ) then function SWEP:GetViewModelPosition( pos, ang ) pos = pos + ang:Forward()*4 return pos, ang end end function SWEP:Think() -- Called every frame end function SWEP:Initialize() --util.PrecacheSound("physics/flesh/flesh_impact_bullet" .. math.random( 3, 5 ) .. ".wav") util.PrecacheSound("weapons/shuriken/throw1.wav") util.PrecacheSound("weapons/shuriken/throw2.wav") util.PrecacheSound("weapons/shuriken/throw3.wav") util.PrecacheSound("weapons/shuriken/throw4.wav") end function SWEP:PrimaryAttack() self.Weapon:EmitSound("weapons/shuriken/throw"..tostring( math.random( 1, 4 ) )..".wav") self.Weapon:SetNextPrimaryFire(CurTime() + 0.8) self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) if SERVER then local shuriken = ents.Create("ent_shuriken") shuriken:SetAngles(self.Owner:EyeAngles())-- Angle(0,90,0)) shuriken:SetPos(self.Owner:GetShootPos()) shuriken:SetOwner(self.Owner) shuriken:SetPhysicsAttacker(self.Owner) shuriken:Spawn() shuriken:Activate() local phys = shuriken:GetPhysicsObject() phys:SetVelocity(self.Owner:GetAimVector()*7000) phys:AddAngleVelocity(Vector(0,0,90)) end end[/CODE]
I don't see a weapon base being defined. If it's for TTT make sure you use that weapon base, and define who can buy it.
ok now i ge them, but it now does not give any damage when the round starts. Any suggestions?
yeah, I have the same weapon but it does not spawn at all for me either. What should I do? What did you do to fix it? Thanks! :) ~kpj
And it is suppose to break glass and stay in ammo packs, but it is glitching [editline]26th April 2013[/editline] By bouching off
[QUOTE='[TET] Tobias;40435569']And it is suppose to break glass and stay in ammo packs, but it is glitching [editline]26th April 2013[/editline] By bouching off[/QUOTE] How did you fix it? When I have sv_Cheats 1 on and try to spawn it nothing happens... :( am I doing something wrong? Thanks :P ~kpj 8)
What kind of server do you have? This is for a TTT server.
[QUOTE='[TET] Tobias;40436062']What kind of server do you have? This is for a TTT server.[/QUOTE] Yeah same a TTT server. Do you mind adding me on steam? Maybe you could help me out with this SWEP? Thanks, ~kpj 8)
It says they are suppose to get stuck in objects, but they bounce off and don't give damage to anyone
So now they will equip to you, and you can throw them, but when you throw them at someone it will not give them damage. With this swep you need an entry in the gamemode folder. Here is the entry: [QUOTE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() self:SetModel( "models/jaanus/shuriken_small.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) util.PrecacheSound("physics/metal/sawblade_stick3.wav") util.PrecacheSound("physics/metal/sawblade_stick2.wav") util.PrecacheSound("physics/metal/sawblade_stick1.wav") util.PrecacheSound("weapons/shuriken/hit1.wav") util.PrecacheSound("weapons/shuriken/hit2.wav") util.PrecacheSound("weapons/shuriken/hit3.wav") self.Hit = { Sound( "physics/metal/sawblade_stick1.wav" ), Sound( "physics/metal/sawblade_stick2.wav" ), Sound( "physics/metal/sawblade_stick3.wav" ) }; self.FleshHit = { Sound( "weapons/shuriken/hit1.wav" ), Sound( "weapons/shuriken/hit2.wav" ), Sound( "weapons/shuriken/hit3.wav" ) } self:GetPhysicsObject():SetMass( 2 ) end function ENT:Think() self.lifetime = self.lifetime or CurTime() + 20 if CurTime() > self.lifetime then self:Remove() end end function ENT:Disable() self.PhysicsCollide = function()end self.lifetime = CurTime() + 30 end function ENT:PhysicsCollide( data, phys ) if self:GetVelocity():Length() < 250 then self:Disable() return end local Ent = data.HitEntity if !(ValidEntity( Ent ) || Ent:IsWorld()) then return end if Ent:IsWorld() then if data.OurOldVelocity:Normalize():Dot( data.HitNormal ) > .5 then self:SetPos( data.HitPos ) self:SetAngles( data.OurOldVelocity:Angle() ) self:GetPhysicsObject():EnableMotion( false ) util.Decal( "ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal ) self:EmitSound( self.Hit[math.random(1,#self.Hit)] ); end self:Disable() elseif Ent.Health then if not(Ent:IsPlayer() || Ent:IsNPC() || Ent:GetClass() == "prop_ragdoll") then util.Decal( "ManhackCut", data.HitPos + data.HitNormal, data.HitPos - data.HitNormal ) self:EmitSound( self.Hit[math.random(1,#self.Hit)] ); end Ent:TakeDamage( 18, self:GetOwner() ) self:SetPos( data.HitPos ) self:SetParent( Ent ) Ent:DeleteOnRemove( self ) self:Disable() if (Ent:IsPlayer() || Ent:IsNPC() || Ent:GetClass() == "prop_ragdoll") then local effectdata = EffectData() effectdata:SetStart( data.HitPos ) effectdata:SetOrigin( data.HitPos ) effectdata:SetScale( 1 ) util.Effect( "BloodImpact", effectdata ) self:EmitSound( self.FleshHit[math.random(1,#self.Hit)] ); self:Remove() --Comment this line out if you want the shurikens to stick in ragdolls/npcs (shittily) end end end[/QUOTE]
[QUOTE='[TET] Tobias;40445198']So now they will equip to you, and you can throw them, but when you throw them at someone it will not give them damage. With this swep you need an entry in the gamemode folder. Here is the entry:[/QUOTE] You have like 3 threads open where you ask us to fix some bit of code for you. It's obvious you do not know how to code. This is the developer section. Hire a coder or learn it yourself.
Sorry, you need to Log In to post a reply to this thread.