Server Lua problems...

So, my servers been doing ok with not real game breaking lua errors but there are still a few that effect some players and thought i might post here for help see if anyone would… Here they are.

[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_crossbow/shared.lua:224: attempt to compare number with boolean

  1. FireBolt - gamemodes/terrortown/entities/weapons/weapon_ttt_crossbow/shared.lua:224
  2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_crossbow/shared.lua:111

And then theres this one which alot of people get from joining and they get “To many lua errors” this is TTT Damage Logs/RDM Manager: http://forum.facepunch.com/showthread.php?t=1301766

[ERROR] addons/damagelog-master/lua/cl_tabs/damagetab.lua:347: attempt to call method ‘CanUseDamagelog’ (a nil value)

  1. func - addons/damagelog-master/lua/cl_tabs/damagetab.lua:347
  2. unknown - lua/includes/modules/net.lua:31

And Finaly… Tihs one…

[ERROR] lua/includes/modules/draw.lua:76: bad argument #1 to ‘GetTextSize’ (string expected, got nil)

  1. GetTextSize - [C]:-1
  2. SimpleText - lua/includes/modules/draw.lua:76
    3. unknown - gamemodes/terrortown/gamemode/vgui/sb_main.lua:734

Help for any of the above would be grate the damage logs and the 3rd one are the most anoying

  1. Looks fine to me.
  2. Where is CanUseDamagelog() defined?
  3. -What Robotboy655 said-

Also, for future reference, put all code in


 tags, not 
[quote]
.
  1. Post the whole code
  2. What code_gs said
  3. You posted wrong file, post sb_main.lua:734
  1. doesn’t cause crashes but happens a lot.
  2. I don’t know Lua assuming defined is something to do with Lua.
  3. Here is that line how ever this is a custom scoreboard so i can’t really post more if i can’t get help there i will ask the creator.

draw.SimpleText(custom_rank, "smallest", x + 247, y + 17, custom_rank_C, TEXT_ALIGN_RIGHT)

  1. Post the whole code.
  2. Post the whole code.
  1. So what? I asked for the code, not if it crashes or not. if self:Ammo1() returns a bool, it must be overridden somewhere.
  2. Where did you even get that addon? Something tells me it’s outdated.
  3. custom_rank variable appears to be nil in some cases, I can’t help you more then that without the rest of the code.

if SERVER then

   AddCSLuaFile( "shared.lua" )
   
end

SWEP.HoldType           = "crossbow"

BOLT_MODEL			= "models/crossbow_bolt.mdl"

BOLT_AIR_VELOCITY	= 3500
BOLT_WATER_VELOCITY	= 1500
BOLT_SKIN_NORMAL	= 0
BOLT_SKIN_GLOW		= 1

CROSSBOW_GLOW_SPRITE	= "sprites/light_glow02_noz.vmt"
CROSSBOW_GLOW_SPRITE2	= "sprites/blueflare1.vmt"

if CLIENT then
   
   SWEP.PrintName          = "Silenced Crossbow"           
   SWEP.Author             = "Urban"
   SWEP.Slot               = 6
   SWEP.SlotPos            = 1
   SWEP.IconLetter         = "w"
   SWEP.Icon = "VGUI/ttt/icon_crossbow"    
   
   SWEP.ViewModelFlip = false
end

if SERVER then
   resource.AddFile("materials/VGUI/ttt/icon_crossbow.vmt")
end

SWEP.Base               = "weapon_tttbase"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.Kind = WEAPON_ROLE

SWEP.AutoReload = true

SWEP.Primary.Tracer = 1
SWEP.Primary.Delay          = 1
SWEP.Primary.Recoil         = 5
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "XBowBolt"
SWEP.Primary.Damage = 100
SWEP.Primary.NumShots		= 1
SWEP.Primary.NumAmmo		= SWEP.Primary.NumShots
SWEP.Primary.Force = 10000000
SWEP.Primary.Cone = 0.001
SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.ClipMax = 3
SWEP.AutoReload          = false
SWEP.AmmoEnt = ""
SWEP.Primary.AmmoType		= "crossbow_bolt"
SWEP.AutoSpawnable      = false
SWEP.ViewModel = "models/weapons/v_crossbow.mdl"
SWEP.WorldModel = "models/weapons/w_crossbow.mdl"
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 65

SWEP.Primary.Reload	= Sound( "Weapon_Crossbow.Reload" )
SWEP.Primary.Sound = Sound ("Weapon_Crossbow.Single")
SWEP.Primary.Special1		= Sound( "Weapon_Crossbow.BoltElectrify" )
SWEP.Primary.Special2		= Sound( "Weapon_Crossbow.BoltFly" )

--SWEP.IronSightsPos        = Vector( 5, 0, 1 )
SWEP.IronSightsPos = Vector(0, 0, -15)
SWEP.CanBuy = { ROLE_TRAITOR }
SWEP.LimitedStock = true

SWEP.fingerprints = {}

SWEP.EquipMenuData = {
   type = "Weapon",
   model="models/weapons/w_crossbow.mdl",
   desc = "Crossbow Silenced. 
 Bam and they're dead!
Made by Urban."

};
SWEP.AllowDrop = true 
SWEP.AllowPickup = false
SWEP.IsSilent = true

SWEP.PrimaryAnim = ACT_VM_PRIMARYATTACK_SILENCED
SWEP.ReloadAnim = ACT_VM_RELOAD_SILENCED
   
function SWEP:Precache()

	util.PrecacheSound( "Weapon_Crossbow.BoltHitBody" );
	util.PrecacheSound( "Weapon_Crossbow.BoltHitWorld" );
	util.PrecacheSound( "Weapon_Crossbow.BoltSkewer" );

	util.PrecacheModel( CROSSBOW_GLOW_SPRITE );
	util.PrecacheModel( CROSSBOW_GLOW_SPRITE2 ); 

	self.BaseClass:Precache();

end

function SWEP:PrimaryAttack()
	if ( !self:CanPrimaryAttack() ) then return end
      
	if ( self.m_bInZoom && IsMultiplayer() ) then
//		self:FireSniperBolt();
		self:FireBolt();
	else
		self:FireBolt();
	end
	
	// Signal a reload
	self.m_bMustReload = true;

end

function SWEP:Deploy()
   self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED)
   return true
end

function SWEP:SetZoom(state)
    if CLIENT then 
       return
    else
       if state then
          self.Owner:SetFOV(20, 0.3)
       else
          self.Owner:SetFOV(0, 0.2)
       end
    end
end

-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
    if not self.IronSightsPos then return end
    if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
    
    bIronsights = not self:GetIronsights()
    
    self:SetIronsights( bIronsights )
    
    if SERVER then
        self:SetZoom(bIronsights)
    end
    
    self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end

function SWEP:PreDrop()
    self:SetIronsights( false )
    self:SetZoom(false)
end  

function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
    self:SetIronsights( false )
    self:SetZoom(false)
end


function SWEP:Holster()
    self:SetIronsights(false)
    self:SetZoom(false)
    return true
end

if CLIENT then
   local scope = surface.GetTextureID("sprites/scope")
   function SWEP:DrawHUD()
      if self:GetIronsights() then
         surface.SetDrawColor( 0, 0, 0, 255 )
         
         local x = ScrW() / 2.0
         local y = ScrH() / 2.0
         local scope_size = ScrH()

         -- crosshair
         local gap = 80
         local length = scope_size
         surface.DrawLine( x - length, y, x - gap, y )
         surface.DrawLine( x + length, y, x + gap, y )
         surface.DrawLine( x, y - length, x, y - gap )
         surface.DrawLine( x, y + length, x, y + gap )

         gap = 0
         length = 50
         surface.DrawLine( x - length, y, x - gap, y )
         surface.DrawLine( x + length, y, x + gap, y )
         surface.DrawLine( x, y - length, x, y - gap )
         surface.DrawLine( x, y + length, x, y + gap )


         -- cover edges
         local sh = scope_size / 2
         local w = (x - sh) + 2
         surface.DrawRect(0, 0, w, scope_size)
         surface.DrawRect(x + sh - 2, 0, w, scope_size)

         surface.SetDrawColor(255, 0, 0, 255)
         surface.DrawLine(x, y, x + 1, y + 1)

         -- scope
         surface.SetTexture(scope)
         surface.SetDrawColor(255, 255, 255, 255)

         surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)

      else
         return self.BaseClass.DrawHUD(self)
      end
   end

   function SWEP:AdjustMouseSensitivity()
      return (self:GetIronsights() and 0.2) or nil
   end
