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) +``` 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)