• Line # has whatever error, but there is no problem, how so?
    10 replies, posted
I've been scripting some sweps, and for some reason the weapon bases are exactly the way they were from the original author's version, yet errors come up only when I change the folder name to something else. Example, [lua] include('shared.lua') SWEP.PrintName = "Siminov's Weapon Base" // 'Nice' Weapon name (Shown on HUD) SWEP.Slot = 0 // Slot in the weapon selection menu SWEP.SlotPos = 1 // Position in the slot SWEP.DrawAmmo = true // Should draw the default HL2 ammo counter? SWEP.DrawCrosshair = false // Should draw the default crosshair? SWEP.DrawWeaponInfoBox = true // Should draw the weapon info box? SWEP.BounceWeaponIcon = false // Should the weapon icon bounce? SWEP.SwayScale = 1.0 // The scale of the viewmodel sway SWEP.BobScale = 1.0 // The scale of the viewmodel bob SWEP.RenderGroup = RENDERGROUP_OPAQUE // Override this in your SWEP to set the icon in the weapon selection if (file.Exists("../materials/weapons/swep.vmt")) then SWEP.WepSelectIcon = surface.GetTextureID("weapons/swep") end // This is the corner of the speech bubble if (file.Exists("../materials/gui/speech_lid.vmt")) then SWEP.SpeechBubbleLid = surface.GetTextureID("gui/speech_lid") end language.Add("buckshot_ammo", "12 Gauge Shells") // 357 language.Add("357_ammo", ".357 Magnum Ammo") // 357 language.Add("airboatgun_ammo", "5.56MM Ammo") // AirboatGun = 5.56MM Ammo (M249, FAMAS, SG-550, SG-552, Galil, M4A1) language.Add("gaussenergy_ammo", ".30-06 Ammo") // Gravity = 4.6MM Ammo (MP7) language.Add("alyxgun_ammo", "5.7MM Ammo") // AlyxGun = 5.7MM Ammo (Five-Seven, P90) language.Add("battery_ammo", "9MM Ammo") // Battery = 9MM Ammo (Glock, MP5, P228, USP, TMP) language.Add("striderminigun_ammo", "7.62MM Ammo") // StriderMinigun = 7.62MM Ammo (AK-47, SCOUT, G3, Aug, AWP, Scout) language.Add("sniperpenetratedround_ammo", ".45Acp Ammo") // SniperRound = .45 Ammo (MAC10, UMP) language.Add("combinecannon_ammo", ".50AE Ammo") // CombineCannon = .50 Ammo (Desert Eagle) language.Add("helicoptergun_ammo", "5.45MM Ammo") // Thumper = Explosive Ammo (C4) language.Add("sniperround_ammo", "7.62MM Pistol Ammo") language.Add("slam_ammo", "7.92MM Ammo") // Thumper language.Add("ar2altfire_ammo", ".30 Carbine Ammo") /*--------------------------------------------------------- Name: SWEP:SecondDrawHUD() ---------------------------------------------------------*/ function SWEP:SecondDrawHUD() end /*--------------------------------------------------------- Name: SWEP:DrawHUD() Desc: You can draw to the HUD here. It will only draw when the client has the weapon deployed. ---------------------------------------------------------*/ cl_crosshair_r = CreateClientConVar("sim_crosshair_r", 255, true, false) // Red cl_crosshair_g = CreateClientConVar("sim_crosshair_g", 255, true, false) // Green cl_crosshair_b = CreateClientConVar("sim_crosshair_b", 255, true, false) // Blue cl_crosshair_a = CreateClientConVar("sim_crosshair_a", 200, true, false) // Alpha cl_crosshair_l = CreateClientConVar("sim_crosshair_l", 30, true, false) // Lenght cl_crosshair_t = CreateClientConVar("sim_crosshair_t", 1, true, false) // Enable/Disable function SWEP:DrawHUD() self:SecondDrawHUD() self:DrawFuelHUD() if (self.Weapon:GetDTBool(1)) or (cl_crosshair_t:GetBool() == false) or (LocalPlayer():InVehicle()) then return end local hitpos = util.TraceLine ({ start = LocalPlayer():GetShootPos(), endpos = LocalPlayer():GetShootPos() + LocalPlayer():GetAimVector() * 4096, filter = LocalPlayer(), mask = MASK_SHOT }).HitPos local screenpos = hitpos:ToScreen() local x = screenpos.x local y = screenpos.y if self.Primary.Cone < 0.005 then self.Primary.Cone = 0.005 end local gap = ((self.Primary.Cone * 275) + (((self.Primary.Cone * 275) * (ScrH() / 720))) * (1 / self:CrosshairAccuracy())) * 0.75 gap = math.Clamp(gap, 0, (ScrH() / 2) - 100) local length = cl_crosshair_l:GetInt() self:DrawCrosshairHUD(x - gap - length, y - 1, length, 3) // Left self:DrawCrosshairHUD(x + gap + 1, y - 1, length, 3) // Right self:DrawCrosshairHUD(x - 1, y - gap - length, 3, length) // Top self:DrawCrosshairHUD(x - 1, y + gap + 1, 3, length) // Bottom end /*--------------------------------------------------------- Name: SWEP:DrawCrosshairHUD() ---------------------------------------------------------*/ function SWEP:DrawCrosshairHUD(x, y, width, height) surface.SetDrawColor(0, 0, 0, cl_crosshair_a:GetInt() / 2) surface.DrawRect(x, y, width, height) surface.SetDrawColor(cl_crosshair_r:GetInt(), cl_crosshair_g:GetInt(), cl_crosshair_b:GetInt(), cl_crosshair_a:GetInt()) surface.DrawRect(x + 1, y + 1, width - 2, height - 2) end /*--------------------------------------------------------- Name: SWEP:DrawFuelHUD() ---------------------------------------------------------*/ // Based on the Condition SWEPs HUD made by SB Spy function SWEP:DrawFuelHUD() end /*--------------------------------------------------------- Name: SWEP:DrawWeaponSelection() Desc: Checks the objects before any action is taken. This is to make sure that the entities haven't been removed. ---------------------------------------------------------*/ function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha) // Set us up the texture surface.SetDrawColor(255, 255, 255, alpha) surface.SetTexture(self.WepSelectIcon) // Lets get a sin wave to make it bounce local fsin = 0 if (self.BounceWeaponIcon == true) then fsin = math.sin(CurTime() * 10) * 5 end // Borders y = y + 10 x = x + 10 wide = wide - 20 // Draw that mother surface.DrawTexturedRect(x + (fsin), y - (fsin), wide - fsin * 2, (wide / 2) + (fsin)) // Draw weapon info box self:PrintWeaponInfo(x + wide + 20, y + tall * 0.95, alpha) end /*--------------------------------------------------------- Name: SWEP:PrintWeaponInfo() Desc: Draws the weapon info box. ---------------------------------------------------------*/ function SWEP:PrintWeaponInfo(x, y, alpha) if (self.DrawWeaponInfoBox == false) then return end if (self.InfoMarkup == nil) then local str local title_color = "<color = 130, 0, 0, 255>" local text_color = "<color = 255, 255, 255, 200>" str = "<font=HudSelectionText>" if (self.Author != "") then str = str .. title_color .. "Author:</color>\t" .. text_color .. self.Author .. "</color>\n" end if (self.Contact != "") then str = str .. title_color .. "Contact:</color>\t" .. text_color .. self.Contact .. "</color>\n\n" end if (self.Purpose != "") then str = str .. title_color .. "Purpose:</color>\n" .. text_color .. self.Purpose .. "</color>\n\n" end if (self.Instructions!= "") then str = str .. title_color .. "Instructions:</color>\n" .. text_color .. self.Instructions .. "</color>\n" end str = str .. "</font>" self.InfoMarkup = markup.Parse(str, 250) end alpha = 180 surface.SetDrawColor(0, 0, 0, alpha) surface.SetTexture(self.SpeechBubbleLid) surface.DrawTexturedRect(x, y - 69.5, 128, 64) draw.RoundedBox(8, x - 5, y - 6, 260, self.InfoMarkup:GetHeight() + 18, Color(0, 0, 0, alpha)) self.InfoMarkup:Draw(x + 5, y + 5, nil, nil, alpha) end /*--------------------------------------------------------- Name: SWEP:GetViewModelPosition() Desc: Allows you to re-position the view model. ---------------------------------------------------------*/ local IRONSIGHT_TIME = 0.2 function SWEP:GetViewModelPosition(pos, ang) local bIron = self.Weapon:GetDTBool(1) local DashDelta = 0 if (self.Owner:KeyDown(IN_SPEED)) and (self.Owner:GetVelocity():Length() > self.Owner:GetWalkSpeed()) or self.Weapon:GetDTBool(0) then if (!self.DashStartTime) then self.DashStartTime = CurTime() end DashDelta = math.Clamp(((CurTime() - self.DashStartTime) / 0.1) ^ 1.2, 0, 1) else if (self.DashStartTime) then self.DashEndTime = CurTime() end if (self.DashEndTime) then DashDelta = math.Clamp(((CurTime() - self.DashEndTime) / 0.1) ^ 1.2, 0, 1) DashDelta = 1 - DashDelta if (DashDelta == 0) then self.DashEn
please use "[lua]" tags
tell is which line has errors.
Forgot about those tags, cheanged them. Also added the last script's errors.
Your code isnt complete. You must define RunArmAngle (line 213-228) and CrosshairAccuracy() ( line 79).
Because what ever is defining them is including or sending the values to that specific location, and not to the one you are changing it to.
Fixed some things, they seem to work, I'll continue posting what I need help with here, if people are supportive and want to help go right ahead. [lua] function SWEP:ReloadAnimation() self.Weapon:DefaultReload(ACT_VM_RELOAD) self.Weapon:EmitSound local reloadsounds if (IsValid(self.Owner) and self.Owner:GetViewModel()) then self:IdleAnimation(self.Owner:GetViewModel():SequenceDuration()) end end [/lua] What should I do to line 4? it says there's a missing or incorrect symbol near "local"
That's like doing [lua]function Think() local herpderp = ilikepie[/lua] in the same line.
self.Weapon:EmitSound(reloadsounds) That's the proper call. Arguments go inside the parentheses when calling any function.
Here's a line that's been bothering me. [lua] function SWEP:Think() self:SecondThink() if self.Weapon:Clip1() > 0 and self.IdleDelay < CurTime() and self.IdleApply then local WeaponModel = self.Weapon:GetOwner():GetActiveWeapon():GetClass() if self.Owner and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == WeaponModel and self.Owner:Alive() then if self.Weapon:GetDTBool(3) and self.Type == 3 then self.Weapon:SendWeaponAnim(ACT_VM_IDLE_SILENCED) else self.Weapon:SendWeaponAnim(ACT_VM_IDLE) end if self.AllowPlaybackRate and not self.Weapon:GetDTBool(1) then self.Owner:GetViewModel():SetPlaybackRate(1) else self.Owner:GetViewModel():SetPlaybackRate(0) end end self.IdleApply = false elseif self.Weapon:Clip1() == 0 then self.IdleApply = false end if self.Weapon:GetDTBool(1) and self.Owner:KeyDown(IN_SPEED) then self:SetIronsights(false) end if self.Owner:KeyDown(IN_SPEED) or self.Weapon:GetDTBool(0) then if self.Rifle or self.Sniper or self.Shotgun then self:SetWeaponHoldType("passive") elseif self.Pistol then self:SetWeaponHoldType("normal") end else self:SetWeaponHoldType(self.HoldType) end if self.Owner:KeyDown(IN_SPEED) or self.Weapon:GetDTBool(0) then return end if (self.Owner:KeyDown(IN_USE)) then self:SetWeaponHoldType("fist") else self:SetWeaponHoldType(self.HoldType) end self:NextThink(CurTime()) end [/lua] Says the 5th line is nil, this is from a Child swep from the base. The same thing happens on all sweps using the base.
Try [lua] if self.Weapon:Clip1() > 0 and self.IdleDelay < CurTime() and self.IdleApply() then[/lua] and make sure CurTime isn't nil.
Sorry, you need to Log In to post a reply to this thread.