time_source_destroy

This function will destroy the given Time Source. You can optionally specify whether all child Time Sources under it should be deleted as well.

You cannot use this function to destroy the time_source_global and time_source_game Built-In Time Sources, however you can use this to delete all the child Time Sources under them, meaning the second argument destroy_tree must be true when passing a built-in Time Source.

 

Syntax:

time_source_destroy(id, [destroy_tree]);

ArgumentTypeDescription
idTime SourceThe Time Source to destroy
destroy_treeBooleanOPTIONAL Whether to destroy child Time Sources as well, is false by default

 

Returns:

N/A

 

Example:

// Create event
time_source = time_source_create(time_source_game, 1, time_source_units_seconds, my_method, [], -1);

// Clean Up event
time_source_destroy(time_source);

The Create event code creates a new Time Source that expires once per second and repeats indefinitely.

The Clean Up event code destroys that Time Source, as it will not be needed after the instance is destroyed.