From 8c33bcac17e77b79d558009ba60e7ba18af2a873 Mon Sep 17 00:00:00 2001 From: outdead Date: Wed, 23 Feb 2022 18:14:19 +0300 Subject: [PATCH] Add safehouse logs --- README.md | 8 +++++ src/lua/client/LogExtender.lua | 61 ++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3a715e2..fb00202 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,14 @@ This mod does not work in single player mode. Therefore, it must be installed on ``` There can be `connected`, `levelup` and `tick` events. +### _safehouse.txt +```text +[23-02-22 17:31:51.126] 76561190000000000 "outdead" take safehouse 10909,9397,11,11 owner="outdead". +[23-02-22 18:04:53.263] 76561190000000000 "outdead" release safehouse 10909,9397,11,11 owner="outdead" members=["rez"]. +[23-02-22 17:40:16.922] 76561190000000000 "outdead" remove player from safehouse 10909,9397,11,11 owner="outdead" target="rez". +[23-02-22 17:39:09.932] 76561190000000000 "outdead" join to safehouse 10880,9401,8,11 owner="rez". +``` + ## Warning Log Extender is under development and is being tested on the server [Last Day](https://last-day.wargm.ru). You can join our server or use the mod on your own server. If you think you have found a bug, write about it in the [bug reporting topic](https://steamcommunity.com/workshop/filedetails/discussion/1844524972/1638668751263547005/) diff --git a/src/lua/client/LogExtender.lua b/src/lua/client/LogExtender.lua index 6488945..1e9ca9c 100644 --- a/src/lua/client/LogExtender.lua +++ b/src/lua/client/LogExtender.lua @@ -328,15 +328,6 @@ LogExtender.DumpSafehouse = function(player, action, safehouse, target) local area = {} local owner = player:getUsername() - --if instanceof(safehouse, 'IsoGridSquare') then - -- local zone = safehouse:getZone() - -- area = { - -- Top = zone:getX() .. "x" .. zone:getY(), - -- Bottom = zone:getX()+zone:getHeight() .. "x" .. zone:getY()+zone:getWidth(), - -- zone = zone:getX() .. "," .. zone:getY() .. "," .. zone:getHeight() .. "," .. zone:getWidth() - -- }; - --end - if instanceof(safehouse, 'SafeHouse') then owner = safehouse:getOwner(); area = { @@ -348,9 +339,26 @@ LogExtender.DumpSafehouse = function(player, action, safehouse, target) message = message .. ' ' .. area.zone message = message .. ' owner="' .. owner .. '"' + + if action == "release safehouse" then + message = message .. ' members=[' + + local members = safehouse:getPlayers(); + for j = 0, members:size() - 1 do + local member = members:get(j) + + if member ~= owner then + message = message .. '"' .. member .. '"' + if j ~= members:size() - 1 then + message = message .. ',' + end + end + end + message = message .. ']' + end else - message = message .. ' ' .. '0,0,0,0' - message = message .. ' owner="' .. '' .. '"' + message = message .. ' ' .. '0,0,0,0' -- TODO: What can I do? + message = message .. ' owner="' .. player:getUsername() .. '"' end if target ~= nil then @@ -406,7 +414,15 @@ LogExtender.OnTakeSafeHouse = function() originalOnTakeSafeHouse(worldobjects, square, player) local character = getSpecificPlayer(player) - LogExtender.DumpSafehouse(character, "take safehouse", square, nil) + local safehouse = nil + + local safehouseList = SafeHouse.getSafehouseList(); + for i = 0, safehouseList:size() - 1 do + safehouse = safehouseList:get(i); + break; + end + + LogExtender.DumpSafehouse(character, "take safehouse", safehouse, nil) end end @@ -430,7 +446,15 @@ LogExtender.OnReleaseSafeHouseCommand = function() local command = ISChat.instance.textEntry:getText(); if command == "/releasesafehouse" then local character = getSpecificPlayer(0) - LogExtender.DumpSafehouse(character, "release safehouse", nil, nil) + local safehouse = nil + + local safehouseList = SafeHouse.getSafehouseList(); + for i = 0, safehouseList:size() - 1 do + safehouse = safehouseList:get(i); + break; + end + + LogExtender.DumpSafehouse(character, "release safehouse", safehouse, nil) end onCommandEnteredOriginal(self) @@ -438,7 +462,7 @@ LogExtender.OnReleaseSafeHouseCommand = function() end LogExtender.OnRemovePlayerFromSafehouse = function() - local onCommandEnteredOriginal = ISChat.onCommandEntered; + local onRemovePlayerFromSafehouseOriginal = ISSafehouseUI.onRemovePlayerFromSafehouse; ISSafehouseUI.onRemovePlayerFromSafehouse = function(self, button, player) if button.internal == "YES" then @@ -446,7 +470,7 @@ LogExtender.OnRemovePlayerFromSafehouse = function() LogExtender.DumpSafehouse(character, "remove player from safehouse", button.parent.ui.safehouse, button.parent.ui.selectedPlayer) end - onCommandEnteredOriginal(self, button, player) + onRemovePlayerFromSafehouseOriginal(self, button, player) end end @@ -579,12 +603,11 @@ LogExtender.OnGameStart = function() end if SandboxVars.LogExtender.TakeSafeHouse then - --LogExtender.OnTakeSafeHouse() + LogExtender.OnTakeSafeHouse() end if SandboxVars.LogExtender.ReleaseSafeHouse then LogExtender.OnReleaseSafeHouse() - LogExtender.OnReleaseSafeHouseCommand() end if SandboxVars.LogExtender.RemovePlayerFromSafehouse then @@ -596,4 +619,8 @@ LogExtender.OnGameStart = function() end end +if SandboxVars.LogExtender.ReleaseSafeHouse then + LogExtender.OnReleaseSafeHouseCommand() +end + Events.OnGameStart.Add(LogExtender.OnGameStart);