I'm currently trying to make my own hud. Its not finished but I keep getting some <eof> errors near end but I just can't figure it out...
[code]
function PAINT:HUD()
local Bar = vgui.Create( "DHudBar" )
GM:AddHUDItem( Bar, 2 )
Bar:SetSize(20, 60)
Bar:SetPos(5, 5)
Bar:SetText("100")
end
local Bar2 = vgui.Create( "DHudBar" )
GM:AddHUDItem( Bar2, 2 )
Bar2:SetSize(20, 60)
Bar2:SetPos(5, 25)
Bar2:SetText("".. LocalPlayer():PS_GetPoints() .."")
end
local Bar3 = vgui.Create( "DHudBar" )
Bar3:SetSize(12, 60)
Bar3:SetPos(5, -255)
Bar3:SetValueFunction( function()
if ( GetGlobalFloat( "RoundStartTime", 0 ) > CurTime() ) then return GetGlobalFloat( "RoundStartTime", 0 ) end
return GetGlobalFloat( "RoundEndTime" ) end )
end
local Bar4 = vgui.Create( "DHudBar" )
Bar4:SetSize(15, 60)
Bar4:SetPos(19, -255)
Bar4:SetText(""..c.."")
function GetTeam (ply)
if (ply:Team() == TEAM_GUARD then
c == "Guard"
r == 0, 0, 255
elseif (ply:Team() == TEAM_PRISONER then
c == "Prisoner"
r == 255, 0, 0
else
c == Unknown
r == 0, 0, 0
end
Bar4:SetTextColor(..r..)
end
[/code]
second bottom line. Also [b]post the damn error[/b].
Why are you using double = to define a variable?
[QUOTE=Internet1001;42768006]Why are you using double = to define a variable?[/QUOTE]
Let's say he haven't got a slightest idea of what he's doing lol.
Oh my god that code is messy. Unclosed brackets, and you seem to be defining a color by doing r = 0,0,0 instead of r = Color( 0, 0, 0 ).
[editline]5th November 2013[/editline]
Please don't tell me you're defining a function in a function that will be called every frame.
Your error occurs because you have put 'end' outside of a functions or a condition on line 20.
[editline]5th November 2013[/editline]
[QUOTE=Internet1001;42768055]
Please don't tell me you're defining a function in a function that will be called every frame.[/QUOTE]
Shouldn't matter with JIT enabled.
[QUOTE=dingusnin;42768091]Your error occurs because you have put 'end' outside of a functions or a condition on line 20.
[editline]5th November 2013[/editline]
Shouldn't matter with JIT enabled.[/QUOTE]
JIT is disabled by default though.
Thanks for the feedback so soon... I will get the error... Sorry if its messy, first HUD I've ever created of my own. I have been experimenting on others to get me ready for this one.
[editline]5th November 2013[/editline]
Thanks for the feedback so soon... I will get the error... Sorry if its messy, first HUD I've ever created of my own. I have been experimenting on others to get me ready for this one.
[code]
[ERROR] gamemodes/jailbreak/gamemode/core/cl_hud.lua:13: '<eof>' expected near 'end'
1. unknown - gamemodes/jailbreak/gamemode/core/cl_hud.lua:0
[/code]
[editline]5th November 2013[/editline]
Oh and fixed the teams thing
[code]
function PAINT:HUD()
local Bar = vgui.Create( "DHudBar" )
GM:AddHUDItem( Bar, 2 )
Bar:SetSize(20, 60)
Bar:SetPos(5, 5)
Bar:SetText("100")
local Bar2 = vgui.Create( "DHudBar" )
GM:AddHUDItem( Bar2, 2 )
Bar2:SetSize(20, 60)
Bar2:SetPos(5, 25)
Bar2:SetText("".. LocalPlayer():PS_GetPoints() .."")
local Bar3 = vgui.Create( "DHudBar" )
Bar3:SetSize(12, 60)
Bar3:SetPos(5, -255)
Bar3:SetValueFunction( function()
if ( GetGlobalFloat( "RoundStartTime", 0 ) > CurTime() ) then return GetGlobalFloat( "RoundStartTime", 0 ) end
return GetGlobalFloat( "RoundEndTime" ) end )
local Bar4 = vgui.Create( "DHudBar" )
Bar4:SetSize(15, 60)
Bar4:SetPos(19, -255)
Bar4:SetText(""..c.."")
function GetTeam (ply)
if (ply:Team() = TEAM_GUARD) then
c == "Guard"
r == 0, 0, 255
elseif (ply:Team() = TEAM_PRISONER) then
c == "Prisoner"
r == 255, 0, 0
else
c == Unknown
r == 0, 0, 0
end
Bar4:SetTextColor(..r..)
end
[/code]
I was not paying attention to that... Thanks
You didn't put GM:AddHUDItem under Bar3
Oh balls.... This is what happens when you code while tired.
[editline]5th November 2013[/editline]
Okey, fixed some stuff got it to this:
[code]
local hudScreen = nil
function JB:AddHUDItem( item, pos, parent )
hudScreen:AddItem( item, parent, pos )
end
hook.Add("HUDPaint","JBHUD", function()
local Bar = vgui.Create( "DHudBar" )
JB:AddHUDItem( Bar, 2 )
Bar:SetSize(20, 60)
Bar:SetPos(5, 5)
Bar:SetText("100")
local Bar2 = vgui.Create( "DHudBar" )
JB:AddHUDItem( Bar2, 2 )
Bar2:SetSize(20, 60)
Bar2:SetPos(5, 25)
Bar2:SetText("".. LocalPlayer():PS_GetPoints() .."")
local Bar3 = vgui.Create( "DHudBar" )
JB:AddHUDItem( Bar3, 2 )
Bar3:SetSize(12, 60)
Bar3:SetPos(5, -255)
Bar3:SetValueFunction( function()
if ( GetGlobalFloat( "RoundStartTime", 0 ) > CurTime() ) then return GetGlobalFloat( "RoundStartTime", 0 ) end
return GetGlobalFloat( "RoundEndTime" ) end )
local Bar4 = vgui.Create( "DHudBar" )
JB:AddHUDItem( Bar4, 2 )
Bar4:SetSize(15, 60)
Bar4:SetPos(19, -255)
Bar4:SetText(""..c.."")
function GetTeam()
if localplayer:Team() == TEAM_GUARD then
c= "Guard"
r= 0, 0, 255
elseif localplayer:Team() == TEAM_PRISONER then
c= "Prisoner"
r= 255, 0, 0
else
c= Unknown
r= 0, 0, 0
end
end
Bar4:SetTextColor(""..r.."")
end);
[/code]
But now getting:
[code]
[ERROR] gamemodes/jailbreak/gamemode/core/cl_hud.lua:4: attempt to index upvalue 'hudScreen' (a nil value)
1. AddHUDItem - gamemodes/jailbreak/gamemode/core/cl_hud.lua:4
2. v - gamemodes/jailbreak/gamemode/core/cl_hud.lua:9
3. unknown - lua/includes/modules/hook.lua:82
[/code]
I don't understand... You don't want me to make it with Vgui?
[QUOTE=SatoshiAaron;42768875]I don't understand... You don't want me to make it with Vgui?[/QUOTE]
We do, but you're doing it wrong.
Create the panel only [I]once[/I], it'll take care of drawing itself on its own.
[QUOTE=SatoshiAaron;42768875]I don't understand... You don't want me to make it with Vgui?[/QUOTE]
Think of it like this.
Every frame, you create 1 panel. That sounds fine so far right? That's because you're probably assuming the old frame was removed when the new one was created.
[B]It wasn't[/B]
You'll start stacking up panels very quickly until your fps hits 1-2.
You create 1 panel outside of HUDPaint, and update the HUDPaint variables
Sorry, you need to Log In to post a reply to this thread.