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

Difference between revisions of "stuffcmd"

From Quake Wiki

(Created page with "====Syntax:==== <code>void stuffcmd(entity client, string s)</code> Sends text to the console as if it had been typed by the '''client''' entity. For use with player entitie...")
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
====Syntax:====
+
''void'' '''stuffcmd'''(''entity'' player, ''string'' cmd)
<code>void stuffcmd(entity client, string s)</code>
 
  
Sends text to the console as if it had been typed by the '''client''' entity.  For use with player entities only.
+
== Usage ==
====Parameters:====
+
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.
:<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 ===
 +
*''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]]

Latest revision as of 15:34, 31 July 2023

void stuffcmd(entity player, string cmd)

Usage[edit]

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[edit]

  • player
The player to send the message to.
  • cmd
The message to run in the player's console e.g. a command.

Example[edit]

// Execute the item flash when a player picks up an item
if (other.flags & FL_CLIENT)
    stuffcmd(other, "bf\n");