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

Difference between revisions of "WriteByte"

From Quake Wiki

(Created page with "''void'' '''WriteByte'''(''float'' type, ''float'' cmd) == Usage == Writes an unsigned byte to the current network message. This is often used to denote that a server command...")
 
m (Usage)
Line 2: Line 2:
  
 
== Usage ==
 
== Usage ==
Writes an unsigned byte to the current network message. This is often used to denote that a server command has started.
+
Writes an unsigned byte to the current network message. This is often used to denote that a server command has started, but some server commands also expect a byte as an argument.
  
 
== Parameters ==
 
== Parameters ==

Revision as of 16:22, 1 August 2023

void WriteByte(float type, float cmd)

Usage

Writes an unsigned byte to the current network message. This is often used to denote that a server command has started, but some server commands also expect a byte as an argument.

Parameters

  • type
The type of network message to write to. Can be one of the following:
  • MSG_BROADCAST
Send a message to every client, not caring if they receive it. This is best used for things that have no affect on the gameplay state e.g. temp entities.
  • MSG_ONE
Send a message to a single client. The client it's sent to is stored in the msg_entity global. Guarantees the client receives it.
  • MSG_ALL
Similar to MSG_BROADCAST but it guarantees every client receives it.
  • cmd
The server command to run. Any of the internal svc_* constants will work, but the default exposed ones are:
  • SVC_TEMPENTITY
  • SVC_KILLEDMONSTER
  • SVC_FOUNDSECRET
  • SVC_INTERMISSION
  • SVC_FINALE
  • SVC_CDTRACK
  • SVC_SELLSCREEN

Example

// Whenever this trigger is activated, marks that a secret was found
void UseSecretTrigger()
{
    ++found_secrets;
    WriteByte(MSG_ALL, SVC_FOUNDSECRET);
    self.use = __NULL__;
}