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 name

Categories

Parameters

  • id: player id
  • oldname: old player name
  • newname: new player name
  • forced: was nickname forced by server command (0/1) or changed delayed (2)

Info

When the name of a player is being changed or a delayed name change is scheduled.

"forced" will be 0 if the name change was triggered by the player.
It will be 1 if the name change was forced by the server with the setname command.
In case it's a delayed name change because the player was dead while triggering it, "forced" will be 2 (read details below!).

Delayed Name Changing
If the name is changed by the player (not via setname) while being dead/not in a team, it will be delayed.
  • The hook will be triggered instantly (with forced=0) when the dead player tries to change the name. This can be cancelled with return 1 (name change won't be scheduled then and the second hook call below won't be triggered). The name will NOT YET be changed at that point!

  • As soon as the player is alive again (with up to 1 sec delay) the name will be ACTUALLY changed. When this happens the hook will be triggered a second time but with forced=2. This can be cancelled with return 1 as well (name won't be changed then).


Note: Dead players can't change names instantly. If they try to do so their rename will be scheduled and executed later. The hook will be triggered 2 times (once for scheduling and once for actually changing the name) in that case. Read the explanation above!

Return Values

  • 0: proceed normally
  • 1: don't change name

Lua Command Lua Commands