1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Something is wrong with my code..

Discussion in 'DarkRP Modding Questions & Help' started by Szhweetie, Jan 12, 2018.

  1. Szhweetie

    Szhweetie New Member

    Hello! Thanks for opening my thread and if you maybe know what i did wrong thats even more nice of you.
    Ok, so i tried to make a DarkRP custom scanner addon SWEP and the custom swep does not show up anywhere on my gmod so something is probobly wrong with my shared.lua file.

    Code:

    "
    if SERVER then

    AddCSLuaFile( "shared.lua" )

    SWEP.Weight = 2

    SWEP.AutoSwitchTo = true

    SWEP.AutoSwitchFrom = true

    SWEP.HoldType = "pistol"

    end



    if CLIENT then

    SWEP.PrintName = "Scanner"

    SWEP.Slot = 5

    SWEP.SlotPos = 1

    SWEP.DrawAmmo = false

    SWEP.DrawCrosshair = true

    end



    SWEP.Author = ""

    SWEP.Contact = ""

    SWEP.Purpose = "Scan area for illegal items"

    SWEP.Instructions = "Left click to scan the area you are pointing at for money printers and drug labs"



    SWEP.Spawnable = false

    SWEP.AdminSpawnable = true



    SWEP.ViewModel = "models/weapons/v_pistol.mdl"

    SWEP.WorldModel = "models/weapons/w_pistol.mdl"



    SWEP.Primary.ClipSize = -1

    SWEP.Primary.DefaultClip = -1

    SWEP.Primary.Automatic = false

    SWEP.Primary.Ammo = ""



    SWEP.Secondary.ClipSize = -1

    SWEP.Secondary.DefaultClip = -1

    SWEP.Secondary.Automatic = false

    SWEP.Secondary.Ammo = ""





    function SWEP:Reload()

    end



    local i = 1



    function SWEP:primaryAttack()

    self:SetNextPrimaryFire( CurTime() + 1 )

    self:SetNextSecondaryFire( CurTime() + 1 )



    local tr = self.Owner:GetEyeTrace()



    local dist = tr.HitPos:Distance( self.Owner:GetPos() )

    if dist > 400 or (tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer()) then

    if CLIENT then self.Owner:EmitSound( "buttons/button8.wav" ) end

    return

    end



    local bullet = {}

    bullet.Num = 0

    bullet.Src = self.Owner:GetShootPos() // Source

    bullet.Dir = self.Owner:GetAimVector() // Dir of bullet

    bullet.Spread = Vector( 0, 0, 0 ) // Aim Cone

    bullet.Tracer = 1 // Show a tracer on every x bullets

    bullet.TracerName = "ToolTracer" // what Tracer Effect should be used

    bullet.Force = 0 // Amount of force to give to phys objects

    bullet.Damage = 0

    bullet.Attacker = nil



    self.Owner:FireBullets( bullet )

    self:ShootEffects()



    if not SERVER then return end



    if SERVER then

    local hitPos = tr.HitPos

    local map = game.GetMap()

    local tbl = HCrime.BlacklistedScanner[ map ] or nil

    if tbl then

    for k, v in pairs( tbl ) do

    if hitPos.x <= math.max( v[ 1 ].x, v[ 2 ].x ) and hitPos.x >= math.min( v[ 1 ].x, v[ 2 ].x )

    and hitPos.y <= math.max( v[ 1 ].y, v[ 2 ].y ) and hitPos.y >= math.min( v[ 1 ].y, v[ 2 ].y )

    and hitPos.z <= math.max( v[ 1 ].z, v[ 2 ].z ) and hitPos.z >= math.min( v[ 1 ].z, v[ 2 ].z ) then

    self.Owner:EmitSound( "npc/scanner/combat_scan" .. math.random(1,4) .. ".wav" )

    DarkRP.notify( self.Owner, 1, 4, "You can't scan here!" )

    return

    end

    end

    end

    end





    -- if not self.Owner:isCP() then return end



    local found = false



    for k, v in pairs( ents.FindInSphere( tr.HitPos, 300 ) ) do

    if HCrime.illegal_entities[ v:GetClass() ] then

    HCrime.Commit( v.dt.owning_ent, HCrime.illegal_entities[ v:GetClass() ], v )

    found = true

    end

    end



    if found then

    self.Owner:EmitSound( "npc/scanner/combat_scan5.wav" )

    else

    self.Owner:EmitSound( "npc/scanner/combat_scan" .. math.random(1,4) .. ".wav" )

    end

    end



    function SWEP:SecondaryAttack()

    end
    ''
     
  2. Trinity

    Trinity Member

    Doesn't look like you ever called the object/entity. You specified the model but I don't see anything that calls for the object to be put anywhere.
     

Share This Page