K/D ratio

How would I make it show the K/D ration in the HUD? I’m just making a very basic HUD. Here is my HUD so far.


function hud()    local health = LocalPlayer():Health()
    local armor = LocalPlayer() :Armor()
    local mag_left = LocalPlayer() :GetActiveWeapon(): Clip1()
    local mag_extra = LocalPlayer() :GetAmmoCount(LocalPlayer ():GetActiveWeapon():GetPrimaryAmmoType())
    local secondary_ammo = LocalPlayer() :GetAmmoCount(LocalPlayer ():GetActiveWeapon():GetSecondaryAmmoType())    
        draw.RoundedBox(10, 140, 725, 120, 30, Color(0, 0, 0, 150))
        draw.RoundedBox(10, 5, 725, 120, 30, Color(0, 0, 0, 150))
        draw.RoundedBox(10, 1200, 725, 120, 30, Color(0, 0, 0, 150))
        draw.RoundedBox(0, 15, ScrH() - 15 - 20, health, 15, Color(255,0,0,200))
        draw.RoundedBox(0, 150, ScrH() - 15 - 20, armor, 15, Color(0,170,255,150))
        draw.SimpleText(health, "trebuchet24", 10, ScrH() - 15 - 40, Color(255,255,255,255))
        draw.SimpleText(armor, "trebuchet24", 145,  ScrH() - 15 - 40, Color(255,255,255,255))
        draw.SimpleText(mag_left, "trebuchet24", 1210, ScrH() - 10 - 30, Color(255,255,255,255))
        draw.SimpleText(mag_extra, "trebuchet24", 1245, ScrH() - 10 - 30, Color(255,255,255,255))
        draw.SimpleText(secondary_ammo, "trebuchet24", 1290, ScrH() - 10 - 30, Color(255,255,255,255))
        draw.SimpleText(LocalPlayer():Frags(),"trebuchet24", 30, ScrH() - 50 - 30, Color(255,255,255,255))
        draw.SimpleText(LocalPlayer():Deaths () ,"trebuchet24", 70, ScrH() - 50 - 30, Color(255,0,0,255))
        draw.SimpleText("K:" ,"trebuchet24", 10,ScrH() - 80, Color(255,255,255,255))
        draw.SimpleText("D:" ,"trebuchet24", 50,ScrH() - 80, Color(255,0,0,255))
        draw.SimpleText(LocalPlayer() :SteamID(), "trebuchet24", 1130,ScrH() - 80, Color(255,255,255,255))
end 

I’m new to Lua and any help would be appreciated.
Thanks in advance.

[lua]draw.SimpleText("K/D: " … string.sub(tostring(LocalPlayer():Frags() / LocalPlayer():Deaths()), 1, 4), …)[/lua]

This will draw your player’s K/D ratio and truncate it to 2 decimals after the point. Just add the line to somewhere in your draw script and make sure to fill out the proper coordinates and colors.

Thanks a lot.