Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server side command logger #821

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions docs/custom_serverlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.

Expand All @@ -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)
```
4 changes: 4 additions & 0 deletions resource/sv_logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down