Commands/Lua

Reference for console commands, Lua hooks and Lua commands in CS2D.

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Category: all (79)

Lua Hook connect_attempt

Categories

Parameters

  • name: player name (string)
  • ip: player IP (string)
  • port: player port (number)
  • usgnID: player USGN ID (number, 0 if none)
  • usgnName: player USGN name (string, "" if none)
  • steamID: player Steam ID (string!, "0" if none)
  • steamName: player Steam name (string, "" if none)

Info

When a player tries to connect to a server. This hook is called at the very beginning of each connection attempt.
The player is not even created on the server at that point which is why you can't retrieve a player ID in this hook.

You can return a string in this hook to cancel the connection process instantly.
The player will see the string as ban reason.
Return nothing or an empty string to continue normally.

Hook execution order when a player connects/joins:


Note: This hook is NOT triggered for bots!

Attention: name is not verified at this point. It's what the client sent and it may contain an invalid name which is automatically modified by the server in later steps to match the requirements for a valid name.

Attention: usgnID, usgnName, steamID and steamName are not verified at this point and may be fake!

Attention: The player is not fully connected at that point. This is why there is no ID parameter. Use the join hook instead if you want to show stuff to the new player.

Return Values

  • "": (nothing) continue normally
  • anything else: cancel the connection process. Client will see a ban popup and the returned string will be displayed as ban reason

Lua Command Lua Commands