04-24-2020, 12:25 PM
(This post was last modified: 03-27-2021, 05:36 PM by LegendGuard.)
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)
3. Write the following macro to call the command function in the line 860 more or less where says "Macro system for networked commands":
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:
you can organize a bit your line to be like the other aliases, after save the commands.cfg
9. And enjoy!!
cmd hello
hello
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
void ClientCommand_hello(entity caller, int request)
{
switch (request)
{
case CMD_REQUEST_COMMAND:
{
sprint(caller, "\nHELLO BUDDY IM TALKING TO YOU FROM QC.\n");
return; // never fall through to usage
}
default:
case CMD_REQUEST_USAGE:
{
sprint(caller, "\nUsage:^3 cmd hello\n");
sprint(caller, " Where 'hellomessage' is the string of text to say the hello text.\n");
return;
}
}
}
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