Advertisement
garfield

[PHP]: Engine para Ranking SA-MP..

Oct 19th, 2012
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2.     //  Defina aqui aonde fica as contsa do servidor;
  3.     $PlayerDir   =  "./scriptfiles/ServerData/Players/";
  4.    
  5.     // A função Opendir abre o diretório que você configurou acima;
  6.     $Diretorio   =  opendir($PlayerDir);
  7.    
  8.     // Criamos uma array para aramazenar a pontuação e o nome de cada player;
  9.     $Player      = Array();
  10.    
  11.    
  12.     // Procurando por todos os arquivos da pasta que você definiu ($PlayerDir).
  13.     while(false != ($Arquivo = readdir($Diretorio))){
  14.    
  15.         // Verificar se o arquivo tem a extensão .ini
  16.         if(strstr($Arquivo, ".ini")){
  17.        
  18.             // Armazenamos o arquivo encontrado na variável $getLinha
  19.             $getLinha = parse_ini_file($PlayerDir.$Arquivo);
  20.            
  21.            
  22.             // Armazena o nome do player em uma array com o score pegado da
  23.             // Variável acima($getLinha)
  24.             // Usamos substr para remover o ".ini" do nome.
  25.             $Player[substr($Arquivo, 0, -4)] = $getLinha["Level"];
  26.         }
  27.     }
  28.    
  29.    
  30.     // Classificamos as pontuações  usando uma função
  31.     // nativa que classifica arrays.
  32.     arsort($Player);
  33.    
  34.    
  35.     // Criamos a variável $Players para contar quantos players tem
  36.     $Players    = count($Player);
  37.    
  38.     // Fazemos um interador para
  39.     $Interador  = 0;
  40.    
  41.     // Criamos uma string com uma tabela simples
  42.     $Exibir     = "<table border='1%' cellspacing='1' style='border-collapse: collapse;'>";
  43.    
  44.     // Adicionamos há string uma identificação ("Nome","Pontuação").
  45.     $Exibir    .= "<tr><td><b>Nome</b></td><td><b>Pontuação</b></td></tr>";
  46.    
  47.     // Fazemos um loop pela quantidade de players achados na pasta
  48.     while($Players != $Interador){
  49.    
  50.         // Adicionamos uma linha na string $Exibir.
  51.         $Exibir .= "<tr><td>Player: ".Key($Player)."</td><td>Score: ". $Player[Key($Player)]."</td></tr><br />";
  52.        
  53.         // Partimos para nosso próximo parâmetro na array $Player
  54.         next($Player);
  55.        
  56.         // Incrementamos o interador;
  57.         $Interador ++;
  58.     }
  59.    
  60.     // Exibimos
  61.     echo "</table>".$Exibir;
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement