Вопрос Помогите с кодом

  • 31
  • 0
Контакты для связи отсутствуют.
Помогите написать серверную часть для кода

Чтобы при выполнении

Lua:
function SWEP:Equip(owner)
    unisono.sendNotify("ЛКМ - Клюнуть", 15, owner)
end

он работал

вот клиентская часть
Lua:
local notifs = notifs or {}
local imgS = 35
function addNotify( txt, len )
    surface.SetFont( "TargetID" )
    w, _ = surface.GetTextSize( txt )
    w = w + 25
    local t =
        {
            x = ScrW()*0.5,
           // y = ScrH()+150,
            y = -150,
            alpha = 0,
            w = w,
            h = imgS + 5,
            txt = txt or "No Text",
            len = len or 3,
            lenstep = w/len,
            formated = string.find(txt, "%%s") and true or false
        }
    table.insert( notifs, t )
end

local function drawNotif( t )
    draw.RoundedBox( 4, t.x - t.w*0.5-25, t.y, t.w, t.h, Color( 25, 25, 25, t.alpha-25) )
    draw.RoundedBox( 0, t.x - t.w*0.5-24, t.y + 2, math.Clamp( t.len*t.lenstep, 0, t.w ), 1, Color( 255, 255, 255, t.alpha ) )
    surface.SetFont( "TargetID" )
    surface.SetTextColor( Color( 255, 255, 255, t.alpha ) )
    surface.SetTextPos( t.x - t.w*0.5 -12, t.y + t.h/3.4 )
    if formated then
        surface.DrawText( t.txt )
    else
        surface.DrawText( Format(t.txt,math.floor(t.len)+1) )
    end
end

hook.Add( "HUDPaint", "uni_notify_draw", function()
    for k, v in ipairs( notifs ) do
        v.y = Lerp( FrameTime()*3, v.y, k * (v.h + 5) )

        v.len = v.len - FrameTime()
        if v.len <= 0 then
            v.die = true
        end

        if v.die then
            if v.alpha >= 50 then
                v.alpha = Lerp( FrameTime()*3, v.alpha, 0 )
            else
                table.remove( notifs, k )
            end
        else
            v.alpha = Lerp( FrameTime()*3, v.alpha, 255 )
        end
        drawNotif( v )
    end
end )


net.Receive("uni_notify", function()
    local tab = net.ReadTable()
    addNotify(tab.text,tab.len)
end)
 
  • 98
  • 1
  • 12
Контакты для связи отсутствуют.
охуенно поставил вопрос, бро, 10/10

что работать то должно? при вызове Equip не отправляется нотификейшен?
 
  • 8
  • 0
Контакты для связи отсутствуют.
Lua:
unisono = unisono or {}

util.AddNetworkString 'uni_notify'

function unisono.sendNotify(msg, len, player)
    if IsValid(player) then
        net.Start 'uni_notify'
            net.WriteTable({
                text = msg,
                len = len
            })
        net.Send(player)
    end
end
 
Активность
Пока что здесь никого нет
Сверху Снизу