This function is what i use to stop all of my objects getting cluttered up.
Here is the core part:
object=1
while object exist(object)=1
object=object+1
endwhile
load object object$,object
object(id)=object
And here is an example, i will create gun no. 1
function make_gun(1,"models/colt45.x")
object=1
while object exist(object)=1
object=object+1
endwhile
load object static$,object
gun(id)=object
endfunction gun(id)
This id can then be used for any object function, so instead of OBJECT POSITION X(122233), you can use OBJECT POSITION X(GUN(1))
simple...