Installation

Installing txLogin has never been easier.

  • Drag & Drop the resource into your server and make sure to start it in the server.cfg using: ensure txLogin

  • Head over to Shared/Settings.lua and fill in all the necessary information, everything is explained next to the setting.

  • If necessary, make any changes to the functions in server/logger.lua to change the text regarding the logs.

  • Same goes for client/notify.lua, change to your liking.

Next up we will look at inserting the code into the txAdmin to disable the menu from popping up when not logged in.

  • Locate the following file within you artifacts folder:

Windows:

citizen/system_resources/monitor/resource/menu/client/cl_base.lua

Linux:

alpine/opt/cfx-server/citizen/system_resources/monitor/resource/menu/client/cl_base.lua

  • After locating the file, replace the following piece of code at line 77:

RegisterNetEvent('txcl:setAdmin', function(username, perms, rejectReason)
  if type(perms) == 'table' then
    debugPrint("^2[AUTH] logged in as '" .. username .. "' with perms: " .. json.encode(perms or "nil"))
    menuIsAccessible = true
    menuPermissions = perms
    RegisterKeyMapping('txadmin', 'Menu: Open Main Page', 'keyboard', '')
    RegisterKeyMapping('txAdmin:menu:openPlayersPage', 'Menu: Open Players page', 'KEYBOARD', '')
    RegisterKeyMapping('txAdmin:menu:noClipToggle', 'Menu: Toggle NoClip', 'keyboard', '')
    RegisterKeyMapping('txAdmin:menu:togglePlayerIDs', 'Menu: Toggle Player IDs', 'KEYBOARD', '')
  else
    noMenuReason = tostring(rejectReason)
    debugPrint("^3[AUTH] rejected (" .. noMenuReason .. ")")
    if awaitingReauth then
      displayAuthRejectedError()
      awaitingReauth = false
    end
    menuIsAccessible = false
    menuPermissions = {}
  end
  sendMenuMessage('setPermissions', menuPermissions)
end)

By changing line 80 we get this changed code.

RegisterNetEvent('txcl:setAdmin', function(username, perms, rejectReason)
  if type(perms) == 'table' then
    debugPrint("^2[AUTH] logged in as '" .. username .. "' with perms: " .. json.encode(perms or "nil"))
    menuIsAccessible = exports['txLogin']:isLoggedIn()
    menuPermissions = perms
    RegisterKeyMapping('txadmin', 'Menu: Open Main Page', 'keyboard', '')
    RegisterKeyMapping('txAdmin:menu:openPlayersPage', 'Menu: Open Players page', 'KEYBOARD', '')
    RegisterKeyMapping('txAdmin:menu:noClipToggle', 'Menu: Toggle NoClip', 'keyboard', '')
    RegisterKeyMapping('txAdmin:menu:togglePlayerIDs', 'Menu: Toggle Player IDs', 'KEYBOARD', '')
  else
    noMenuReason = tostring(rejectReason)
    debugPrint("^3[AUTH] rejected (" .. noMenuReason .. ")")
    if awaitingReauth then
      displayAuthRejectedError()
      awaitingReauth = false
    end
    menuIsAccessible = false
    menuPermissions = {}
  end
  sendMenuMessage('setPermissions', menuPermissions)
end)

That's all! You're ready to use txLogin as a resource to protect your server against staff using their txMenu whilst in a roleplay scenario! For more information on how to use the txLogin to block other events please refer to the next page.

Last updated