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 :/
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
[code]if( IsValid(txt) ) then
self:AddText( txt:GetClass(), GAMEMODE.DeathNoticeDefaultColor )
else
self:AddText( tostring( txt ) )
end
end[/code]
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 :/
I see where it's being set now. For some reason, txt:Nick() is returning suicide. Try using this for your AddEntityText() function.
[code]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[/code]
i did that but it still showing suicide killed nil nil
[code]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[/code]
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
I have narrowed it down to a fretta file that is not reading the new death messages properly..
garrysmod\gamemodes\fretta\gamemode\cl_deathnotice.lua
There's overrides in there that changes the default method.
I'm trying to figure out how to get it to do it the new way now :s
[editline]4th April 2014[/editline]
I've fixed it, will post results after I fix my servers up
[editline]4th April 2014[/editline]
Here's the 2 files you need to change (I'm running these for prop hunt)
File location is stated in comment at the top of the file.
[url]http://pastebin.com/ui4AWVZW[/url]
[url]http://pastebin.com/FzKp4gis[/url]
fixed my problems! thank you!
it works somewhat it just shows the sandbox symbol for suicides but thats not that big of an issue though c:
just wish i could edit what the suicide string says like instead of it saying "player" couldnt take the pressure and committed suicide to something else
but oh well thank you c:
This fixed my issue also, thanks. However, is there a way to change the skull to an actual string, like AWildEspeon said?
Prior to this it said "Player couldn't take the pressure and commited suicide", now all it shows is a skull.
Change AddIcon to AddText
I took code_gs' advice and modified it, and it seems to work flawless now. Just re-arrange a few lines and change one AddIcon to AddText.
Original Code:
[code] if Victim == Attacker then
pnl:AddIcon( "suicide" )
pnl:AddText( Attacker, color1)
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end[/code]
Working Version:
[code]if Victim == Attacker then
pnl:AddText( Attacker, color1)
pnl:AddText( "couldn't take the pressure and commited suicide" )
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end[/code]
[QUOTE=Xer0n;44448222]I took code_gs' advice and modified it, and it seems to work flawless now. Just re-arrange a few lines and change one AddIcon to AddText. Use this:
Original Code:[code] if Victim == Attacker then
pnl:AddIcon( "suicide" )
pnl:AddText( Attacker, color1)
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end
[/code]
Working Version:
[code]
if Victim == Attacker then
pnl:AddText( Attacker, color1)
pnl:AddText( "couldn't take the pressure and commited suicide" )
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end
[/code][/QUOTE]
Ah, good stuff, thank you very much.
Just noticed I'm getting this error when I do, too.
[QUOTE=Xer0n;44448222]I took code_gs' advice and modified it, and it seems to work flawless now. Just re-arrange a few lines and change one AddIcon to AddText. Use this:
Original Code:[code] if Victim == Attacker then
pnl:AddIcon( "suicide" )
pnl:AddText( Attacker, color1)
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end
[/code]
Working Version:
[code]
if Victim == Attacker then
pnl:AddText( Attacker, color1)
pnl:AddText( "couldn't take the pressure and commited suicide" )
else
pnl:AddText( Attacker, color1)
pnl:AddIcon( Inflictor )
pnl:AddText( Victim, color2 )
end
[/code][/QUOTE]
That's in cl_deathnotice? I can't find that code.
Will need to delete line 190 in cl_deathnotice.lua btw, that's a debug line I forgot to remove.
(The MsgAll line)
[QUOTE=Blasteh;44443842]I have narrowed it down to a fretta file that is not reading the new death messages properly..
garrysmod\gamemodes\fretta\gamemode\cl_deathnotice.lua
There's overrides in there that changes the default method.
I'm trying to figure out how to get it to do it the new way now :s
[editline]4th April 2014[/editline]
I've fixed it, will post results after I fix my servers up
[editline]4th April 2014[/editline]
Here's the 2 files you need to change (I'm running these for prop hunt)
File location is stated in comment at the top of the file.
[url]http://pastebin.com/ui4AWVZW[/url]
[url]http://pastebin.com/FzKp4gis[/url][/QUOTE]
There is no line 190 in cl_deathnotice.lua only 117.
-EDIT- Scratch that, I was reading the old file. My bad.
Sorry, you need to Log In to post a reply to this thread.