My problem is my detective items (Grappling hook, and DNA scanner) If you drop them then it just spawns a new one and leads to the items being duped over and and over.
I need some help making it not give a new one if it's dropped
I tried
SWEP.AutoSpawnable = false
SWEP.AllowDrop = true
but that didn't do it.
here are the respective shared.lua files if anyone could please help.
Grappling Hook
[CODE]SWEP.Author = "Darkfortune"
SWEP.Contact = "Darkfortune202@gmail.com"
SWEP.Purpose = "The Spiderman's Swep!"
SWEP.Instructions = "Left click to fire a rope"
SWEP.Base = "weapon_tttbase"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.PrintName = "Grappling Hook"
SWEP.Slot = 7
SWEP.SlotPos = 7
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.AutoSpawnable = false
SWEP.AllowDrop = true
SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.InLoadoutFor = { ROLE_DETECTIVE }
local sndPowerUp = Sound("rope_hit.wav")
local sndPowerDown = Sound ("shoot_rope.wav")
function SWEP:Initialize()
nextshottime = CurTime()
self:SetWeaponHoldType( "pistol" )
end
function SWEP:Think()
if (!self.Owner || self.Owner == NULL) then return end
if ( self.Owner:KeyPressed( IN_ATTACK ) ) then
self:StartAttack()
elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then
self:UpdateAttack()
elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then
self:EndAttack( true )
end
if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then
self:Attack2()
end
end
function SWEP:DoTrace( endpos )
local trace = {}
trace.start = self.Owner:GetShootPos()
trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096)
if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end
trace.filter = { self.Owner, self.Weapon }
self.Tr = nil
self.Tr = util.TraceLine( trace )
end
function SWEP:StartAttack()
local gunPos = self.Owner:GetShootPos()
local disTrace = self.Owner:GetEyeTrace()
local hitPos = disTrace.HitPos
local x = (gunPos.x - hitPos.x)^2;
local y = (gunPos.y - hitPos.y)^2;
local z = (gunPos.z - hitPos.z)^2;
local distance = math.sqrt(x + y + z);
local distanceCvar = GetConVarNumber("rope_distance")
inRange = false
if distance <= distanceCvar then
inRange = true
end
if inRange then
if (SERVER) then
if (!self.Beam) then
self.Beam = ents.Create( "rope" )
self.Beam:SetPos( self.Owner:GetShootPos() )
self.Beam:Spawn()
end
self.Beam:SetParent( self.Owner )
self.Beam:SetOwner( self.Owner )
end
self:DoTrace()
self.speed = 10000
self.startTime = CurTime()
self.endTime = CurTime() + self.speed
self._dt = -1
if (SERVER && self.Beam) then
self.Beam:GetTable():SetEndPos( self.Tr.HitPos )
end
self:UpdateAttack()
self.Weapon:EmitSound( sndPowerDown )
else
end
end
function SWEP:UpdateAttack()
self.Owner:LagCompensation( true )
if (!endpos) then endpos = self.Tr.HitPos end
if (SERVER && self.Beam) then
self.Beam:GetTable():SetEndPos( endpos )
end
lastpos = endpos
if ( self.Tr.Entity:IsValid() ) then
endpos = self.Tr.Entity:GetPos()
if ( SERVER ) then
self.Beam:GetTable():SetEndPos( endpos )
end
end
local vVel = (endpos - self.Owner:GetPos())
local Distance = endpos:Distance(self.Owner:GetPos())
local et = (self.startTime + (Distance/self.speed))
if(self._dt != 0) then
self._dt = (et - CurTime()) / (et - self.startTime)
end
if(self._dt < 0) then
self.Weapon:EmitSound( sndPowerUp )
self._dt = 0
end
if(self._dt == 0) then
zVel = self.Owner:GetVelocity().z
vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7))
if( SERVER ) then
local gravity = GetConVarNumber("sv_Gravity")
vVel:Add(Vector(0,0,(gravity/100)*1.5))
if(zVel < 0) then
vVel:Sub(Vector(0,0,zVel/100))
end
self.Owner:SetVelocity(vVel)
end
end
endpos = nil
self.Owner:LagCompensation( false )
end
function SWEP:EndAttack( shutdownsound )
if ( shutdownsound ) then
self.Weapon:EmitSound( sndPowerDown )
end
if ( CLIENT ) then return end
if ( !self.Beam ) then return end
self.Beam:Remove()
self.Beam = nil
end
function SWEP:Attack2()
if (CLIENT) then return end
local CF = self.Owner:GetFOV()
if CF == 90 then
self.Owner:SetFOV(30,.3)
elseif CF == 30 then
self.Owner:SetFOV(90,.3)
end
end
function SWEP:Holster()
self:EndAttack( false )
return true
end
function SWEP:OnRemove()
self:EndAttack( false )
return true
end
function SWEP:PrimaryAttack()
end
function SWEP:SecondaryAttack()
end[/CODE]
DNA scanner
[CODE]-- DNA Scanner
if SERVER then
AddCSLuaFile( "shared.lua" )
end
SWEP.HoldType = "normal"
if CLIENT then
SWEP.PrintName = "dna_name"
SWEP.Slot = 8
SWEP.ViewModelFOV = 10
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "dna_desc"
};
SWEP.Icon = "VGUI/ttt/icon_wtester"
end
SWEP.Base = "weapon_tttbase"
SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel = "models/props_lab/huladoll.mdl"
SWEP.DrawCrosshair = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Delay = 1
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 2
SWEP.Kind = WEAPON_ROLE
SWEP.CanBuy = nil -- no longer a buyable thing
SWEP.WeaponID = AMMO_WTESTER
--SWEP.LimitedStock = true
SWEP.InLoadoutFor = {ROLE_DETECTIVE}
SWEP.AllowDrop = true
SWEP.AutoSpawnable = false
SWEP.NoSights = true
SWEP.Range = 175
SWEP.ItemSamples = {}
SWEP.NowRepeating = nil
local MAX_ITEM = 30
SWEP.MaxItemSamples = MAX_ITEM
local CHARGE_DELAY = 0.1
local CHARGE_RATE = 3
local MAX_CHARGE = 1250
local SAMPLE_PLAYER = 1
local SAMPLE_ITEM = 2
AccessorFuncDT(SWEP, "charge", "Charge")
AccessorFuncDT(SWEP, "last_scanned", "LastScanned")
if CLIENT then
CreateClientConVar("ttt_dna_scan_repeat", 1, true, true)
else
function SWEP:GetRepeating()
local ply = self.Owner
return IsValid(ply) and ply:GetInfoNum("ttt_dna_scan_repeat", 1) == 1
end
end
SWEP.NextCharge = 0
function SWEP:SetupDataTables()
self:DTVar("Int", 0, "charge")
self:DTVar("Int", 1, "last_scanned")
return self.BaseClass.SetupDataTables(self)
end
function SWEP:Initialize()
self:SetCharge(MAX_CHARGE)
self:SetLastScanned(-1)
if CLIENT then
self:AddHUDHelp("dna_help_primary", "dna_help_secondary", true)
end
return self.BaseClass.Initialize(self)
end
local beep_miss = Sound("player/suit_denydevice.wav")
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
-- will be tracing against players
self.Owner:LagCompensation(true)
local spos = self.Owner:GetShootPos()
local sdest = spos + (self.Owner:GetAimVector() * self.Range)
local tr = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner, mask=MASK_SHOT})
local ent = tr.Entity
if IsValid(ent) and (not ent:IsPlayer()) then
if SERVER then
if ent:IsPlayer() then
--self:GatherPlayerSample(ent)
elseif ent:GetClass() == "prop_ragdoll" and ent.killer_sample then
if CORPSE.GetFound(ent, false) then
self:GatherRagdollSample(ent)
else
self:Report("dna_identify")
end
elseif ent.fingerprints and #ent.fingerprints > 0 then
self:GatherObjectSample(ent)
else
self:Report("dna_notfound")
end
end
else
Disallow dropping it then?
Well I still want it to be able to be dropped, I just don't want it to spawn a new one.
Bump for help
anyone?
Sorry, you need to Log In to post a reply to this thread.