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

Difference between revisions of "remove"

From Quake Wiki

 
Line 1: Line 1:
====Syntax:====
+
''void'' '''remove'''(entity e)
<code>void remove(entity e)</code>
 
  
"Removes" an entity from the game.
+
== Usage ==
====Parameters:====
+
Deletes an entity from the game. This should be used with caution as it can cause entity pointers to become invalid as they're not cleared automatically. If you know an entity has a pointer to the one being removed, manually set the pointer to '''world''' as a safety measure.
:<code>e</code> - The entity to remove
 
====Returns:====
 
:void
 
  
 +
=== Parameters ===
 +
*''e''
 +
:The entity to remove.
 +
 +
== Example ==
 +
// This temporary entity removes itself after it does its task
 +
void SpawnTempEntity()
 +
{
 +
    entity temp = spawn();
 +
    temp.nextthink = time + 1;
 +
    temp.think = PerformTask;
 +
}
 +
 +
void PerformTask()
 +
{
 +
    // ...
 +
 +
    remove(self);
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:39, 31 July 2023

void remove(entity e)

Usage[edit]

Deletes an entity from the game. This should be used with caution as it can cause entity pointers to become invalid as they're not cleared automatically. If you know an entity has a pointer to the one being removed, manually set the pointer to world as a safety measure.

Parameters[edit]

  • e
The entity to remove.

Example[edit]

// This temporary entity removes itself after it does its task
void SpawnTempEntity()
{
    entity temp = spawn();
    temp.nextthink = time + 1;
    temp.think = PerformTask;
}

void PerformTask()
{
    // ...

   remove(self);
}