Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.