Another thing i forgot to Point out is , you dont have to use while(1);
in your recording and playing functions loop , you dont have to save every tick .
Better for the performance would be 3 or more . Best for me and my slowly Computer is for example wait(3);

function demo_record()

{
if(demo_mode!=0){return;} // if we already recording or playing , end here
demo_mode=1;
counter=0;
start_timer();
filehandle=file_open_write("demo.DEM");
str_cpy(show_info.string,"Recording Demo !!");
while(demo_mode==1)
{
file_var_write(filehandle,player.pan);
file_asc_write(filehandle,13);
file_var_write(filehandle,player.x);
file_asc_write(filehandle,13);
file_var_write(filehandle,player.y);
file_asc_write(filehandle,13);
file_var_write(filehandle,player.z);
file_asc_write(filehandle,13);
file_var_write(filehandle,speed.x);
file_asc_write(filehandle,13);
file_var_write(filehandle,speed.y);
file_asc_write(filehandle,13);
file_var_write(filehandle,speed.z);
file_asc_write(filehandle,13);
counter+=1;
wait(1); // wait(3); for slower Computer play with 3
}
file_close(filehandle);
str_cpy(show_info.string,"Stoped Recording !!");
}




Dont forget to change Both functions , recording and for Playing

if you want the demo to play Faster as recorded so let it (1) in play function and maybe (2) or (3) while recording .

if you want the demo to play in slow motion so let i (3) in play function and maybe (1) or (2) while recording.