-- Это Server
local vremya = 180
local try_sdelat_po_pozicii_xz_kak_buder_rabotat = {}
local afkproverka= {}
hook.Add("PlayerInitialSpawn", "DOBAVLYAEM", function(ply)
try_sdelat_po_pozicii_xz_kak_buder_rabotat[ply] = {
pos = ply:GetPos(),
time = CurTime()
}
afkproverka[ply] = false
ply:SetNWBool("AFKSHNIK", false)
end)
hook.Add("PlayerDisconnected", "OCHISTKA", function(ply)
try_sdelat_po_pozicii_xz_kak_buder_rabotat[ply] = nil
afkproverka[ply] = nil
end)
timer.Create("VREMYA_V_AFK", 10, 0, function()
for _, ply in ipairs(player.GetAll()) do
if not IsValid(ply) then continue end
if not ply:Alive() then continue end
local data = try_sdelat_po_pozicii_xz_kak_buder_rabotat[ply]
local cpos = ply:GetPos()
if data and cpos:Distance(data.pos) > 5 then
try_sdelat_po_pozicii_xz_kak_buder_rabotat[ply].pos = cpos
try_sdelat_po_pozicii_xz_kak_buder_rabotat[ply].time = CurTime()
afkproverka[ply] = false
else
if CurTime() - data.time >= VREMYA_V_AFK then
if not afkproverka[ply] then
afkproverka[ply] = true
ply:SetNWBool("AFKSHNIK", true)
print(ply:Nick() .. " ПРОВЕРКА СВЯЗИ!!!!!11!") -- ЭТОТ КОД ДЕЛАЛ НЕ ЧЕКАЯ ПОЭТОМУ ЕСЛИ НАПИСАЛО КОГДА ИГРОК НЕ ДВИГ С ПОЗ ТО КОММЕНТ
end
end
end
end
end)
-- Это Client
local function DrawPlayerInfo(ply, smath)
if not IsValid(ply) or not ply:Alive() then return end
local pos
if (smath) then
pos = ply:EyePos() + Vector(0, 0, 80)
pos.z = pos.z - 20
else
local bone = ply:LookupBone("ValveBiped.Bip01_Head1")
if (not bone) then return end
pos, _ = ply:GetBonePosition(bone)
end
if not pos then return end
local ang = LocalPlayer():EyeAngles()
ang:RotateAroundAxis(ang:Up(), -90)
ang:RotateAroundAxis(ang:Right(), 90)
cam.Start3D2D(pos + Vector(0, 0, 15), Angle(0, ang.y, 90), 0.035)
local offset = -350
if ply:GetNWBool("AFKSHNIK", false) then
DrawText("AFK", Color(255, 255, 255), 0, offset)
end
cam.End3D2D()
end