SHARE
TWEET

Untitled

a guest Jun 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. aveTimes(player, time)
  2. {
  3.     guid = player getGuid();
  4.     for(i=4; i>-1; i--)
  5.     {
  6.         //If players new time is slower then their old time
  7.         if(level.playerTimes[i]["guid"] == guid && level.playerTimes[i]["time"] < time )
  8.             return;
  9.  
  10.         //If a quicker time is set
  11.         if(level.playerTimes[i]["time"] > time)
  12.         {
  13.             //check player doesnt have old time
  14.             for(x=0; x<i+1; x++)
  15.             {
  16.                 if(level.playerTimes[x]["guid"] == guid && level.playerTimes[x]["time"] != time)
  17.                 {
  18.                     //If they do move all times below up to remove it
  19.                     for(z=x; z>0; z--)
  20.                     {
  21.                         level.playerTimes[z]["time"] = level.playerTimes[z-1]["time"];
  22.                         level.playerTimes[z]["name"] = level.playerTimes[z-1]["name"];
  23.                         level.playerTimes[z]["guid"] = level.playerTimes[z-1]["guid"];
  24.                     }
  25.                 }
  26.             }
  27.             //move old times down
  28.             for(p=0; p<i; p++)
  29.             {
  30.                 level.playerTimes[p]["time"] = level.playerTimes[p+1]["time"];
  31.                 level.playerTimes[p]["name"] = level.playerTimes[p+1]["name"];
  32.                 level.playerTimes[p]["guid"] = level.playerTimes[p+1]["guid"];
  33.             }
  34.             //insert new time
  35.             level.playerTimes[i]["time"] = time;
  36.             level.playerTimes[i]["name"] = player.name;
  37.             level.playerTimes[i]["guid"] = guid;
  38.  
  39.             saveToDvar();
  40.             return;
  41.         }
  42.     }
  43. }
RAW Paste Data
Top