Difference between revisions of "CGame"

From Sven Co-op
Jump to navigation Jump to search
m
m
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
The HTML documentation can be found here.
 
The HTML documentation can be found here.
  
A single global instance exists:
+
A single global instance exists:<code>CGame g_Game;</code>
<nowiki>
+
== Methods ==
CGame g_Game;
 
</nowiki>
 
===== Methods =====
 
  
Precache methods
+
=== Precache methods ===
  
 
{| class="wikitable"  
 
{| class="wikitable"  
Line 18: Line 15:
 
|-
 
|-
 
| PrecacheModel
 
| PrecacheModel
| int PrecacheModel(const string& in szFileName)
+
|<code>int PrecacheModel(const string& in szFileName)
 
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 
|-
 
|-
 
| PrecacheModel
 
| PrecacheModel
| int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName)
+
|<code>int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName)
 
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 
|-
 
|-
 
| PrecacheOther
 
| PrecacheOther
| void PrecacheOther(const string& in szClassName)
+
|<code>void PrecacheOther(const string& in szClassName)
 
| This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
 
| This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
 
|-
 
|-
 
| PrecacheMonster
 
| PrecacheMonster
| void PrecacheMonster(const string& in szClassName, bool fAlly)
+
|<code>void PrecacheMonster(const string& in szClassName, bool fAlly)
 
| This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity. szClassName is the given entity's classname, fAlly is whether this is an ally or enemy monster.
 
| This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity. szClassName is the given entity's classname, fAlly is whether this is an ally or enemy monster.
 
|-
 
|-
 
| PrecacheGeneric
 
| PrecacheGeneric
| void PrecacheGeneric(const string& in szFileName)
+
|<code>void PrecacheGeneric(const string& in szFileName)
 
| Precaches a file for download to clients.
 
| Precaches a file for download to clients.
 
|}
 
|}
  
AlertMessage
+
=== AlertMessage ===
  <nowiki>
+
  <nowiki>bool AlertMessage(ALERT_TYPE aType, const string& in szFormat, ...)</nowiki>
bool AlertMessage(ALERT_TYPE aType, const string& in szFormat, ...)
 
</nowiki>
 
 
Outputs a message to the console. Uses SC printf formatting style. Supports a variable number of arguments.
 
Outputs a message to the console. Uses SC printf formatting style. Supports a variable number of arguments.
  
 
See the ALERT_TYPE enum.
 
See the ALERT_TYPE enum.
  
 
+
=== GetGameName ===
GetGameName
+
  <nowiki>string GetGameName() const</nowiki>
  <nowiki>
 
string GetGameName() const
 
 
Returns the game name.
 
Returns the game name.
  
GetGameVersionString
+
=== GetGameVersionString ===
  <nowiki>
+
  <nowiki>string GetGameVersionString() const</nowiki>
string GetGameVersionString() const
 
</nowiki>
 
 
Returns the game version as a string, e.g. "5.0".
 
Returns the game version as a string, e.g. "5.0".
  
GetGameVersion
+
=== GetGameVersion ===
  <nowiki>
+
  <nowiki>uint32 GetGameVersion() const</nowiki>
uint32 GetGameVersion() const
 
</nowiki>
 
 
Returns the game version as a number, e.g. 500: major version, minor version (3.0 becomes 300, 4.0b1 becomes 401, 4.06 becomes 406, 4.5 becomes 450, etc...)
 
Returns the game version as a number, e.g. 500: major version, minor version (3.0 becomes 300, 4.0b1 becomes 401, 4.06 becomes 406, 4.5 becomes 450, etc...)
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]

Latest revision as of 21:55, 13 March 2025

This class contains methods integral to the operation of the game. You will often use these.

The HTML documentation can be found here.

A single global instance exists:CGame g_Game;

1 Methods

1.1 Precache methods

Name Method Description
PrecacheModel int PrecacheModel(const string& in szFileName) Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
PrecacheModel int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName) Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
PrecacheOther void PrecacheOther(const string& in szClassName) This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
PrecacheMonster void PrecacheMonster(const string& in szClassName, bool fAlly) This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity. szClassName is the given entity's classname, fAlly is whether this is an ally or enemy monster.
PrecacheGeneric void PrecacheGeneric(const string& in szFileName) Precaches a file for download to clients.

1.2 AlertMessage

bool AlertMessage(ALERT_TYPE aType, const string& in szFormat, ...)

Outputs a message to the console. Uses SC printf formatting style. Supports a variable number of arguments.

See the ALERT_TYPE enum.

1.3 GetGameName

string GetGameName() const

Returns the game name.

1.4 GetGameVersionString

string GetGameVersionString() const

Returns the game version as a string, e.g. "5.0".

1.5 GetGameVersion

uint32 GetGameVersion() const

Returns the game version as a number, e.g. 500: major version, minor version (3.0 becomes 300, 4.0b1 becomes 401, 4.06 becomes 406, 4.5 becomes 450, etc...)