Links
Comment on page

Grand Theft Auto (FiveM)

This is the setup guide designed for integrating StaffWatch with Grand Theft Auto V servers using the FiveM framework.

Integrated Features

Supported Features
In-Game Commands
Notes
  • Players can view their own profile using link provided via command.
  • Commend, warn, kick, and ban players using chat commands.
  • Freeze and unfreeze players using chat commands.

Staff Commands

  • /commend [id] [reason] -> Commend players via StaffWatch.
  • /warn [id] [reason] -> Warn players via StaffWatch.
  • /kick [id] [reason] -> Kick players via StaffWatch.
  • /ban [id] [duration]?[reason] -> Ban players via StaffWatch.
  • /freeze [id] -> Freeze players from moving/driving in-game.
  • /unfreeze [id] -> Unfreeze a player to allow them to resume playing.

Player Commands

  • /trustscore -> Displays trustscore of player that executes command.
  • /report [id] [reason] -> Reports a player to in-game staff members.
  • /myprofile -> Gives the player a link to view their StaffWatch profile.
  • Supports RCON or Command Queue
  • Player Claims Required For Staff Functions

Installing Resource

The resource download can be found on the downloads page of the documentation.
From the GitHub repo, select Download ZIP then extract the file titled StaffWatch-FiveM-main.zip using 7-Zip or a similar utility.
Rename the folder however you want, but make sure that the root folder is exposed! An example of a correct file path is shown below.
/cfx-server-data
-> resources
-> [gameplay]
-> [system]
-> [misc]
-> MyStaffResource
-> fxmanifest.lua
-> config.lua
-> client.lua
-> server.lua
Open config.lua in VSCode, Notepad++, or a similar editor. Using the built-in Notepad application is strongly discouraged as it may cause issues!
Add your server secret, found on the Manage Servers page, to the config.
Config.secret = "SERVER_SECRET_HERE"
Make sure to add your resource to the server.cfg and restart the server!
start ExampleStaffResource
Congratulations! Assuming all goes well, your console will not be full of errors and everything should work! The rest of the tutorial is optional! 🎉🎉

Setting Up RCON (Optional)

RCON is no longer mandatory, and is instead only recommended for developers already experienced with RCON. The only benefit to using RCON is that commands and staff actions will be executed 2-4 seconds faster.
Pick a secure RCON password, preferably between 8-12 characters, that cannot be guessed easily. Do not share this password with anyone else!
Add the password to the bottom of your server.cfg as demonstrated below.
rcon_password "EXAMPLE_PASSWORD"
Navigate to the Manage Servers page, and configure each server to include the correct IP and port, as well as your newly configured RCON password.
To check if RCON is working properly, you can use our Debug Server tool, located on the Server Dashboard of whatever server you are trying to test!

Setting Up Logging (Optional)

In order to have the most possible usage of StaffWatch's chat and command logging system, you will have to modify the default chat resource. Luckily it is not that difficult.
Navigate to the folder containing the default FiveM chat resource. The resource is typically located under /cfx-server-data/resources/[gameplay]/chat.
In this directory, open the file labeled cl_chat.lua and copy-paste the code in the box below at the location marked by the arrows in the code-block below.
-------------------------
--- Log Chat Messages ---
-------------------------
TriggerServerEvent('staffwatch:logData', 'chat', data.message)
-------------------------
Insert the code above into the following location.
The arrows are there for reference, do not actually add them into the Lua file or it will break.
cl_chat.lua
RegisterNUICallback('chatResult', function(data, cb)
chatInputActive = false
SetNuiFocus(false)
if not data.canceled then
local id = PlayerId()
--deprecated
local r, g, b = 0, 0x99, 255
-> -> -------------------------
-> -> --- Log Chat Messages ---
-> -> -------------------------
-> -> TriggerServerEvent('staffwatch:logData', 'chat', data.message)
-> -> -------------------------
if data.message:sub(1, 1) == '/' then
ExecuteCommand(data.message:sub(2))
else
TriggerServerEvent('_chat:messageEntered', GetPlayerName(id), { r, g, b }, data.message)
end
end
cb('ok')
end)