static
In GML code, you can use static variables.
static counter = 0; // Only happens once
counter += 1; // Will keep increasing every time this code runs
These are localized to each GML file - you can't share them.
BUT.
For some reason, this is kind of unreliable.
If you try to set it to the value of a function, even if it's built-in, it will throw an error.
Here's a workaround for that:
static s = undefined; // Won't crash
if s == undefined
s = scr_whatever(); // Works, but it's ugly. It is what it is
This is a GMLive bug.