Guest User

trigon.im garry's mod logs to telegram: https://forum.gm-donate.net/t/luchshaya-sistema-logov/3671

a guest
May 3rd, 2023
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.24 KB | None | 0 0
  1. local function addHook(name, cb)
  2.     hook.Add(name, "TLG_ADMIN.serverlogs", cb)
  3. end
  4.  
  5. local buffer = Stack()
  6. local repeats, lastline
  7. local function log(patt, ...)
  8.     local args = {...}
  9.     local count = 0
  10.     local str = patt:gsub("?", function()
  11.         count = count + 1
  12.         return args[count]
  13.     end)
  14.  
  15.     if str == lastline then
  16.         repeats = repeats + 1
  17.         buffer:lpop() -- #u1 пытается использовать #tool advdupe2 (4)
  18.         buffer:lpush(str .. " (x" .. repeats .. ")") -- #u9725 пытается использовать #tool advdupe2 (5)
  19.     else
  20.         buffer:lpush(str)
  21.         lastline = str
  22.         repeats = 1
  23.     end
  24. end
  25.  
  26. local TLG_LOGS = -1001211638609
  27. timer.Create("telegram_serverlogs", 15, 0, function()
  28.     if buffer:isempty() then return end
  29.  
  30.     local logstr = "#" .. SERVERS:Name()
  31.     for _ = 1,math.min(20, buffer:length()) do
  32.         logstr = logstr .. "\n" .. buffer:rpop()
  33.     end
  34.  
  35.     lastline = nil -- https://img.qweqwe.ovh/1594906189275.jpg
  36.     TLG_ADMIN.reply(TLG_LOGS).silent().disablePreview().html(logstr)
  37. end)
  38.  
  39.  
  40. local function tag(pl)
  41.     if pl:IsBot() then
  42.         return "#bot"
  43.     else -- player
  44.         local s64 = pl:SteamID64()
  45.         return htmlURL(pl:Nick(), util.SteamIDToProfile(s64))
  46.     end
  47. end
  48.  
  49. -------------------
  50. --  Connections  --
  51. -------------------
  52. addHook("PlayerDataLoaded", function(pl)
  53.     local s64 = pl:SteamID64()
  54.     local nick = pl:Nick()
  55.     local contact = "Steam " .. htmlURL(nick, util.SteamIDToProfile(s64))
  56.     local tlg_id = TLG_CONNECT_BOT.CONNECTIONS[s64]
  57.     if tlg_id then
  58.         contact = "TLG " .. tlgMention(nick, tlg_id, "html")
  59.     -- elseif VKB.PlayerID(pl) then
  60.     --  contact = "VK " .. htmlURL(nick, "https://vk.com/id" .. VKB.PlayerID(pl))
  61.     end
  62.     log("#connections ? подключился. Контакт: ?", pl:SteamID(), contact)
  63. end)
  64.  
  65. addHook("PlayerDisconnected", function(pl)
  66.     log("#connections ? отключился", tag(pl))
  67. end)
  68.  
  69.  
  70. -------------
  71. --  Kills  --
  72. -------------
  73. local function foo(attacker)
  74.     if IsValid(attacker) and attacker:IsPlayer() then
  75.         local sAttacker, weapon
  76.  
  77.         sAttacker = tag(attacker)
  78.         weapon = (IsValid(attacker:GetActiveWeapon()) and attacker:GetActiveWeapon():GetClass() or "unknown")
  79.  
  80.         return sAttacker, weapon
  81.     end
  82. end
  83.  
  84. addHook("PlayerDeath", function(pl, _, attacker)
  85.     local sAttacker, weapon = foo(attacker)
  86.     if sAttacker then
  87.         log("? #убил ? при помощи ?", sAttacker, tag(pl), weapon)
  88.     end
  89. end)
  90.  
  91. addHook("PostPlayerTakeDamage", function(pl, _, attacker, amount, dmg, took)
  92.     if took and dmg:IsBulletDamage() then
  93.         local sAttacker, weapon = foo( attacker )
  94.         if sAttacker then
  95.             log("? нанес ? #урона по ? при помощи ?", sAttacker, math.Round(amount, 0), tag(pl), weapon)
  96.         end
  97.     end
  98. end)
  99.  
  100.  
  101. -------------
  102. --  Props  --
  103. -------------
  104. local spawned_props = setmetatable({}, {__mode = "kv"}) -- sid > count
  105. addHook("PlayerSpawnProp", function(pl)
  106.     spawned_props[tag(pl)] = (spawned_props[tag(pl)] or 0) + 1
  107. end)
  108. timer.Create("spawned_props_logs_group", 60, 0, function()
  109.     for tagg,count in pairs(spawned_props) do
  110.         log("? #заспавнил ? пропов за 1 мин", tagg, count)
  111.         spawned_props[tagg] = nil
  112.     end
  113. end)
  114.  
  115. addHook("PlayerSpawnedRagdoll", function(pl, mdl)
  116.     log("? #заспавнил рэгдол ?", tag(pl), ulx.standardizeModel(mdl))
  117. end)
  118.  
  119. addHook("PlayerSpawnedEffect", function(pl, mdl)
  120.     log("? #заспавнил эффект ?", tag(pl), ulx.standardizeModel(mdl))
  121. end)
  122.  
  123. addHook("PlayerSpawnedVehicle", function(pl, ent)
  124.     log("? #заспавнил транспорт ?", tag(pl), ulx.standardizeModel(ent:GetModel() or "unknown"))
  125. end)
  126.  
  127. addHook("PlayerSpawnedSENT", function(pl, ent)
  128.     log("? #заспавнил энтити ?", tag(pl), ent:GetClass())
  129. end)
  130.  
  131. addHook("PlayerSpawnedNPC", function(pl, ent)
  132.     log("? #заспавнил NPC ?", tag(pl), ent:GetClass())
  133. end)
  134.  
  135.  
  136. -------------
  137. --  Tools  --
  138. -------------
  139. addHook("CanTool", function(pl, _, tool)
  140.     log("? пытается использовать #тул ?", tag(pl), tool)
  141. end)
  142.  
  143.  
  144. -----------
  145. --  ULX  --
  146. -----------
  147. timer.Simple(1, function()
  148. addHook(ULib.HOOK_COMMAND_CALLED, function(pl, cmd, args)
  149.     if pl:IsPlayer() then
  150.         log("? выполнил #ulx команду ? ?", tag(pl), cmd, table.concat(args, " "))
  151.     end
  152. end)
  153. end)
  154.  
  155. local function onNameChanged(pl, old, new)
  156.     log("? изменил свой #ник с ? на ?", tag(pl), old, new)
  157. end
  158.  
  159. addHook("ULibPlayerNameChanged", onNameChanged)
  160. addHook("onPlayerChangedName", onNameChanged)
  161.  
  162. --------------
  163. --  DarkRP  --
  164. --------------
  165. addHook("onHitAccepted", function(hitman, target, customer)
  166.     log("#Хитмэн ? принял заказ на убийство ? от ?", tag(hitman), tag(target), tag(customer))
  167. end)
  168.  
  169. addHook("onHitCompleted", function(hitman, target, customer)
  170.     log("#Хитмэн ? выполнил заказ на убийство ? от ?", tag(hitman), tag(target), tag(customer))
  171. end)
  172.  
  173. addHook("onHitFailed", function(hitman, target, reason)
  174.     log("#Хитмэн ? провалил заказ на убийство ? по причине: ?", tag(hitman), tag(target), reason)
  175. end)
  176.  
  177. addHook("OnPlayerChangedTeam", function(pl, old, new)
  178.     log("? изменил #работу с ? на ?", tag(pl), team.GetName(old), team.GetName(new))
  179. end)
  180.  
  181. addHook("onPlayerDemoted", function(demoter, demotee, reason)
  182.     log("? начал #понижение ? по причине: ?", tag(demoter), tag(demotee), reason)
  183. end)
  184.  
  185. addHook("playerArrested", function(target, _, officer)
  186.     log("? #arrested ?", tag(officer), tag(target))
  187. end)
  188.  
  189. addHook("playerUnArrested", function(target, officer)
  190.     if IsValid(officer) then
  191.         log("? #unarrested ?", tag(officer), tag(target))
  192.     else
  193.         log("? был #unarrested с тюрьмы", tag(target))
  194.     end
  195. end)
  196.  
  197. addHook("playerWanted", function(target, officer, reason)
  198.     if IsValid(officer) then
  199.         log("? #wanted ? за ?", tag(officer), tag(target), reason)
  200.     end
  201. end)
  202.  
  203. addHook("playerUnWanted", function(target, officer)
  204.     if IsValid(officer) then
  205.         log("? #unwanted ?", tag(officer), tag(target))
  206.     else
  207.         log("? #unwanted, так как срок розыска истек", tag(target))
  208.     end
  209. end)
  210.  
  211. addHook("playerWarranted", function(target, officer, reason)
  212.     if IsValid(officer) then
  213.         log("? #warranted ? за ?", tag(officer), tag(target), reason)
  214.     end
  215. end)
  216.  
  217. addHook("playerUnWarranted", function(target, officer)
  218.     if IsValid(officer) then
  219.         log("? #unwarranted ?", tag(officer), tag(target))
  220.     else
  221.         log("? #unwarranted, так как срок ордера истек", tag(target))
  222.     end
  223. end)
  224.  
  225. addHook("playerBoughtCustomEntity", function(pl, ent_tbl)
  226.     log("? #купил ? за ?", tag(pl), ent_tbl.name, ent_tbl.price)
  227. end)
  228.  
  229. addHook("lockpickStarted", function(pl, ent)
  230.     log("? начал #взлом ?", tag(pl), ent:GetClass())
  231. end)
  232.  
  233. addHook("onLockpickCompleted", function(pl, succ)
  234.     log("? ? завершил #взлом ?", tag(pl), succ and "успешно" or "безуспешно")
  235. end)
  236.  
  237. addHook("playerBoughtDoor", function(pl, _, cost)
  238.     log("? купил #дверь за ?", tag(pl), qq.formatMoney(cost))
  239. end)
  240.  
  241. addHook("playerSellDoor", function(pl)
  242.     log("? продал #дверь", tag(pl))
  243. end)
  244.  
  245. addHook("onPocketItemAdded", function(pl, ent)
  246.     log("? взял в #карман ?", tag(pl), ent:GetClass())
  247. end)
  248.  
Advertisement
Add Comment
Please, Sign In to add comment