.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Post tutorial Report RSS Quake c - server and client controls

Quake c has built in functions to send server and client commands, stuffcmd and localcmd - Not a trivial task and needed for complex mods. This tutorial will help.

Posted by on - Advanced Server Side Coding

For reference: Cataboligne.org we will be looking at the section of the quake c manual at that link. You can make a local copy - I did a scroogle search and couldnt even find it. (There are other manuals, but that is my favorite.)

These are the two quake c instructions referenced:

stuffcmd (entity client, string text);

client = player that is to receive the command

text = text of the command, ended by \n (newline).

Send a command to a given player, as if it had been typed on the player's
console. Don't forget the \n (newline) at the end, otherwise your command
will not be executed, and will stand still on the console window.


localcmd (string text);

text = text of the command, ended by \n (newline).

Execute a command on the server, as if it had been typed on the server's console.

*** Important NOTE: these two pieces of code are not interchangeable!

The first - stuffcmd - is used to send console commands to a client connected to the server. There are any number of variables server code might want to change, however, the most frequent use is "bf\n" - flash the screen.

The second - localcmd - tends to be used for code controlled server admin type functions such as loading new maps, and changing control vars.

In both cases the engine interprets the text as if typed and a terminator <\n> char MUST be sent, or the command will languish in the console buffer.

This segment is something for the coder to keep in mind - I just ran into this during development. There is a .cfg file that gets executed based on in game action. And it wasnt working for the network client. I checked and sure enough, I had threw in localcmd when I wanted stuffcmd.

Post comment Comments
ArkaZeen
ArkaZeen - - 1,696 comments

thanks for the help! :)

Reply Good karma Bad karma+1 vote
numbersix Author
numbersix - - 2,244 comments

Your welcome. I literally just ran into this again.

Reply Good karma+1 vote
numbersix Author
numbersix - - 2,244 comments

Quake-c Manual ver 3.4 entry for commands:

8.8 Server managment

Function: stuffcmd

stuffcmd (entity client, string text)
client = player that is to receive the command
text = text of the command, ended by \n (newline).
Send a command to a given player, as if it had been typed on the player's console.
Don't forget the \n (newline) at the end, otherwise your command will not be executed, and will stand still on the console window.

8.10 Console

Function: localcmd

void localcmd (string text)
text = text of the command, ended by \n (newline).
Execute a command on the server, as if it had been typed on the server's console.
Examples:

localcmd("restart\n"); // restart the level
localcmd("teamplay 1\n"); // set deathmatch mode to teamplay
localcmd("killserver\n"); // poor server...

Reply Good karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: