From 210a71fad3aa9188f8c6fb1d839056921b1ad7d0 Mon Sep 17 00:00:00 2001 From: TehSteel <50503589+TehSteel@users.noreply.github.com> Date: Tue, 9 May 2023 15:44:51 +0300 Subject: [PATCH 1/2] Server side command logger --- resource/sv_logger.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resource/sv_logger.lua b/resource/sv_logger.lua index 07740c14a..9a06a65c3 100644 --- a/resource/sv_logger.lua +++ b/resource/sv_logger.lua @@ -206,6 +206,10 @@ RegisterNetEvent('txaLogger:CommandExecuted', function(data) logger(source, 'CommandExecuted', data) end) +RegisterServerEvent('txaLogger:server:commandExecuted', function(source, data) + logger(source, 'CommandExecuted', data) +end) + --FIXME: didn't migrate to keep compatibility with external calls RegisterNetEvent('txaLogger:DebugMessage', function(data) logger(source, 'DebugMessage', data) From 762b09a30c8b2dd1165a073ed95a899c55d57c25 Mon Sep 17 00:00:00 2001 From: TehSteel <50503589+TehSteel@users.noreply.github.com> Date: Tue, 9 May 2023 15:55:23 +0300 Subject: [PATCH 2/2] Update custom_serverlog.md --- docs/custom_serverlog.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/custom_serverlog.md b/docs/custom_serverlog.md index 58a7bf3d5..52548247b 100644 --- a/docs/custom_serverlog.md +++ b/docs/custom_serverlog.md @@ -2,9 +2,9 @@ This feature allows you to add logging for custom commands like `/car` and `/tp`. To do that, you will need to edit the scripts of those commands to trigger a `txaLogger:CommandExecuted` event. -> **Note: for now this only supports client commands!** -## How to Enable +## Client Side +### How to Enable In the client script, add the following event call inside the command function: @@ -15,7 +15,7 @@ TriggerServerEvent('txaLogger:CommandExecuted', rawCommand) Where `rawCommand` is a variable containing the full command with parameters. You don't NEED to pass `rawCommand`, you can edit this string or pass anything you want. -## Example +### Example In this example, we will log data from the `/car` command from the `CarCommand` script. @@ -28,3 +28,27 @@ RegisterCommand('car', function(source, args, rawCommand) -- there is more code here, no need to edit end) ``` + +## Server Side + +### How to Enable +In the server script, add the following event call inside the command function: + +```lua +TriggerEvent('txaLogger:server:commandExecuted', source, rawCommand) +``` + +Where `rawCommand` is a variable containing the full command with parameters. +You don't NEED to pass `rawCommand`, you can edit this string or pass anything you want. + +### Example + +In this example, we will log data from the `/kick` command from the `KickCommand` script. + +```lua +RegisterCommand('kick', function(source, args, rawCommand) + TriggerEvent('txaLogger:server:commandExecuted', source, rawCommand) -- txAdmin logging Callback + + DropPlayer(args[1], 'Dropped!') +end, true) +```