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

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Lua Command Lua Commands

Lua Command image



  • "path"
  • x
  • y
  • mode
  • [pl] (optional)


Creates an image (dynamic object) on the map and returns the ID for that image. Use the optional pl parameter if you want the image to be visible to a certain player only. The path is relative to the CS2D folder.

Possible modes:

  • Mode 0: floor image (covered by players etc)
  • Mode 1: top image (covering players)
  • Mode 2: HUD image (covering everything, part of the interface, affected by mp_hudscale)
  • Mode 3: super top image (covering everything on the map)
  • Mode 4: background image (covering only the background)
  • Mode 101-132: draw under this player (id+100)
  • Mode 201-232: draw over this player (id+200)
  • Mode 133-164: draw over this player and over entities (id+132)

Special meaning of x and y when drawing at player
Also when drawing an image at a player (mode 101-232), x and y are not used for the position but this way:

  • x<=0: do not rotate with player
  • x=1: rotate img with player
  • x=2: rotate and wiggle img with player
  • x=3: rotate and wiggle img with player and move correctly with recoil
  • y<=0: only draw if not covered by fog of war
  • y>0: draw always

Special path values and tags
Moreover you can use some built-in images with this function by using one of the following values for the path parameter or attach tags to change the loading behavior:

  • <tile:X> - a tile from the tileset that is used in the current map, with X being the ID of a tile, starting at 0 for the first tile in the tileset. Attention: Unlike all other Lua images the origin (rotation point/root coordinate) of tiles is not in their center but at their top left corner!
  • PATH<b> - black pixels (rgb 0,0,0 or HEX #000000) will become invisible in the specified image (this mode is used by default but another masking method might be used if the image has been loaded before with another method. So please use this tag if masking of black pixels is important)
  • PATH<m> - magenta pixels (rgb 255,0,255 or HEX #FF00FF) will become invisible in the specified image
  • PATH<a> - alpha values (opacity) will be set depending on the brightness of pixels
  • PATH<n> - no masking. The image will be loaded and displayed as it is.
  • <spritesheet:PATH:FRAMEW:FRAMEH[:MODE]> - spritesheet. PATH is the path to the image, FRAMEW and FRAMEH are the width and height of one frame, MODE is an optional masking mode to be applied to the image (see above).
  • <flag:iso> - a small flag image (16x11 pixels) for the given country ISO-3166 ALPHA-2 code. e.g.: AE for United Arab Emirates, DE for Germany, US for United States etc.
  • <avatar:id> - the avatar for the player with this player ID. This will only display something if the player is logged in via Steam or U.S.G.N. and has an avatar there. Moreover avatar download needs to be enabled.

Note: Always save the returned ID in a variable - otherwise you are not able to remove or change the image!
Note: The game will automatically remove ALL images when a new round begins!
Note: Images which are created with this command are a special type of dynamic objects (object type 40). You can use the object command to get details of your images!
Attention: Using too many images can lead to lags and other problems!
Attention: Missing images are not always transferred over the internet and you can never be sure that all clients/players actually accept and see all those images! Use the file sys/servertransfer.lst to add custom images to the transfer list (this still doesn't ensure that everyone will receive those images but it will work in most cases)
Attention: The default file size limit for transfers is 250kb! Keep each image file size smaller than that, otherwise most clients won't see your images!
Attention: CS2D recycles image IDs. The same ID might be used again for another image after you remove an image!

Sample 1: An image which is visible for all players and part of the HUD (mode 2), covering the radar

Sample 2: Creating an image and changing its look and position/rotation
local id=image("gfx/sprites/flare2.bmp",0,0,2)

Sample 3: Creating a spritesheet and changing its frame
local id=image("<spritesheet:gfx/player/t1.bm32:32:m>",1,0,201)