• Orbital Dubstep Cannon
    18 replies, posted
Hey guys, while making my version of the Dubstep Cannon (new sound, restructured the code a bit) I got this Errors: [CODE][ERROR] workshop/lua/weapons/weapon_ttt_odc/shared.lua:55: unexpected symbol near '=' 1. unknown - workshop/lua/weapons/weapon_ttt_odc/shared.lua:0[/CODE] This is my UPDATED code: [CODE]local ShootSound = Sound("odc/pre.wav") local FireSound = Sound("odc/shot.wav") local DropSound = Sound("odc/drop.wav") local FailSound = Sound("odc/fail.wav") local function around( val ) return math.Round( val * (10 ^ 3) ) / (10 ^ 3); end if SERVER then AddCSLuaFile("shared.lua") resource.AddFile("sound/odc/drop.wav") resource.AddFile("sound/odc/pre.wav") resource.AddFile("sound/odc/shot.wav") resource.AddFile("sound/odc/fail.wav") resource.AddFile("materials/beam/laser01.vmt") resource.AddFile("materials/beam/laser02d.vmt") resource.AddFile("materials/models/weapons/v_vikgun/energy.vmt") resource.AddFile("materials/models/weapons/v_vikgun/v_hand_sheet.vmt") resource.AddFile("materials/models/weapons/v_vikgun/vikgun.vmt") resource.AddFile("materials/vgui/ttt/glpcontroller.vmt") resource.AddFile("models/weapons/v_vikgun.mdl") SWEP.HoldType = "shotgun" end local function ValidTarget(ent) return IsValid(ent) and ent:GetMoveType() == MOVETYPE_VPHYSICS and ent:GetPhysicsObject() and (not ent:IsWeapon()) and (not ent:GetNWBool("punched", false)) --Cannot check for motion disabled on client end --Equipment menu information is only needed on the client if CLIENT then --Path to the icon material SWEP.Icon = "materials/vgui/ttt/glpcontroller" --Text shown in the equip menu SWEP.EquipMenuData = { type = "Orbital Weapon", desc = "Let the Dubstep Intro kick it!" }; end SWEP.Base = "weapon_tttbase" SWEP.PrintName = "Orbital Dubstep Cannon" SWEP.Icon = "vgui/ttt/glpcontroller.vmt" SWEP.Kind = WEAPON_EQUIP2 SWEP.AutoSpawnable = false SWEP.CanBuy = {ROLE_TRAITOR} SWEP.InLoadoutFor = SWEP.LimitedStock = true SWEP.AllowDrop = true SWEP.IsSilent = false SWEP.NoSights = true SWEP.Primary.Recoil = 5 SWEP.Primary.NumShots = 1 SWEP.Primary.ClipSize = 1 SWEP.Primary.DefaultClip = 1 SWEP.Primary.ClipMax = 1 SWEP.Primary.Automatic = false SWEP.Primary.Delay = 20 SWEP.ViewModel = "models/weapons/v_vikgun.mdl" SWEP.WorldModel = "models/weapons/w_irifle.mdl" SWEP.Slot = 8 SWEP.ViewModelFOV = 65 SWEP.ViewModelFlip = false SWEP.IsCharging = false SWEP.NextCharge = 0 AccessorFuncDT(SWEP, "charge", "Charge") local maxrange = 800 --making laser bigger? local math = math function SWEP:SetupDataTables() self:DTVar("Float", 0, "charge") end function SWEP:Initialize() return self.BaseClass.Initialize(self) end function SWEP:PreDrop() self.IsCharging = false self:SetCharge(0) -- OnDrop does not happen on client end if CLIENT then local linex = 0 local liney = 0 local laser = Material("trails/laser") function SWEP:ViewModelDrawn() local client = LocalPlayer() local vm = client:GetViewModel() if not IsValid(vm) then return end local plytr = client:GetEyeTrace(MASK_SHOT) local muzzle_angpos = vm:GetAttachment(1) local spos = muzzle_angpos.Pos + muzzle_angpos.Ang:Forward() * 10 local epos = client:GetShootPos() + client:GetAimVector() * maxrange -- Painting beam local tr = util.TraceLine({start=spos, endpos=epos, filter=client, mask=MASK_ALL}) local c = COLOR_WHITE local a = 255 if LocalPlayer():IsTraitor() then c = COLOR_WHITE a = 255 else c = COLOR_RED end local d = (plytr.StartPos - plytr.HitPos):Length() -- if tr.HitSky == true then -- c = COLOR_GREEN -- a = 255 -- else -- c = COLOR_YELLOW -- end -- render.SetMaterial(laser) render.DrawBeam(spos, tr.HitPos, 5, 0, 0, c) -- Charge indicator local vm_ang = muzzle_angpos.Ang local cpos = muzzle_angpos.Pos + (vm_ang:Up() * -4) + (vm_ang:Forward() * -18) + (vm_ang:Right() * -7) local cang = vm:GetAngles() cang:RotateAroundAxis(cang:Forward(), 90) cang:RotateAroundAxis(cang:Right(), 90) cang:RotateAroundAxis(cang:Up(), 90) cam.Start3D2D(cpos, cang, 0.05) surface.SetDrawColor(255, 55, 55, 50) surface.DrawOutlinedRect(0, 0, 50, 15) local sz = 48 local next = self.Weapon:GetNextPrimaryFire() local ready = (next - CurTime()) <= 0 local frac = 1.0 if not ready then frac = 1 - ((next - CurTime()) / 5) sz = sz * math.max(0, frac) end surface.SetDrawColor(255, 10, 10, 170) surface.DrawRect(1, 1, sz, 13) surface.SetTextColor(255,255,255,15) surface.SetFont("Default") surface.SetTextPos(10,0) surface.DrawText("Target") surface.SetDrawColor(0,0,0, 80) surface.DrawRect(linex, 1, 3, 13) surface.DrawLine(1, liney, 48, liney) linex = linex + 3 > 48 and 0 or linex + 1 liney = liney > 13 and 0 or liney + 1 cam.End3D2D() end local draw = draw end --Primary function SWEP:PrimaryAttack() local tr = self.Owner:GetEyeTrace() local tracedata = {} tracedata.start = tr.HitPos + Vector(0,0,0) tracedata.endpos = tr.HitPos + Vector(0,0,50000) tracedata.filter = ents.GetAll() local trace = util.TraceLine(tracedata) if trace.HitSky == true then hitsky = true else hitsky = true end if hitsky == true then self.Owner:SetAnimation( PLAYER_ATTACK1 ) self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self:EmitSound( ShootSound ) self:EmitSound( FireSound ) else self:EmitSound( FailSound ) end --The rest is only done on the server if (!SERVER) then return end if hitsky == true then --self:CreateHammer(tr.Entity, tr.HitPos) self:TakePrimaryAmmo(1) sound.Play("odc/pre.wav", tr.HitPos, 125, 100) sound.Play("odc/pre.wav", trace.HitPos, 100, 100) -- timer.Simple( 2.6, function() start(tr, trace, self) end) --TIMERS! timer.Simple( 30, function() kill(self) end) -- end end --SecondaryAttack function SWEP:SecondaryAttack() self:EmitSound( FireSound ) end --Reload function SWEP:Reload() self:EmitSound( FailSound ) end function start(tr, trace, self) local tracedata2 = {} tracedata2.start = trace.HitPos tracedata2.endpos = trace.HitPos + Vector(0,0,-50000) tracedata2.filter = ents.GetAll() local trace2 = util.TraceLine(tracedata2) self.glow = ents.Create("env_lightglow") self.glow:SetKeyValue("rendercolor", "255 255 255") self.glow:SetKeyValue("VerticalGlowSize", "50") self.glow:SetKeyValue("HorizontalGlowSize", "150") self.glow:SetKeyValue("MaxDist", "200") self.glow:SetKeyValue("MinDist", "1") self.glow:SetKeyValue("HDRColorScale", "100") self.glow:SetPos(trace2.HitPos + Vector(0,0,32)) self.glow:Spawn() self.glow2 = ents.Create("env_lightglow") self.glow2:SetKeyValue("rendercolor", "53 255 253") self.glow2:SetKeyValue("VerticalGlowSize", "100") self.glow2:SetKeyValue("HorizontalGlowSize", "100") self.glow2:SetKeyValue("MaxDist", "300") self.glow2:SetKeyValue("MinDist", "1") self.glow2:SetKeyValue("HDRColorScale", "100") self.glow2:SetPos(trace2.HitPos + Vector(0,0,32)) self.glow2:Spawn() self.glow3 = ents.Create("env_lightglow") self.glow3:SetKeyValue("rendercolor", "255 255 255") self.glow3:SetKeyValue("VerticalGlowSize", "10") self.glow3:SetKeyValue("HorizontalGlowSize", "30") self.glow3:SetKeyValue("MaxDist", "400") self.glow3:SetKeyValue("MinDist", "1") self.glow3:SetKeyValue("HDRColorScale", "100") self.glow3:SetPos(trace2.HitPos + Vector(0,0,27000)) self.glow3:Spawn() self.targ = ents.Create("info_target") self.targ:SetKeyValue("targetname", tostring(self.targ)) self.targ:SetPos(tr.HitPos + Vector( 0, 0, -50000 )) self.targ:Spawn() self.laser = ents.Create("env_laser") self.laser:SetKeyValue("texture", "beam/laser01.
Line 127: rename trace to tr And the function CreateHammer does not exist, you have to add the function.
[QUOTE]And the function CreateHammer does not exist, you have to add the function.[/QUOTE] So what should I add? I only have this code and no informations about, what is made for what :D
[QUOTE=craniel;50098977]So what should I add? I only have this code and no informations about, what is made for what :D[/QUOTE] Create the function yourself?
[QUOTE=smithy285;50099326]Create the function yourself?[/QUOTE] and if i don't know for what the function is? xD
[QUOTE=craniel;50099525]and if i don't know for what the function is? xD[/QUOTE] Well it seems your code is an edited version of another addon. Their code seems to have "CreateHammer" commented out: [url]https://github.com/Br0ly/TTT_Orbital_Bass_Cannon/blob/master/entities/weapons/weapon_ttt_OBC/shared.lua#L256[/url]
[QUOTE=smithy285;50099626]Well it seems your code is an edited version of another addon. Their code seems to have "CreateHammer" commented out: [url]https://github.com/Br0ly/TTT_Orbital_Bass_Cannon/blob/master/entities/weapons/weapon_ttt_OBC/shared.lua#L256[/url][/QUOTE] So you mean, i should just left it out?
[QUOTE=craniel;50099783]So you mean, i should just left it out?[/QUOTE] My crystal ball isn't working at the moment, so I'm afraid you will have to try it yourself and see if it works
[QUOTE=smithy285;50099822]My crystal ball isn't working at the moment, so I'm afraid you will have to try it yourself and see if it works[/QUOTE] Now I got this Error: [QUOTE] [ERROR] workshop/lua/weapons/weapon_ttt_odc/shared.lua:55: unexpected symbol near '=' 1. unknown - workshop/lua/weapons/weapon_ttt_odc/shared.lua:0 [/QUOTE] with the updated code above
[QUOTE=craniel;50100195]Now I got this Error: with the updated code above[/QUOTE] Are you joking? Look at line 54 and you MUST be able to see the issue
[QUOTE=smithy285;50100703]Are you joking? Look at line 54 and you MUST be able to see the issue[/QUOTE] What is the problem? the "nil" did not work, so i removed it (should work like a "nil")
[QUOTE=craniel;50100895]What is the problem? the "nil" did not work, so i removed it (should work like a "nil")[/QUOTE] No idea what you're talking about but this is the issue: SWEP.InLoadoutFor = You can't just having nothing, either delete the line or set it as true
[QUOTE=smithy285;50100979]No idea what you're talking about but this is the issue: SWEP.InLoadoutFor = You can't just having nothing, either delete the line or set it as true[/QUOTE] The error was there also with a "nil"
[QUOTE=craniel;50104540]The error was there also with a "nil"[/QUOTE] Remove the line or set it as false, you can not leave it blank
have a new code working, thanks to you guys
"Hey can you guys help me with this code I stole?" "Can you write it for me?" "OK I did it, but I'm not going to share how" People like you make me ashamed to call myself a programmer
[QUOTE=Mista_Epic;50161238]"Hey can you guys help me with this code I stole?" "Can you write it for me?" "OK I did it, but I'm not going to share how" People like you make me ashamed to call myself a programmer[/QUOTE] I know this thread is a trainwreck, but you've only just started Lua by the looks of it. [url]https://facepunch.com/showthread.php?t=1514890&p=50141065&viewfull=1#post50141065[/url] Don't be so quick to 'call yourself a programmer' and be an arse. You could have quite as easily looked up on how to use hooks, takes two seconds. [url]https://wiki.garrysmod.com/page/hook/Add[/url] [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index64f4.html#Explaining_Hooks[/url] [url]http://www.lua.org/pil/23.2.html[/url]
[QUOTE=Semajnad;50161500]I know this thread is a trainwreck, but you've only just started Lua by the looks of it. [url]https://facepunch.com/showthread.php?t=1514890&p=50141065&viewfull=1#post50141065[/url] Don't be so quick to 'call yourself a programmer' and be an arse. You could have quite as easily looked up on how to use hooks, takes two seconds. [url]https://wiki.garrysmod.com/page/hook/Add[/url] [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index64f4.html#Explaining_Hooks[/url] [url]http://www.lua.org/pil/23.2.html[/url][/QUOTE] Just because I don't have experience in LUA or GMod addon creation doesn't mean I'm not a programmer. Don't be quick to assume I have no experience in any other languages and make an arse out of yourself.
[QUOTE=Mista_Epic;50162181]Just because I don't have experience in LUA or GMod addon creation doesn't mean I'm not a programmer. Don't be quick to assume I have no experience in any other languages and make an arse out of yourself.[/QUOTE] My point stands. I actually didn't assume you hadn't used other languages, although my wording was bad. My point stands that you make a sarky comment like that, and yet you ask to be spoon fed too. Just pointing it out. Your the one making an arse outta yourself.
Sorry, you need to Log In to post a reply to this thread.