[TUTORIAL] How to create a command - Xonotic QuakeC programming - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10) +--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12) +--- Thread: [TUTORIAL] How to create a command - Xonotic QuakeC programming (/showthread.php?tid=8318) |
How to create a command - Xonotic QuakeC programming - LegendGuard - 04-24-2020 Hi, all! This is my first tutorial created, it talks about how to create commands and this is the first time that I develop the code: How I started to write my first code, the used notepad is Code::Blocks, it can be opened in another notepad (I don't recommend using a notepad like Windows default notepad): IMPORTANT NOTE: as it's server side, keep in mind that only works for your own server and not for other servers(Internet). 1. Open a file called cmd.qc in xonotic/data/xonotic-data.pk3dir/qcsrc/server/command folder 2. Write the following in the line 281 (NOTE: This line is specific, if you see something not empty, don't do. The code may change in some time due to the development, so don't write inside the functions, write it outside the functions) Code: //LegendGuard first command code test 2020/04/22 during the coronavirus pandemic crisis 3. Write the following macro to call the command function in the line 860 more or less where says "Macro system for networked commands": Code: CLIENT_COMMAND("hello", ClientCommand_hello(ent, request), "Print a message of hello from qc lol") \ 4. Save cmd.qc file and go to console MSYS2 (as I use Windows) 5. In the console, write and execute ./all compile -qc -r 6. After, run the game with ./all run 7. Execute map any_mapname command in the game (NOTE: alternatively you can go in Multiplayer >> Create >> Select a map >> Start multiplayer! , you're creating a local server) 8. When the map is loaded in the game, run the following created command: cmd hello IMPORTANT NOTE: if you don't want to write cmd and you want to execute the hello command directly, then do this: go to and open xonotic/data/xonotic-data.pk3dir/commands.cfg, go to where says "cmd (client-to-server command) - server/command/cmd.qc" and qc_cmd_cmd things, inside of those aliases, write a new line inside those aliases: Code: alias hello "qc_cmd_cmd hello ${* ?}" // Prints a hello message in the console 9. And enjoy!! cmd hello hello RE: How to create a command - Xonotic QuakeC programming - BuddyFriendGuy - 05-27-2020 Thank you. Hopefully this will inspire more folks to join the force. RE: How to create a command - Xonotic QuakeC programming - LegendGuard - 07-25-2020 (05-27-2020, 03:55 AM)BuddyFriendGuy Wrote: Thank you. Hopefully this will inspire more folks to join the force. I didn't see this answer, but anyways thank you! RE: How to create a command - Xonotic QuakeC programming - LegendGuard - 07-25-2020 More tutorial for this!!! In this section, it will show you how to develop a Basic Calculator command: 1. Open a file called cmd.qc in xonotic/data/xonotic-data.pk3dir/qcsrc/server/command folder 2. Write the following in the line 103 (NOTE: This line is specific, if you see something not empty, don't do. The code may change in some time due to the development, so don't write inside the functions, write it outside the functions) Code: //LegendGuard calc command code, enjoy the calculator command! 3. Write the following macro to call the command function in the line 860 more or less where says "Macro system for networked commands": Code: CLIENT_COMMAND("calc", ClientCommand_calc(ent, request, arguments), "Basic Calculator") \ 4. Save the file cmd.qc 5. If you don't want to write cmd and you want to execute the calc command directly, then do this: go to and open xonotic/data/xonotic-data.pk3dir/commands.cfg, go to where says "cmd (client-to-server command) - server/command/cmd.qc" and qc_cmd_cmd things, inside of those aliases, write a new line inside those aliases: Code: alias calc "qc_cmd_cmd calc ${* ?}" // Basic Calculator in the console you can organize a bit your line to be like the other aliases, after save the commands.cfg 5. Go to console MSYS2 (as I use Windows), in the console, write and execute ./all compile -qc -r 6. After, run the game with ./all run 7. Execute map any_mapname command in the game (NOTE: alternatively you can go in Multiplayer >> Create >> Select a map >> Start multiplayer! , you're creating a local server) 8. When the map is loaded in the game, run the following created command, for example: cmd calc 5 + 5 9. Enjoy!!! calc Using pi (π) number Using tau (τ) number |