Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Editing stuffcmd

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''stuffcmd'''(''entity'' player, ''string'' cmd)
+
====Syntax:====
 +
<code>void stuffcmd(entity client, string s)</code>
  
== Usage ==
+
Sends text to the console as if it had been typed by the '''client''' entity.  For use with player entities only.
Sends a message to the passed player's console. Useful for executing console commands such as the item flash on pick up. Messages should have the '''\n''' character at the end to ensure commands run properly and future messages will move to the next line.
+
====Parameters:====
 +
:<code>client</code> - The entity to send the console text from.
 +
:<code>s</code> - The text to place on the console.
 +
====Returns:====
 +
:void
 +
====Other Details:====
 +
Note that if you do not add a newline character (<code>\n</code>), the text will stay on the console until a newline character is entered. In the case of commands, the commands will not be executed.
  
=== Parameters ===
+
The command generates a reliable [[SVC_STUFFTEXT]] network message.
*''player''
 
:The player to send the message to.
 
*''cmd''
 
:The message to run in the player's console e.g. a command.
 
  
== Example ==
 
// Execute the item flash when a player picks up an item
 
if (other.flags & FL_CLIENT)
 
    stuffcmd(other, "bf\n");
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)