Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @description Insert description here
  2. ini_open(global.STATS_file)
  3.  
  4. //1 //Read stuff
  5.     stats_board = ds_grid_create(10,3)
  6.     var str = ini_read_string("Data","grid","")
  7.     ds_grid_read(stats_board,str)
  8.     title = ini_read_string("Title","value","Untitled")
  9.    
  10. //2 //Compare my score with the stats-score, starting from the top player
  11.     myplace = -1
  12.     for(var i = 0; i <10;i++)
  13.     {
  14.         if (global.STATS_points > stats_board[# i, 1]) //if my points are bigger...
  15.         {
  16.             myplace = i //...save that place number
  17.             //show_message("this needs to happen only once")
  18.             break;
  19.         }
  20.         else if (global.STATS_points == stats_board[# i, 1]) //else if points are same...
  21.         {
  22.             if (global.STATS_level >= stats_board[# i, 2]) //...check if we reached a better/equal level
  23.             {
  24.                 myplace = i
  25.                 break;
  26.             }
  27.         }      
  28.     }
  29. //3 //Now, lets overwrite stats if needed  
  30.     if myplace != -1 //if I am in the top 10
  31.     {
  32.         if (myplace < 9) //if I ain't last, check if we have to 'drop-down-one-place' some stats.
  33.         {
  34.             for(var i = 8; i>=myplace; i--) //drop each stat one place down, beggining from the semifinal stat (9th/10th)
  35.             {                               //we begin from the 9th place because the 10th place will surely get eliminated.
  36.                 var ii = i+1
  37.                 stats_board[# ii, 0] = stats_board[# i, 0] //transfer the name down (eg: from 9th place to 10th place, then from 8th to 9th, and so on)
  38.                 stats_board[# ii, 1] = stats_board[# i, 1] //transfer the score down
  39.                 stats_board[# ii, 2] = stats_board[# i, 2] //transfer the level down
  40.             }
  41.         }
  42.    
  43.     //4 //now transfer myself on the stats, using the variable that we made when comparing
  44.         stats_board[# myplace, 0] = global.user
  45.         stats_board[# myplace, 1] = global.STATS_points
  46.         stats_board[# myplace, 2] = global.STATS_level
  47.    
  48.     //5 //write the new stats board in the text file
  49.         var str = ds_grid_write(stats_board)
  50.         ini_write_string("Data","grid",str)
  51.     }
  52.    
  53.    
  54. ini_close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement