• Overflowed Reliable Buffer
    5 replies, posted
I'm pretty new to Lua but I have coded in other languages. I coded this SWEP and whenever I run it the game freezes and I get a Overflowed Reliable Buffer error. Here is the code below: [CODE]-- INCOMPLETE -- INCOMPLETE -- INCOMPLETE -- INCOMPLETE if SERVER then AddCSLuaFile("shared.lua") SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false elseif CLIENT then -- This is where the cl_init.lua stuff goes SWEP.PrintName = "Traitor Finder" SWEP.Slot = 4 SWEP.SlotPos = 1 --Sets drawing the ammuntion levels for this weapon SWEP.DrawAmmo = false SWEP.DrawCrosshair = false end SWEP.Author = "Curtis Maves" SWEP.Contact = "CMav97@gmail.com" SWEP.Purpose = "Scans to see if the person is a traitor or not" SWEP.Instructions = "Hold the gun to the person for 15 seconds and it will chat the result" --The category that you SWep will be shown in, in the Spawn (Q) Menu --(This can be anything, GMod will create the categories for you) SWEP.Category = "Category" SWEP.Spawnable = false -- Whether regular players can see it SWEP.AdminSpawnable = true -- Whether Admins/Super Admins can see it SWEP.Kind = WEAPON_EQUIP1 SWEP.AmmoEnt = "none" SWEP.Icon = "VGUI/ttt/icon_myserver_ak47" SWEP.ViewModel = "models/weapons/v_RPG.mdl" -- Change to holstered model SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl" -- Changing to holster model SWEP.Primary.ClipSize = 1 SWEP.Primary.DefaultClip = 1 SWEP.Primary.ClipMax = 1 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" --When the script loads, the sound ''Metal.SawbladeStick'' will be precached, --and a local variable with the sound name created. local ShootSound = Sound("Metal.SawbladeStick") --changed to a scanning sound function SWEP:Reload() end function SWEP:Think(scanbool) end function scan(scanbool) -- This function test to make sure you are still facing some the target player. The function is incomplete but it should still display a message if you are facing a player. --if SERVER then return end -- May use may not if !SERVER then return end ply:PrintMessage( HUD_PRINTCONSOLE , "test 4") local ent = tr.Enity if ent != null and (ent:isPlayer() or ent:isBot()) then if scanbool then local distance = tr:StartPos().distance(tr:HitPos()) if(distance >= 10) then timer.Stop("scan") self.Owner:PrintMessage( HUD_PRINTCENTER, "Scan Failed") return(false) else self.Owner:PrintMessage( HUD_PRINTCENTER, 15-elapsed) end else self.Owner:PrintMessage( HUD_PRINTCENTER, "Scan Completed") end end end function SWEP:scan_attack() --This runs a loop for 15 seconds if !SERVER then return end time = os.clock() self.Owner:PrintMessage( HUD_PRINTCENTER, "test 1") tr = self.Owner:GetEyeTrace() ply = self.Owner elapsed = 0 while(elapsed <= 15) do self.Owner:PrintMessage( HUD_PRINTCENTER, "test 2") if scan(true) == false then break end self.Owner:PrintMessage( HUD_PRINTCENTER, "test 3") elapsed = os.clock()-time end scan(false) end function SWEP:PrimaryAttack() self.Owner:PrintMessage( HUD_PRINTCENTER, "test 1") self:scan_attack() end function SWEP:SecondaryAttack() --No Secondary Attack end[/CODE] Here is an image of the error: [IMG]http://postimg.org/image/o4vnkn3wb/[/IMG] Here is the console output: Dropped Cyber Ghost from server (Cyber Ghost overflowed reliable buffer ) Disconnect: Cyber Ghost overflowed reliable buffer . Disconnect: Cyber Ghost overflowed reliable buffer . I have no idea what would cause this and any help would be appreciated.
No idea about this error; I've had it before, but never found a solution. A couple questions, does this happen without the weapon installed? The only thing that jumps out at me would be this: [code] while(elapsed <= 15) do self.Owner:PrintMessage( HUD_PRINTCENTER, "test 2") if scan(true) == false then break end self.Owner:PrintMessage( HUD_PRINTCENTER, "test 3") elapsed = os.clock()-time end [/code] but I'm not sure if that could be causing your problems or not.
That while loop isn't doing what you think it's doing. It's calling self.Owner:PrintMessage every single think for 15 seconds. Since PrintMessage is a networked function, that might be the cause.
I found another error in my code and fixed it but it didn't fix the problem. The error was in the lines with [Code] os.clock() [/Code] The code should be: [Code] tonumber(os.clock()) [/Code] Even after this change the error overflow error is still there. [editline]10th January 2014[/editline] What would be an alternative to the PrintMessage command that is local and doesn't send a message to the server.
[QUOTE=Cyber Ghost;43494161]I found another error in my code and fixed it but it didn't fix the problem. The error was in the lines with [Code] os.clock() [/Code] The code should be: [Code] tonumber(os.clock()) [/Code] Even after this change the error overflow error is still there. [editline]10th January 2014[/editline] What would be an alternative to the PrintMessage command that is local and doesn't send a message to the server.[/QUOTE] You probably shouldn't do it at all. There's no need to be printing to the client's console constantly unless you're shooting a gun.
I have fixed the problem. I believe that it was caused by sending to many printmessage commands to the server.
Sorry, you need to Log In to post a reply to this thread.