Skip to content

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
outdead committed Dec 1, 2019
1 parent c5ea70f commit c4cfc14
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 12 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.2.0] - 2019-09-24
## [v0.3.0] - 2019-12-01
### Added
- Add Events.OnEnterVehicle callback. Saves coordinates of the player's entry into the vehicle to {{dd-mm-yy_h-i}}_cmd.txt log file.
- Add Events.OnExitVehicle callback. Saves player's exit coordinates from vehicle to {{dd-mm-yy_h-i}}_cmd.txt log file.
- Add Events.EveryHours callback. Makes saving the character to {{dd-mm-yy_h-i}}_player.txt log file every one ingame hour.

### Changed
- Events can be turned on or off in the configuration of the LogExtender object.

### Fixed
- Removed levelup entries from the character’s creation window until the server is fully connected.

## [v0.2.0] - 2019-09-24
### Added
- Add level to dump player stats.
- Start writing changelog.
Expand All @@ -28,7 +40,8 @@ All notable changes to this project will be documented in this file.
### Added
- Add basic implementation.

[Unreleased]: https://github.com/gorcon/rcon-cli/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/gorcon/rcon-cli/compare/v0.3.0...HEAD
[v0.3.0]: https://github.com/gorcon/rcon-cli/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/gorcon/rcon-cli/compare/v0.1.2...v0.2.0
[v0.1.2]: https://github.com/gorcon/rcon-cli/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/gorcon/rcon-cli/compare/v0.1.0...v0.1.1
85 changes: 75 additions & 10 deletions workshop/Contents/mods/LogExtender/media/lua/client/LogExtender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
-- LogExtender adds more logs to the Logs directory the Project Zomboid game.
--

local version = "0.2.0"
local version = "0.3.0"

LogExtender = {
local LogExtender = {
-- Contains default config values.
config = {
-- placeholders for Project Zomboid log file names.
-- Placeholders for Project Zomboid log file names.
-- Project Zomboid generates files like this 24-08-19_18-11_chat.txt
-- at firts action and use file until next server restart.
filemask = {
Expand All @@ -19,15 +20,31 @@ LogExtender = {
player = "player",
item = "item",
map = "map",
admin = "admin"
}
admin = "admin",
},
-- Callbacks switches.
actions = {
player = {
connected = true,
levelup = true,
tick = true,
disconnected = false, -- TODO: How can I do this?
},
vehicle = {
enter = true,
exit = true,
},
time = true,
},
},
player = nil
-- Store ingame player object when user is logged in.
player = nil,
}

-- getLogLinePrefix generates prefix for each log lines.
-- for ease of use, we assume that the player’s existence has been verified previously.
LogExtender.getLogLinePrefix = function(player, action)
-- TODO: Add ownerID.
return getCurrentUserSteamID() .. " \"" .. player:getUsername() .. "\" " .. action
end

Expand Down Expand Up @@ -193,7 +210,7 @@ end
LogExtender.OnConnected = function()
local player = getSpecificPlayer(0);
if player then
LogExtender.player = player;
--LogExtender.player = player;
LogExtender.DumpPlayer(player, "connected");
end
end
Expand All @@ -202,16 +219,64 @@ end
LogExtender.OnPerkLevel = function(player, perk, perklevel)
if player and perk and perklevel then
if instanceof(player, 'IsoPlayer') and player:isLocalPlayer() then
-- Hide events from the log when creating a character.
if player:getHoursSurvived() <= 0 then return end

LogExtender.DumpPlayer(player, "levelup");
end
end
end

-- EveryHours adds callback for EveryHours global event.
LogExtender.EveryHours = function()
local player = getSpecificPlayer(0);
if player and instanceof(player, 'IsoPlayer') and player:isLocalPlayer() then
-- Hide events from the log when creating a character.
if player:getHoursSurvived() <= 0 then return end

LogExtender.DumpPlayer(player, "tick");
end
end

-- VehicleEnter adds collback for OnEnterVehicle event.
LogExtender.VehicleEnter = function(player)
if player and instanceof(player, 'IsoPlayer') and player:isLocalPlayer() then
local location = math.floor(player:getX()) .. "," .. math.floor(player:getY()) .. "," .. math.floor(player:getZ());
local message = LogExtender.getLogLinePrefix(player, "vehicle.enter") .. " @ " .. location;
writeLog(LogExtender.config.filemask.cmd, message);
end
end

-- VehicleExit adds collback for OnExitVehicle event.
LogExtender.VehicleExit = function(player)
if player and instanceof(player, 'IsoPlayer') and player:isLocalPlayer() then
local location = math.floor(player:getX()) .. "," .. math.floor(player:getY()) .. "," .. math.floor(player:getZ());
local message = LogExtender.getLogLinePrefix(player, "vehicle.exit") .. " @ " .. location;
writeLog(LogExtender.config.filemask.cmd, message);
end
end

-- OnGameStart adds callback for OnGameStart global event.
LogExtender.OnGameStart = function()
LogExtender.OnConnected();
LogExtender.TimedActionPerform();
if LogExtender.config.actions.player.connected then
LogExtender.OnConnected();
end

if LogExtender.config.actions.player.levelup then
Events.LevelPerk.Add(LogExtender.OnPerkLevel);
end

if LogExtender.config.actions.player.tick then
Events.EveryHours.Add(LogExtender.EveryHours);
end

if LogExtender.config.actions.vehicle.enter then
Events.OnEnterVehicle.Add(LogExtender.VehicleEnter);
end

if LogExtender.config.actions.vehicle.exit then
Events.OnExitVehicle.Add(LogExtender.VehicleExit);
end
end

Events.OnGameStart.Add(LogExtender.OnGameStart);
Events.LevelPerk.Add(LogExtender.OnPerkLevel);

0 comments on commit c4cfc14

Please sign in to comment.