Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function addHook(name, cb)
- hook.Add(name, "TLG_ADMIN.serverlogs", cb)
- end
- local buffer = Stack()
- local repeats, lastline
- local function log(patt, ...)
- local args = {...}
- local count = 0
- local str = patt:gsub("?", function()
- count = count + 1
- return args[count]
- end)
- if str == lastline then
- repeats = repeats + 1
- buffer:lpop() -- #u1 пытается использовать #tool advdupe2 (4)
- buffer:lpush(str .. " (x" .. repeats .. ")") -- #u9725 пытается использовать #tool advdupe2 (5)
- else
- buffer:lpush(str)
- lastline = str
- repeats = 1
- end
- end
- local TLG_LOGS = -1001211638609
- timer.Create("telegram_serverlogs", 15, 0, function()
- if buffer:isempty() then return end
- local logstr = "#" .. SERVERS:Name()
- for _ = 1,math.min(20, buffer:length()) do
- logstr = logstr .. "\n" .. buffer:rpop()
- end
- lastline = nil -- https://img.qweqwe.ovh/1594906189275.jpg
- TLG_ADMIN.reply(TLG_LOGS).silent().disablePreview().html(logstr)
- end)
- local function tag(pl)
- if pl:IsBot() then
- return "#bot"
- else -- player
- local s64 = pl:SteamID64()
- return htmlURL(pl:Nick(), util.SteamIDToProfile(s64))
- end
- end
- -------------------
- -- Connections --
- -------------------
- addHook("PlayerDataLoaded", function(pl)
- local s64 = pl:SteamID64()
- local nick = pl:Nick()
- local contact = "Steam " .. htmlURL(nick, util.SteamIDToProfile(s64))
- local tlg_id = TLG_CONNECT_BOT.CONNECTIONS[s64]
- if tlg_id then
- contact = "TLG " .. tlgMention(nick, tlg_id, "html")
- -- elseif VKB.PlayerID(pl) then
- -- contact = "VK " .. htmlURL(nick, "https://vk.com/id" .. VKB.PlayerID(pl))
- end
- log("#connections ? подключился. Контакт: ?", pl:SteamID(), contact)
- end)
- addHook("PlayerDisconnected", function(pl)
- log("#connections ? отключился", tag(pl))
- end)
- -------------
- -- Kills --
- -------------
- local function foo(attacker)
- if IsValid(attacker) and attacker:IsPlayer() then
- local sAttacker, weapon
- sAttacker = tag(attacker)
- weapon = (IsValid(attacker:GetActiveWeapon()) and attacker:GetActiveWeapon():GetClass() or "unknown")
- return sAttacker, weapon
- end
- end
- addHook("PlayerDeath", function(pl, _, attacker)
- local sAttacker, weapon = foo(attacker)
- if sAttacker then
- log("? #убил ? при помощи ?", sAttacker, tag(pl), weapon)
- end
- end)
- addHook("PostPlayerTakeDamage", function(pl, _, attacker, amount, dmg, took)
- if took and dmg:IsBulletDamage() then
- local sAttacker, weapon = foo( attacker )
- if sAttacker then
- log("? нанес ? #урона по ? при помощи ?", sAttacker, math.Round(amount, 0), tag(pl), weapon)
- end
- end
- end)
- -------------
- -- Props --
- -------------
- local spawned_props = setmetatable({}, {__mode = "kv"}) -- sid > count
- addHook("PlayerSpawnProp", function(pl)
- spawned_props[tag(pl)] = (spawned_props[tag(pl)] or 0) + 1
- end)
- timer.Create("spawned_props_logs_group", 60, 0, function()
- for tagg,count in pairs(spawned_props) do
- log("? #заспавнил ? пропов за 1 мин", tagg, count)
- spawned_props[tagg] = nil
- end
- end)
- addHook("PlayerSpawnedRagdoll", function(pl, mdl)
- log("? #заспавнил рэгдол ?", tag(pl), ulx.standardizeModel(mdl))
- end)
- addHook("PlayerSpawnedEffect", function(pl, mdl)
- log("? #заспавнил эффект ?", tag(pl), ulx.standardizeModel(mdl))
- end)
- addHook("PlayerSpawnedVehicle", function(pl, ent)
- log("? #заспавнил транспорт ?", tag(pl), ulx.standardizeModel(ent:GetModel() or "unknown"))
- end)
- addHook("PlayerSpawnedSENT", function(pl, ent)
- log("? #заспавнил энтити ?", tag(pl), ent:GetClass())
- end)
- addHook("PlayerSpawnedNPC", function(pl, ent)
- log("? #заспавнил NPC ?", tag(pl), ent:GetClass())
- end)
- -------------
- -- Tools --
- -------------
- addHook("CanTool", function(pl, _, tool)
- log("? пытается использовать #тул ?", tag(pl), tool)
- end)
- -----------
- -- ULX --
- -----------
- timer.Simple(1, function()
- addHook(ULib.HOOK_COMMAND_CALLED, function(pl, cmd, args)
- if pl:IsPlayer() then
- log("? выполнил #ulx команду ? ?", tag(pl), cmd, table.concat(args, " "))
- end
- end)
- end)
- local function onNameChanged(pl, old, new)
- log("? изменил свой #ник с ? на ?", tag(pl), old, new)
- end
- addHook("ULibPlayerNameChanged", onNameChanged)
- addHook("onPlayerChangedName", onNameChanged)
- --------------
- -- DarkRP --
- --------------
- addHook("onHitAccepted", function(hitman, target, customer)
- log("#Хитмэн ? принял заказ на убийство ? от ?", tag(hitman), tag(target), tag(customer))
- end)
- addHook("onHitCompleted", function(hitman, target, customer)
- log("#Хитмэн ? выполнил заказ на убийство ? от ?", tag(hitman), tag(target), tag(customer))
- end)
- addHook("onHitFailed", function(hitman, target, reason)
- log("#Хитмэн ? провалил заказ на убийство ? по причине: ?", tag(hitman), tag(target), reason)
- end)
- addHook("OnPlayerChangedTeam", function(pl, old, new)
- log("? изменил #работу с ? на ?", tag(pl), team.GetName(old), team.GetName(new))
- end)
- addHook("onPlayerDemoted", function(demoter, demotee, reason)
- log("? начал #понижение ? по причине: ?", tag(demoter), tag(demotee), reason)
- end)
- addHook("playerArrested", function(target, _, officer)
- log("? #arrested ?", tag(officer), tag(target))
- end)
- addHook("playerUnArrested", function(target, officer)
- if IsValid(officer) then
- log("? #unarrested ?", tag(officer), tag(target))
- else
- log("? был #unarrested с тюрьмы", tag(target))
- end
- end)
- addHook("playerWanted", function(target, officer, reason)
- if IsValid(officer) then
- log("? #wanted ? за ?", tag(officer), tag(target), reason)
- end
- end)
- addHook("playerUnWanted", function(target, officer)
- if IsValid(officer) then
- log("? #unwanted ?", tag(officer), tag(target))
- else
- log("? #unwanted, так как срок розыска истек", tag(target))
- end
- end)
- addHook("playerWarranted", function(target, officer, reason)
- if IsValid(officer) then
- log("? #warranted ? за ?", tag(officer), tag(target), reason)
- end
- end)
- addHook("playerUnWarranted", function(target, officer)
- if IsValid(officer) then
- log("? #unwarranted ?", tag(officer), tag(target))
- else
- log("? #unwarranted, так как срок ордера истек", tag(target))
- end
- end)
- addHook("playerBoughtCustomEntity", function(pl, ent_tbl)
- log("? #купил ? за ?", tag(pl), ent_tbl.name, ent_tbl.price)
- end)
- addHook("lockpickStarted", function(pl, ent)
- log("? начал #взлом ?", tag(pl), ent:GetClass())
- end)
- addHook("onLockpickCompleted", function(pl, succ)
- log("? ? завершил #взлом ?", tag(pl), succ and "успешно" or "безуспешно")
- end)
- addHook("playerBoughtDoor", function(pl, _, cost)
- log("? купил #дверь за ?", tag(pl), qq.formatMoney(cost))
- end)
- addHook("playerSellDoor", function(pl)
- log("? продал #дверь", tag(pl))
- end)
- addHook("onPocketItemAdded", function(pl, ent)
- log("? взял в #карман ?", tag(pl), ent:GetClass())
- end)
Advertisement
Add Comment
Please, Sign In to add comment