Commands/Lua
Reference for console commands, Lua hooks and Lua commands in CS2D.
- Console Commands are entered in console, executed with key-binds, cfg-files or with Lua parse
- Lua Hooks execute Lua when events occur - some have a return value which can change the game behavior
- Lua Commands are used to retrieve game data or to perform actions in Lua scripts
CS2D Console Commands
Lua Hooks
Lua Commands
menuCategories
Parameters
- id
- "menu-content"
Info
Opens a menu on the screen of a certain player (id=player id) or at the screen of every player (id=0)!
The menu-content string defines the look and content of the menu. It's limited to 400 chars.
Scheme: "title,b1,b2,...,b9"
- title = title of the menu (Attach @b at the end of title for a bigger menu or @i for an invisible menu)
- b1-b9 = up to 9 button captions. Use empty strings for buttons you don't need. Captions can also be split into 2 parts by using "|" (scheme: "left caption|right caption"). Moreover you can put () around a caption to make a disabled button.
The menu-hook is executed when a player hits a menu button with the mouse or presses the corresponding numeric key.
Note: This command has just TWO (2) paramters! The first one is the player id and the second one a string which defines the contents of the menu!
Attention: The menu-content string is limited to a length of 400 chars!
Sample 1: A simple menu for player 1
menu(1,"Sample Menu With 3 Buttons,Button 1,Button 2,Button 3")
Sample 2: A big menu for player 2
menu(2,"Big Menu With 3 Buttons@b,Button 1,Button 2,Button 3")
Sample 3: A menu with a button left out (creating space between button 1 and 2)
menu(1,"Space,Button 1,,Button 2")
Sample 4: A menu with advanced button captions and a disabled button
menu(1,"Custom Buy Menu,Item 1|$5,Item 2|$50,(Item 3|$999999),Item 4|$0")
Sample 5: An invisible menu (can be used to capture hits of numeric keys)
menu(1,"Hidden@i,b1,b2,b3")
Sample 6: Processing menu actions using the menu-hook
addhook("menu","myMenu")
function myMenu(id,title,button)
msg("player "..player(id,"name").." has pressed button #"..button.." in the menu '"..title.."'!")
end
Categories
Parameters
- id
- "menu-content"
Info
Opens a menu on the screen of a certain player (id=player id) or at the screen of every player (id=0)!
The menu-content string defines the look and content of the menu. It's limited to 400 chars.
Scheme: "title,b1,b2,...,b9"
The menu-hook is executed when a player hits a menu button with the mouse or presses the corresponding numeric key.
Sample 1: A simple menu for player 1
Sample 2: A big menu for player 2
Sample 3: A menu with a button left out (creating space between button 1 and 2)
Sample 4: A menu with advanced button captions and a disabled button
Sample 5: An invisible menu (can be used to capture hits of numeric keys)
Sample 6: Processing menu actions using the menu-hook
The menu-content string defines the look and content of the menu. It's limited to 400 chars.
Scheme: "title,b1,b2,...,b9"
- title = title of the menu (Attach @b at the end of title for a bigger menu or @i for an invisible menu)
- b1-b9 = up to 9 button captions. Use empty strings for buttons you don't need. Captions can also be split into 2 parts by using "|" (scheme: "left caption|right caption"). Moreover you can put () around a caption to make a disabled button.
The menu-hook is executed when a player hits a menu button with the mouse or presses the corresponding numeric key.
Note: This command has just TWO (2) paramters! The first one is the player id and the second one a string which defines the contents of the menu!
Attention: The menu-content string is limited to a length of 400 chars!
Sample 1: A simple menu for player 1
menu(1,"Sample Menu With 3 Buttons,Button 1,Button 2,Button 3")
Sample 2: A big menu for player 2
menu(2,"Big Menu With 3 Buttons@b,Button 1,Button 2,Button 3")
Sample 3: A menu with a button left out (creating space between button 1 and 2)
menu(1,"Space,Button 1,,Button 2")
Sample 4: A menu with advanced button captions and a disabled button
menu(1,"Custom Buy Menu,Item 1|$5,Item 2|$50,(Item 3|$999999),Item 4|$0")
Sample 5: An invisible menu (can be used to capture hits of numeric keys)
menu(1,"Hidden@i,b1,b2,b3")
Sample 6: Processing menu actions using the menu-hook
addhook("menu","myMenu")
function myMenu(id,title,button)
msg("player "..player(id,"name").." has pressed button #"..button.." in the menu '"..title.."'!")
end
function myMenu(id,title,button)
msg("player "..player(id,"name").." has pressed button #"..button.." in the menu '"..title.."'!")
end