Thread: Scoreboard
View Single Post
  #7  
Old 11-16-2014, 03:52 AM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Quote:
Originally Posted by xAndrewx View Post
sure

don't store more than 25 scores in the DB though


Try this.
PHP Code:
/* Scoreboard system */

function onCreated() {
  
this.numEntrys 25;
  
clearBoard();

  
addScore("BlueMelon",9001);
  
addScore("snk",69);
  
addScore("BigMonster",1337);
  
addScore("supaman771",7331);

  
displayBoard();
}

function 
displayBoard() {
  for(
temp.i=0temp.i<this.board.size(); temp.i++) {
    echo(
temp.i+1 SPC this.board[temp.iSPC this.board[temp.i].score);
  }
}

function 
clearBoard() {
  
this.board = {};
  for(
temp.i=0temp.i<this.numEntrystemp.i++){
    
this.addScore("(npc server)"0);
  }
}

public function 
addScore(temp.acctemp.score) {
  
this.board.sortByValue("score""float"false);

  
temp.lowest this.board[this.board.size() -1];

  if(
this.board.size() < this.numEntrys){
    
this.board.add(temp.acc);
    
this.board[this.board.size() -1].score temp.score;
  }else if(
temp.score temp.lowest.score && temp.score 0) {
    
this.board.delete(this.board.size() -1);
    
this.board.add(temp.acc);
    
this.board[this.board.size() -1].score temp.score;
  }

  
this.board.sortByValue("score""float"false);

__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote