Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre, fiendish Vore and indestructible Schambler using lethal nails, fierce Thunderbolts and abominable Rocket and Grenade Launchers.

Post tutorial Report content RSS feed 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

thanks for the help! :)

Reply Good karma Bad karma+1 vote
numbersix Author
numbersix

Your welcome. I literally just ran into this again.

Reply Good karma+1 vote
numbersix Author
numbersix

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

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account:

Icon
Quake
Platforms
Windows, Mac, Linux, DOS, N64, DC
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Homepage
Idsoftware.com
Release date
Game watch
Start tracking
Tutorial
Browse
Tutorials
Share
Related Games
Quake
Quake First Person Shooter
Related Engines
DarkPlaces engine
DarkPlaces engine GPL
Quake Engine
Quake Engine GPL
Related Groups
Dark Places engine team
Dark Places engine team Developer with 15 members
id Software
id Software Developer & Publisher with 2 members
qc
qc Hardware & Tech with 31 members
QuakeDB
QuakeDB Fans & Clans with 154 members