prop hunt hunter suicide lua error

Everytime someone enters “kill” in the console commands on my server when the gamemode is on prop hunt i get this error

[ERROR] gamemodes/fretta/gamemode/vgui/vgui_gamenotice.lua:37: attempt to index local ‘txt’ (a nil value)

  1. AddEntityText - gamemodes/fretta/gamemode/vgui/vgui_gamenotice.lua:37
  2. AddText - gamemodes/fretta/gamemode/vgui/vgui_gamenotice.lua:54
  3. AddDeathNotice - gamemodes/fretta/gamemode/cl_deathnotice.lua:96
  4. func - gamemodes/base/gamemode/cl_deathnotice.lua:64
  5. unknown - lua/includes/modules/net.lua:31

{

please help :confused:

We can’t help without code.

what do you mean by code
from the lua files?

Yes.

– client cvars to control deathmsgs
local hud_deathnotice_time = CreateClientConVar( “hud_deathnotice_time”, “6”, true, false )
local hud_deathnotice_limit = CreateClientConVar( “hud_deathnotice_limit”, “5”, true, false )

/*
This is the player death panel. This should be parented to a DeathMessage_Panel. The DeathMessage_Panel that
it’s parented to controls aspects such as the position on screen. All this panel’s job is to print the
specific death it’s been given and fade out before its RetireTime.
*/

local PANEL = {}

Derma_Hook( PANEL, “Paint”, “Paint”, “GameNotice” )
Derma_Hook( PANEL, “ApplySchemeSettings”, “Scheme”, “GameNotice” )
Derma_Hook( PANEL, “PerformLayout”, “Layout”, “GameNotice” )

function PANEL:Init()
self.m_bHighlight = false
self.Padding = 8
self.Spacing = 8
self.Items = {}
end

function PANEL:AddEntityText( txt )

if ( type( txt ) == "string" ) then return false end

if ( type( txt ) == "Player" ) then 

	self:AddText( txt:Nick(), GAMEMODE:GetTeamColor( txt ) )
	if ( txt == LocalPlayer() ) then self.m_bHighlight = true end
	
	return true
	
end

if( txt:IsValid() ) then
	self:AddText( txt:GetClass(), GAMEMODE.DeathNoticeDefaultColor )	
else
	self:AddText( tostring( txt ) )	
end

end

function PANEL:AddItem( item )

table.insert( self.Items, item )
self:InvalidateLayout( true )

end

function PANEL:AddText( txt, color )

if ( self:AddEntityText( txt ) ) then return end

local txt = tostring( txt )

local lbl = vgui.Create( "DLabel", self )

Derma_Hook( lbl, 	"ApplySchemeSettings", 	"Scheme", 	"GameNoticeLabel" )
lbl:ApplySchemeSettings()
lbl:SetText( txt )

if( string.Left( txt , 1 ) == "#" && !color ) then color = GAMEMODE.DeathNoticeDefaultColor end // localised ent death
if( GAMEMODE.DeathNoticeTextColor && !color ) then color = GAMEMODE.DeathNoticeTextColor end // something else
if ( !color ) then color = color_white end

lbl:SetTextColor( color )

self:AddItem( lbl )

end

function PANEL:AddIcon( txt )

if ( killicon.Exists( txt ) ) then

	local icon = vgui.Create( "DKillIcon", self )
		icon:SetName( txt )
		icon:SizeToContents()

	self:AddItem( icon )

else

	self:AddText( "killed" )

end

end

function PANEL:PerformLayout()

local x = self.Padding
local height = self.Padding * 0.5

for k, v in pairs( self.Items ) do

	v:SetPos( x, self.Padding * 0.5 )
	v:SizeToContents()
	
	x = x + v:GetWide() + self.Spacing
	height = math.max( height, v:GetTall() + self.Padding )

end

self:SetSize( x + self.Padding, height )

end

derma.DefineControl( “GameNotice”, “”, PANEL, “DPanel” )

here is the code for vgui_gamenotice.lua is this what you need?

I’m pretty sure it’s trying to check if txt is not nil. Change txt:IsValid() to IsValid( txt )

that fixed the error but on the top right where it says so and so killed so and so it says
suicide killed nil nil
It doesnt say that “player” couldn’t take the pressure and committed suicide
anyway to fix that?

On


if( IsValid(txt) ) then
self:AddText( txt:GetClass(), GAMEMODE.DeathNoticeDefaultColor )	
else
self:AddText( tostring( txt ) )	
end

end

comment out the “else” and the "self:AddText( tostring( txt ) ). Tell me what it says then after a player suicides.

wait what do you mean by comment out?

Put – in front of the two lines I told you.

i did that but it still says suicide killed nil

Can you also comment out the other three lines of the if statement (if (IsValid( txt ), self:AddText, and and end)? I’m just trying to figure out where the nils are coming from.

wait comment ou the if( isvalide( txt ) ) then ?

And the self:AddText and the end that closes the if statement.

i did that and it still say suicide killed nil :confused:

I see where it’s being set now. For some reason, txt:Nick() is returning suicide. Try using this for your AddEntityText() function.


function PANEL:AddEntityText( txt )

     if ( type( txt ) == "string" ) then return false end

     if ( type( txt ) == "Player" ) then 
          if ( txt:Nick() == "suicide" ) then
               self:AddText( "Player suicided." )
          else
               self:AddText( txt:Nick(), GAMEMODE:GetTeamColor( txt ) )
          end
          if ( txt == LocalPlayer() ) then self.m_bHighlight = true end

     return true

     end

     if( IsValid(txt) ) then
          self:AddText( txt:GetClass(), GAMEMODE.DeathNoticeDefaultColor )	
     else
          self:AddText( tostring( txt ) )	
     end

end

i did that but it still showing suicide killed nil nil


function PANEL:AddEntityText( txt )

     if ( type( txt ) == "string" ) then return false end

     if ( type( txt ) == "Player" ) then 
          if ( txt:Nick() == nil ) then
               self:AddText( "Player suicided." )
          else
               self:AddText( txt:Nick(), GAMEMODE:GetTeamColor( txt ) )
          end
          if ( txt == LocalPlayer() ) then self.m_bHighlight = true end

     return true

     end

     if( IsValid(txt) ) then
          self:AddText( txt:GetClass(), GAMEMODE.DeathNoticeDefaultColor )	
     else
          self:AddText( "Player suicided." )	
     end

end

this time it said suicide killed player suicided. nil
lol

I’m getting this error now too, started after running the steam update on my server which doesn’t make much sense since it doesn’t touch fretta