end

   function SWEP:FireBolt()

	if ( self.Weapon:Clip1() <= 0 && self.Primary.ClipSize > -1 ) then
		if ( self:Ammo1() > 3 ) then
			self:Reload();
	        self:ShootBullet( 150, 1, 0.01 )
		else
			self.Weapon:SetNextPrimaryFire( 5 );
		
		end

		return;
	end

	local pOwner = self.Owner;

	if ( pOwner == NULL ) then
		return;
	end

if ( !CLIENT ) then
	local vecAiming		= pOwner:GetAimVector();
	local vecSrc		= pOwner:GetShootPos();

	local angAiming;
	angAiming = vecAiming:Angle();

	local pBolt = ents.Create ( self.Primary.AmmoType );
	pBolt:SetPos( vecSrc );
	pBolt:SetAngles( angAiming );
	pBolt.Damage = self.Primary.Damage;
		self:ShootBullet( 150, 1, 0.01 )
    pBolt.AmmoType = self.Primary.Ammo;
	pBolt:SetOwner( pOwner );
	pBolt:Spawn()

	if ( pOwner:WaterLevel() == 3 ) then
		pBolt:SetVelocity( vecAiming * BOLT_WATER_VELOCITY );
	else
		pBolt:SetVelocity( vecAiming * BOLT_AIR_VELOCITY );
	end

end

	self:TakePrimaryAmmo( self.Primary.NumAmmo );

	if ( !pOwner:IsNPC() ) then
		pOwner:ViewPunch( Angle( -2, 0, 0 ) );
	end

	self.Weapon:EmitSound( self.Primary.Sound );
	self.Owner:EmitSound( self.Primary.Special2 );

	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK );

	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay );
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay );

	// self:DoLoadEffect();
	// self:SetChargerState( CHARGER_STATE_DISCHARGE );

end

function SWEP:CanPrimaryAttack()
	return true
end

function SWEP:SetDeploySpeed( speed )

	self.m_WeaponDeploySpeed = tonumber( speed / GetConVarNumber( "phys_timescale" ) )

	self.Weapon:SetNextPrimaryFire( CurTime() + speed )
	self.Weapon:SetNextSecondaryFire( CurTime() + speed )

end

function SWEP:WasBought(buyer)
   if IsValid(buyer) then -- probably already self.Owner
      buyer:GiveAmmo( 3, "XBowBolt" )
   end
end 


local function AAText(text, font, x, y, color, align)
    draw.SimpleText(text, font, x+1, y+1, Color(0,0,0,math.min(color.a,120)), align)
    draw.SimpleText(text, font, x+2, y+2, Color(0,0,0,math.min(color.a,50)), align)
    draw.SimpleText(text, font, x, y, color, align)
end

local cur_selected

