Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

LUA скрипт [GS] AddToNotify

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
24 Окт 2023
Сообщения
18
Реакции
0
сразу говорю я его переписал с tf2 а вообще там почти нету разницы в CSGO и TF2
или как говорят другие старый лог из гс(старый шрифт)

Код:
Expand Collapse Copy
-- // console.cpp

-- //===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
-- //
-- // Purpose:
-- //
-- // $NoKeywords: $
-- //===========================================================================//
local surface = require("gamesense/surface")

ANTIALIASED_FONTS    = 1
DROPSHADOW_FONTS    = 2
ESCAPE_KEY            = 3
OPENING_NEW_HTML_WINDOWS = 4
FRAME_MINIMIZE_MAXIMIZE     = 5
OUTLINE_FONTS    = 6
DIRECT_HWND_RENDER        = 7
FONTFLAG_NONE,
FONTFLAG_ITALIC            = 0x001
FONTFLAG_UNDERLINE        = 0x002
FONTFLAG_STRIKEOUT        = 0x004
FONTFLAG_SYMBOL            = 0x008
FONTFLAG_ANTIALIAS        = 0x010
FONTFLAG_GAUSSIANBLUR    = 0x020
FONTFLAG_ROTARY            = 0x040
FONTFLAG_DROPSHADOW        = 0x080
FONTFLAG_ADDITIVE        = 0x100
FONTFLAG_OUTLINE        = 0x200
FONTFLAG_CUSTOM            = 0x400        -- // custom generated font - never fall back to asian compatibility mode
FONTFLAG_BITMAP            = 0x800        -- // compiled bitmap font - no fallbacks
-- //------------------------------------------------------------------------------
-- // Purpose :
-- // Input   :
-- // Output  :
-- //------------------------------------------------------------------------------
--// https://wiki.facepunch.com/gmod/surface.CreateFont
local overlay_font = surface.create_font("Lucida Console", 10, 0, {FONTFLAG_DROPSHADOW})
overlays = {}

-- // https://github.com/OthmanAba/TeamFortress2/blob/1b81dded673d49adebf4d0958e52236ecc28a956/tf2_src/engine/console.cpp#L1034-L1046
function AddToNotify(x, y, duration, r, g, b, a, text)
    local text_str = tostring(text or "")

    for line in text_str:gmatch("[^\n]+") do
        table.insert(overlays, {
            x = x or 8,
            y = y or 5,
            text = line,
            r = r or 255, g = g or 255, b = b or 255, a = a or 255,
            starttime = globals.curtime(),
            duration = duration or 5,
            endtime = globals.curtime() + (duration or 5)
        })

        if #overlays > 10 then
            table.remove(overlays, 1)
        end
    end
end
-- //-----------------------------------------------------------------------------
-- // Purpose:
-- //-----------------------------------------------------------------------------

-- // NOTE: I wrote this from Team Fortress 2
-- // https://github.com/OthmanAba/TeamFortress2/blob/master/tf2_src/engine/console.cpp#L1096-L1157

client.set_event_callback("paint_ui", function()

    -- // if not cvar.developer:get_bool() then
    -- //      return
    -- // end

    local x = 8
    local y = 5
    local now = globals.curtime()
    local font_height = 13 -- // int fontTall = vgui::surface()->GetFontTall( m_hFontFixed ) + 1;

    for i = #overlays, 1, -1 do
        if now > overlays[i].endtime then
            table.remove(overlays, i)
        end
    end

    for i = 1, #overlays do
        local data = overlays[i]
        local timeleft = data.endtime - now
        local clr = {r = data.r, g = data.g, b = data.b, a = data.a}

        if timeleft < 0.5 then
            local f = math.max(0, math.min(0.5, timeleft)) / 0.5
            
            clr.a = math.floor(f * data.a)

            if i == 1 and f < 0.2 then
                local shift = font_height * (1.0 - f / 0.2)
                y = y - shift
            end
        else
            clr.a = data.a
        end

        surface.draw_text(
            data.x or x,
            math.floor(y),
            clr.r, clr.g, clr.b, clr.a,
            overlay_font,
            data.text
        )

        y = y + font_height
    end
end)

-- //                      (x,  y, time, R,  G,   B,   A,        text)
-- // Purpose : AddToNotify(8, nil, 8, 255, 255, 255, 255, "hello world!")


AddToNotify(8, nil, 8, 255, 255, 255, 255, "[1] hello world!")
AddToNotify(8, nil, 5, 255, 255, 255, 255, "[2] hello world!")
AddToNotify(8, nil, 5, 255, 55, 25, 255, "[3] hello world!")
 
Назад
Сверху Снизу