Ok so here is the code for the blinding process of the Hunters in PropHunt, and the HUD for props letting them know when the Hunters are unblinded
[CODE]
surface.CreateFont( "HideFont",
{
font = "Helvetica",
size = 256,
weight = 1000,
antialias = true,
outline = false
})
-- the font I will use for info
surface.CreateFont( "InfoFont",
{
font = "Helvetica",
size = 16,
weight = 500,
antialias = false,
outline = true
})
local function hideTimerHUD()
if( !LocalPlayer():Alive() ) then return end
if( round.state != ROUND_IN ) then return end
if( !round.startTime ) then return end
local textToDraw = round.startTime + round.timePad + OBJHUNT_HIDE_TIME - CurTime()
textToDraw = math.Round( textToDraw, 0 )
if( textToDraw < 0 ) then return end
if( LocalPlayer():Team() == TEAM_HUNTERS ) then
surface.SetFont( "HideFont" )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawRect( 0, 0, ScrW(), ScrH() )
-- Determine some useful coordinates
local width, height = surface.GetTextSize( textToDraw )
local startX = ScrW()/2 - width/2
local startY = ScrH()/2 - height/2
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos(startX, startY)
surface.DrawText( textToDraw )
elseif( LocalPlayer():Team() == TEAM_PROPS ) then
textToDraw = "Hunters Released in "..textToDraw
surface.SetFont( "InfoFont" )
-- Determine some useful coordinates
local width = surface.GetTextSize( textToDraw )
local height = 16
local padding = 5
local startX = ScrW()/2 - width/2
local startY = 2*padding
surface.SetDrawColor( 127, 127, 127, 200 )
surface.DrawRect(
startX - padding,
startY - padding,
width + 2*padding,
height + 2*padding
)
surface.SetDrawColor( PANEL_BORDER )
surface.DrawOutlinedRect(
startX - padding,
startY - padding,
width + 2*padding,
height + 2*padding
)
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos(startX, startY)
surface.DrawText( textToDraw )
end
end
hook.Add( "HUDPaintBackground", "Hide Timer", hideTimerHUD )
[/CODE]
What i would like to do, is instead of having a black rectangle and a Huge timer in the middle, display a derma panel (opened by this console command: open_phmenu). The problem is, i believe this is constantly drawing a black rectangle and new timer every second, so i can't just replace everything inside of [CODE]if( LocalPlayer():Team() == TEAM_HUNTERS ) then[/CODE] The reason i believe this is because when i replace the code inside the previously shown if statement with RunConsoleCommand("open_phmenu"), then i get the console error "Too many popups! Rendering will be bad", continuously. The Panel contains 2 buttons that close the menu when clicked, then open something else up. Any ideas as to how to go about this? All help is appreciated
Anybody? :(
you have to check and make sure the menu isn't already open, since that hook gets run every frame
[lua] if LocalPlayer():Team() == TEAM_HUNTERS and LocalPlayer().concommand == nil then
LocalPlayer():ConCommand("open_phmenu")
LocalPlayer().concommand = true
end
[/lua]
and
"if( textToDraw < 0 ) then return end" turns into "if( textToDraw < 0 ) then LocalPlayer().concommand = nil return end"
pseudocode. Just to give you some ideas.
[QUOTE=Tomelyr;46321211][lua] if LocalPlayer():Team() == TEAM_HUNTERS and LocalPlayer().concommand == nil then
LocalPlayer():ConCommand("open_phmenu")
LocalPlayer().concommand = true
end
[/lua]
and
"if( textToDraw < 0 ) then return end" turns into "if( textToDraw < 0 ) then LocalPlayer().concommand = nil return end"
pseudocode. Just to give you some ideas.[/QUOTE]
The problem here is i don't think i can set LocalPlayer().concommand equal to something, or can i? Sorry I'm sort of new to lua.
Case sensitive. While ConCommand would be a reference to a function, concommand would not be. However, it is typically bad practice to use a variable with the same name using different case as they can be easily confused.
[QUOTE=Acecool;46325929]Case sensitive. While ConCommand would be a reference to a function, concommand would not be. However, it is typically bad practice to use a variable with the same name using different case as they can be easily confused.[/QUOTE]
Thanks for clarifying that, I wasn't aware he meant concommand was a variable. I thought he was referring to the function.
Sorry, you need to Log In to post a reply to this thread.