HUD lua trouble

Its mah PC Processor: Windows 7 Intel® Core™ i5-2410m CPU @2.30GHz 2.30GHz
System type: 64 OS

Only today i’ve started to make my custom gamemode with lua and more stuff. I now can launch it throught menu. Anyway, i’ve joined gm_construct with my gamemode and my fps was only from 4 - 10, no more, but when i press Esc or ~ ofcourse my Fps gets on 50. But when i return in game, it makes too low. With Sandbox gamemode on gm_bigcity, full of stuff i’ve got 20 - 30 fps, but with my gamemode on clean gm_construct i’ve got less then 15 fps! And that’s when i’m playing a SinglePlayer! What it can be? I had some lua errors when joined gamemode, still i fixed them but my fps doesn’t change. Its probably because of my hud. It works good, still it lags. Anyways it looks fine in lua and right coded, still look on it and tell me if there is something to fix. Here is the code:

function HUDHide( myhud )
for k, v in pairs {“CHudHealth”,“CHudBattery”} do
if myhud == v then return false
end
end
end
hook.Add(“HUDShouldDraw”,“HUDHide”,HUDHide)

function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()

local HP = LocalPlayer():Health()
surface.CreateFont( “MyFont”,
{
font = “Tahoma”,
size = 60,
weight = 1000,
antialias = false,
shadow = false
})
surface.SetTextColor( 255, 64, 64, 255)
surface.SetTextPos( 50, 680 )
surface.SetFont( “MyFont” )
surface.SetDrawColor( 50, 150, 50, 255)
surface.DrawText( “HP:”…HP )

local ARM = LocalPlayer():Armor()

surface.SetTextColor( 0,245,255,255)
surface.SetTextPos( 360, 680 )
surface.SetDrawColor( 50, 150, 50, 255)
surface.DrawText( “ARM:”…ARM )
end

[editline]12th January 2013[/editline]

Anybody?

Ugh. I can assume you are on laptop. Laptop GPUs generally suck shit. Turn your settings all the way down and see the results.

I always download shit load of addons on my gmod and it works fine. Just a tiny lag. But when i just made a 20 string lua code, it slow down my fps to 10! Is it because i’ve made a gamemode?

It looks like you are creating a font every single frame. Define it outside the HUDPaint function.

Your FPS is shit because you’re calling surface.CreateFont inside HUDPaint.

Edit: god damn ninjas

Thanks mate. It works fine!

You are also looping through two strings for HUDShouldDraw. Just check by using: if myhud == “CHudHealth” or myhud == “CHudBattery” then return false end