Commands/Lua

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

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Lua Command Lua Commands

Category: player (12)

Lua Command player

Categories

Parameters

  • id
  • "value"

Info

Returns a value of a player or a table of players. Returns false if the specified player, value or table does not exist.
Values and tables which can be requested are:

Identity & Logins & Language
  • exists: boolean, true if player with this ID exists, false otherwise

  • name: name of the player

  • ip: IP address of the player

  • port: Port of the player

  • usgn: Unreal Software Gaming Network / UnrealSoftware.de user ID (0 if not logged in)

  • usgnname: Unreal Software Gaming Network / UnrealSoftware.de user name ("" if not logged in)

  • steamid: Steam ID as string ("0" if not logged in)

  • steamname: Steam user name ("" if not logged in. Can also be "" for users who are logged in if name retrieval failed)

  • bot: boolean, true if player is a bot, false otherwise

  • rcon: boolean, true if logged in with correct RCon password, false otherwise

  • language: Current language of the player as string

  • language_iso: Current language of the player as ISO code string

Attention: steamid looks like a number but is always a string! So make sure to save and use it like a string in your scripts!


Team & Appearance
  • team: 0 for spec, 1 for t, 2 for ct, 3 for VIP (ct)
    CS2D Teams

  • favteam: favorite team (if joining the preferred team is not possible (e.g. in Zombies! mode), the preferred team will be saved in here)

  • look: player look (0-3) / selected faction skin

  • sprayname: name of spaylogo file

  • spraycolor: color of spraylogo (0-based index, see spray colors in options menu for reference)


Mouse Position & Screen/Setup
  • mousex: player mouse x screen position (alive players only, -1 if not available)

  • mousey: player mouse y screen position (alive players only, -1 if not available)

  • mousemapx: player mouse x position on map (alive players only, -1 if not available)

  • mousemapy: player mouse y position on map (alive players only, -1 if not available)

  • mousedist: distance between player and player mouse (alive players only, -1 if not available)

  • screenw: game screen width (in pixels) of this player. Game area only, possible borders not included.

  • screenh: game screen height (in pixels) of this player. Game area only, possible borders not included.

  • widescreen: is game running in widescreen mode? (0/1, inverted value of 4:3 client setting)

  • windowed: is game running in windowed mode? (0/1)

  • micsupport: does the player have microphone support? (0/1)


Position
  • x: current x position on map (in pixels)

  • y: current y position on map (in pixels)

  • tilex: current x position on map (in tiles)

  • tiley: current y position on map (in tiles)

  • rot: current rotation angle


Stats
  • health: health value

  • maxhealth: maximum health

  • armor: armor value
    • 0 - 200: Regular Kevlar(+Helm) armor points (damage reduction, reduced on hit. See mp_kevlar for details)

    • 201: Light Armor (Item 79), -25% damage

    • 202: Armor (Item 80), -50% damage

    • 203: Heavy Armor (Item 81), -75% damage

    • 204: Medic Armor (Item 82), -50% damage, +10 HP/sec

    • 205: Super Armor (Item 83), -95% damage

    • 206: Stealth Suit (Item 84), no damage reduction, makes player less visible

  • money: money value

  • score: score (kills+mission goals)

  • deaths: number of deaths

  • teamkills: teammates killed

  • hostagekills: hostages killed

  • teambuildingkills: buildings of own team killed

  • mvp: number of rounds the player was the MVP (most valuable player)

  • assists: number of kill assists

  • ping: current ping (in milliseconds)

  • idle: idle time (no movement) in full seconds (int)

  • speedmod: speed modifier value. 0=normal speed, >0 faster, <0 slower (see speedmod command for details)

  • spectating: ID of the player this player is currently spectating / was spectating last

  • ai_flash: how long (in seconds, float) is this bot flashed by a flashbang (0 for not flashed)


Equipment
  • weapontype: type of current weapon

  • weaponmode: mode of the current weapon (0 for standard, >0 for zoom, burst, ...)

  • nightvision: boolean, true if has a nightvision, false otherwise

  • defusekit: boolean, true if has a defusekit, false otherwise

  • gasmask: boolean, true if has a gasmask, false otherwise

  • bomb: boolean, true if has bomb, false otherwise

  • flag: boolean, true if has a flag, false otherwise

Note: You can use the playerweapons Lua command to get all weapons owned by a player!

Note: You can use the playerammo Lua command to get ammo values of a player!


Actions & Voting
  • reloading: boolean, true if is currently reloading, false otherwise

  • process: current process (internal id for reloading/planting/defusing...)
    • 1 - Start bomb planting

    • 2 - Cancel bomb planting

    • 3 - End bomb planting

    • 4 - Cancel bomb defuse

    • 5 - End bomb defuse

    • 6 - Bomb explode

  • votekick: ID of the player the player voted to kick (or 0 if player did not vote to kick anyone)

  • votemap: name of the map the player voted for (or empty string if player did not vote for a map)


Tables
Moreover there are some parameters to get tables of all players matching certain conditions:
  • player(0,"table"): a Lua table with all player IDs

  • player(0,"tableliving"): a Lua table with all living player IDs

  • player(0,"team1"): a Lua table with all terrorist/zombie IDs

  • player(0,"team2"): a Lua table with all counter-terrorist/survivor IDs

  • player(0,"team1living"): a Lua table with all living terrorist/zombie IDs

  • player(0,"team2living"): a Lua table with all living counter-terrorist/survivor IDs


Sample 1: Using the player table to list the names of all players
local playerlist=player(0,"table")
for _,id in pairs(playerlist) do
   print(player(id,"name"))
end