function Damagelog:DrawDamageTab(x, y)

	local function askLogs()
		if not self.SelectedRound then return end
		self.Damagelog:Clear()
		self.Damagelog:AddLine("", "", "Loading..")
		self.loading = {}
		self.receiving = true
		net.Start("DL_AskDamagelog")
		net.WriteUInt(self.SelectedRound, 32)
		net.SendToServer()
	end
	
	self.DamageTab = vgui.Create("DListLayout")
	
	self.Panel = self.DamageTab:Add("DPanel")
	self.Panel:SetSize(x-40, 240)
	self.PanelOptions = vgui.Create("DPanelList", self.Panel)
	self.PanelOptions:SetSpacing(7)
	self.PanelOptions:StretchToParent(12, 5, 0, 0)
		
	local forms = {}
		
	self.RF = vgui.Create("DForm", self.PanelOptions)
	self.RF:SetName("Round selection and filters")
	self.Round = vgui.Create("DComboBox")
	local old_click = self.Round.DoClick
	self.Round.DoClick = function(panel)
		local sync_ent = self:GetSyncEnt()
		if IsValid(sync_ent) and sync_ent:GetPlayedRounds() > 0 then
			return old_click(panel)
		end
	end
	self.RF:AddItem(self.Round)
	self.Filters = vgui.Create("DListView")
	self.RF:AddItem(self.Filters)
	self.Filters:SetHeight(105)
	self.Filters:AddColumn("Filter")
	self.Filters:AddColumn("Current settings")
	
	local last_selection
	local function updateFilters(refresh)
		self.Filters:Clear()
		for k,v in pairs(self.filters) do
			local setting = self.filter_settings[k]
			if setting != nil then
				local str, color = self:SettingToStr(v, setting)
				local line = self.Filters:AddLine(k, str)
				if color then
					line.PaintOver = function(panel)
						if not panel:IsLineSelected() then
							panel.Columns[2]:SetTextColor(color)
						else
							panel.Columns[2]:SetTextColor(Color(255, 255, 255))
						end
					end
				end
				line.OnRightClick = function()
					last_selection = k
					local menu = DermaMenu()
					if v == DAMAGELOG_FILTER_BOOL then
						menu:AddOption(setting and "disable" or "enable", function()
							self.filter_settings[k] = not self.filter_settings[k]
							self:SaveFilters()
							updateFilters(true)
						end)
					elseif v == DAMAGELOG_FILTER_PLAYER then
						menu:AddOption("Set Player", function()
							self.DamageTab:SetDisabled(true)
							local selection = vgui.Create("DFrame")
							selection:SetTitle("Select player")
							selection:SetSize(270, 400)
							selection:SetDraggable(false)
							selection:Center()
							selection:MakePopup()
							selection.Think = function(panel)
								panel:MoveToFront()
							end
							hook.Add("Think", "Damagelog_SelectionThink", function()
								if not IsValid(selection) then
									self.DamageTab:SetDisabled(false)
									hook.Remove("Think", "Damagelog_SelectionThink")
								end
							end)
							local button = vgui.Create("DButton", selection)
							button:SetText("Set the selected player to the filter")
							button:SetSize(255, 25)
							button:SetPos(0, 28)
							button:CenterHorizontal()
							local plist = vgui.Create("DPanelList", selection)
							plist:SetPos(0, 60)
							plist:SetSize(255, 340)
							plist:CenterHorizontal()
							plist:EnableVerticalScrollbar(true)
							local cur_selected
							plist.AddPlayer = function(pnl, pl)  
								local pl = pl
								if not IsValid(pl) then return end
								if not IsValid(pnl) then return end
								local ply = vgui.Create("DPanel")
								ply:SetSize(0, 30) 
								local alpha = 140
								local col = { r = 40, g = 40, b = 40 }
								local col_selected = { r = 204, g = 204, b = 51 }
								ply.pl = pl
								local function checkValidity()
									if not IsValid(pl) then
										ply:Remove()
										pnl:Clear(false)
										return false
									end	
									return true
								end
								ply.Think = function(self)
									checkValidity()
								end
								ply.Paint = function(self, w, h)
									if not checkValidity() then return end
									if cur_selected != ply then
										draw.RoundedBox(0, 0, 0, w, h, Color(13, 14, 15, alpha))
										draw.RoundedBox(0, 1, 1, w - 2, h - 2, Color(col.r + 40, col.g + 40, col.b + 40, alpha))
										draw.RoundedBox(0, 2, 2, w - 4, h - 4, Color(col.r, col.g, col.b, alpha))
									else
										draw.RoundedBox(0, 0, 0, w, h, Color(13, 14, 15, alpha))
										draw.RoundedBox(0, 1, 1, w - 2, h - 2, Color(col_selected.r + 40, col_selected.g + 40, col_selected.b + 40, alpha))
										draw.RoundedBox(0, 2, 2, w - 4, h - 4, Color(col_selected.r, col_selected.g, col_selected.b, alpha))
									end			    
									AAText(pl:Nick(), "GModNotify", 40, 7, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
								end
								ply.OnMousePressed = function(pnl, mc)
									if mc == MOUSE_LEFT and cur_selected != ply then
										cur_selected = ply  
									end
								end
								local ava = vgui.Create("AvatarImage", ply)
								ava:SetSize(24, 24)
								ava:SetPlayer(pl, 32)
								ava:SetPos(4, 4)
								pnl:AddItem(ply) 
							end
							for k,v in pairs(player.GetAll()) do
								plist:AddPlayer(v)
							end
							button.DoClick = function()
								if IsValid(cur_selected) and IsValid(cur_selected.pl) then
									self.filter_settings[k] = cur_selected.pl:SteamID()
									selection:Remove()
									updateFilters(true)
								end
							end
						end)
						menu:AddOption("Clear", function()
							self.filter_settings[k] = false
							updateFilters(true)
						end)
					end
					menu:Open()
				end
				if k == last_selection then
					line:SetSelected(true)
				end
			end
		end
		if refresh then
			askLogs()
		end
	end
	updateFilters(false)
	
	self.PanelOptions:AddItem(self.RF)
	self.RF:SetHeight(350)
	self.RF:SetExpanded(true)
			
	table.insert(forms, self.RF)
		
	self.DamageInfoBox = vgui.Create("DForm", self.PanelOptions)
	self.DamageInfoBox:SetName("Damage informations section")
	self.DamageInfo = vgui.Create("DListView")
	self.DamageInfo:SetHeight(130)
	self.DamageInfo:AddColumn("Damage informations").DoClick = function() end
	self.DamageInfoBox:AddItem(self.DamageInfo)
	self.PanelOptions:AddItem(self.DamageInfoBox)
	self.DamageInfoBox:SetHeight(350)
	self.DamageInfoBox:SetExpanded(false)
			
	table.insert(forms, self.DamageInfoBox)
			
	self.RoleInfos = vgui.Create("DForm", self.PanelOptions)
	self.RoleInfos:SetName("List of roles")
	self.Roles = vgui.Create("DListView")
	self.Roles:AddColumn("Player")
	self.Roles:AddColumn("Role")
	self.Roles:AddColumn("Alive")
	self.Roles:SetHeight(130)
	self.RoleInfos:AddItem(self.Roles)	
	self.PanelOptions:AddItem(self.RoleInfos)
	self.RoleInfos:SetHeight(350)
	self.RoleInfos:SetExpanded(false)

	table.insert(forms, self.RoleInfos)
			
	for k,v in pairs(forms) do
		local old_toggle = v.Toggle
		v.Toggle = function(self)
			if self:GetExpanded() then 
				return 
			else
				for _,s in pairs(forms) do
					if s:GetExpanded() then
						old_toggle(s)
					end
				end
			end
			return old_toggle(v)
		end
	end
			
	self.Damagelog = self.DamageTab:Add("DListView")
	self.Damagelog:SetHeight(370)
	self.Damagelog:AddColumn("Time"):SetFixedWidth(40)
	self.Damagelog:AddColumn("Type"):SetFixedWidth(40)
	self.Damagelog.EventColumn = self.Damagelog:AddColumn("Event")
	self.Damagelog.EventColumn:SetFixedWidth(529)
	self.Damagelog.IconColumn = self.Damagelog:AddColumn("")
	self.Damagelog.IconColumn:SetFixedWidth(30)
	self.Damagelog.Think = function(panel)
		if panel.VBar.Enabled and not panel.Scrollbar then
			panel.EventColumn:SetFixedWidth(509)
			panel.IconColumn:SetFixedWidth(50)
			panel.Scrollbar = true
		elseif not panel.VBar.Enabled and panel.Scrollbar then
			panel.EventColumn:SetFixedWidth(529)
			panel.IconColumn:SetFixedWidth(30)
			panel.Scrollbar = false
		end
	end

	self.Tabs:AddSheet("Damagelog", self.DamageTab, "icon16/application_view_detail.png")

	local sync_ent = self:GetSyncEnt()
	if not IsValid(sync_ent) then
		return
	end
	
	self.Round.FirstSelect = true
	self.Round.OnSelect = function(_, value, index, data)
		self.SelectedRound = data
		if self.Round.FirstSelect then
			self.Round.FirstSelect = false
			return
		end
		askLogs()
	end
	
	local PlayedRounds = sync_ent:GetPlayedRounds()
	if PlayedRounds > 0 then
		local i_count = 1
		if PlayedRounds > 10 then
			i_count = PlayedRounds - 10
		end
		for i = i_count, PlayedRounds do
			if i == PlayedRounds then
				self.Round:AddChoice("Current Round", i)
			else
				self.Round:AddChoice("Round "..tostring(i), i)
			end
		end
		if PlayedRounds <= 10 then
			self.Round:ChooseOptionID(PlayedRounds)
		else
			self.Round:ChooseOptionID(11)
		end
		self.SelectedRound = PlayedRounds
		askLogs()
	else
		self.Round:AddChoice("No available logs for the current map")
		self.Round:ChooseOptionID(1)
	end
end

function Damagelog:ReceiveLogs(empty, tbl, last)
	if not self.receiving then return end
	if not IsValid(self.Menu) then return end
	self.Damagelog:Clear()
	if empty then
		self.Damagelog:AddLine("", "", "Damagelog empty..")
	else
		table.insert(self.loading, tbl)
		if last then
			self:FinishedLoading()
		end
	end
end
net.Receive("DL_SendDamagelog", function()
	local empty = net.ReadUInt(1) == 1
	if empty then
		Damagelog:ReceiveLogs(true)
	else
		local tbl = net.ReadTable()
		local last = net.ReadUInt(1) == 1
		Damagelog:ReceiveLogs(false, tbl, last)
	end
end)

function Damagelog:FinishedLoading()
	self.receiving = false
	self:SetListViewTable(self.Damagelog, self.loading)
end

function Damagelog:ReceiveRoles(tbl)
	if not IsValid(self.Menu) then return end
	self:SetRolesListView(self.Roles, tbl)
end
net.Receive("DL_SendRoles", function()
	local tbl = net.ReadTable()
	Damagelog.RoleNicks = {}
	for k,v in pairs(player.GetAll()) do
		Damagelog.RoleNicks[v:Nick()] = v
	end
	Damagelog:ReceiveRoles(tbl)
	Damagelog.RoleEnts = {}
end)

net.Receive("DL_SendDamageInfos", function()
	local empty = net.ReadUInt(1) == 1
	local beg = net.ReadUInt(32)
	local t = net.ReadUInt(32)
	local result
	if not empty then
		result = net.ReadTable()
	end
	local victim = net.ReadString()
	local att = net.ReadString()
	Damagelog:SetDamageInfosLV(Damagelog.DamageInfo, att, victim, beg, t, result)
end)

net.Receive("DL_RefreshDamagelog", function()
	local tbl = net.ReadTable()
	if not LocalPlayer():CanUseDamagelog() then return end
	if ValidPanel(Damagelog.Damagelog) then
		local lines = Damagelog.Damagelog:GetLines()
		if lines[1] and lines[1]:GetValue(3) == "Damagelog empty.." then
			Damagelog.Damagelog:Clear()
		end
		local rounds = Damagelog:GetSyncEnt():GetPlayedRounds()
		if rounds == Damagelog.SelectedRound then
			Damagelog:AddLogsLine(Damagelog.Damagelog, tbl)
		end
	end
end)

  1. I’ll just talk to the creator about that.
  1. CanUseDamagelog() is never defined anywhere. It’s only on that one line that’s causing the error.

So, do i just delete it ?

You can try.

So, do i just delete it ?

[editline]30th December 2013[/editline]

My bad repost

That or you could define it yourself. Looks like it’s just a replacement for IsAdmin an IsSuperAdmin.