Thread: Scoreboard
View Single Post
  #1  
Old 11-15-2014, 07:30 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Scoreboard

So, I started working on a scoreboard script.

Here's what I have so far-
PHP Code:
const MAX_STATS 26;

function 
onCreated() {
  
this.registerStat("Rocks_Staff3""xAndrewx"4);
}

public function 
registerStat(temp.stattemp.pltemp.value) {
  if (
temp.stat != "Rocks_Staff3") return;
  
    
//Create place holders if no stats exist
  
if (this.("Stat_" temp.stat "_" 1) == null) {
    for (
temp.1temp.<= MAX_STATStemp.i++) {
      
this.("Stat_" temp.stat "_" temp.i) = {27 temp.i"(npc-server)""Place Holder""head19.png"};      
      
this.("Stat_PlayerCache_" temp.stat).add("(npc-server" temp.@")");
    }         
  }  
  
    
//Loop from lowest score to highest
  
for (temp.i=MAX_STATStemp.i>=1temp.i--) {
    
temp.data this.("Stat_" temp.stat "_" temp.i);

    
temp.score temp.data[0];
    
temp.owner temp.data[1];
    
      
//Not hit the lowest score- end the loop
    
if (temp.== MAX_STATS) {
      if (
temp.value <= temp.score) {
        break;
      }
    }
        
    if (
temp.value temp.score) {
        
//If it's the last entry, finally add it in!
      
if (temp.== MAX_STATS) continue;      
      
        
//Replace old stats with new score
      
this.("Stat_" temp.stat "_" @ (temp.1)) = temp.data;      
      
this.("Stat_PlayerCache_" temp.stat)[(temp.1)] = temp.owner;
            
        
//If they've beaten the high score
      
if (temp.== 1) {
        
this.("Stat_" temp.stat "_" temp.i) = {temp.valuetemp.plfindplayer(temp.pl).nickfindplayer(temp.pl).head};      
        
this.("Stat_PlayerCache_" temp.stat)[(temp.i)] = temp.pl;        
//        echo("-Beat High Score- Adding stat in at" SPC temp.i SPC "old-" @ temp.score @ ". new-" @ temp.value @ ".");      
      
}      
    } else {
        
//Replace the score where they should sit
      
this.("Stat_" temp.stat "_" @ (temp.1)) = {temp.valuetemp.plfindplayer(temp.pl).nickfindplayer(temp.pl).head};      
      
this.("Stat_PlayerCache_" temp.stat)[(temp.1)] = temp.pl;       
      break;
    }
  }

  
this.trigger("update""");

So, I'm wanting a system which only displays the player in the list once.

The only way to do this is another loop- but what do you guys think?? Can you think of an alternative & more robust method
__________________
Reply With Quote