TOP 10/Rango
#1
Holaa buenas tardes ando buscando un top10 que lleve algunos tipos de rango, Principiante, Oro, Plata, Diamante, Veterano, etc; alguien tendrá algún tipo de plugin o si alguien me puede hacer uno Obvio se le (pagara $) Proud
Responder
#2
tengo este desde ya hace tiempo.

https://prnt.sc/26xdiov

estilos
Código PHP:
@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@300;500;600&display=swap");

body 
{
    font-family"Rubik"sans-serif;
    text-aligncenter;
    background-color#240046;
    margin-left20px;
    margin-right20px;
    color#fff;
}

table {
    width100%;
    min-width400px;
    margin30px auto 0 auto;
}

  
th 
{
    bordernone;
    background-color#5a189a;
    /* color: white; */
    text-transformuppercase;
    padding10px;
}

tr,
td {
    bordernone;
    background-color#3c096c;
    color#fff;
    padding5px 20px;


archivo central
Código PHP:
<?php

use Traits\Sql\TopRangos;

require 
'./traits/sql/TopRangos.php';
    $sql = new TopRangos();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>TOP PLAYERS</title>

    <link rel="stylesheet" href="css/main.css">
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <h2 class="text-center text-white mb-4 mt-4">TOP PLAYERS</h2>
                <div class="table-responsive">
                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr class="success">
                                <th class="text-center">#</th>
                                <th>Avatar</th>
                                <th>Nick</th>
                                <th>Rango</th>
                                <th>Frags</th>
                                <th>Insignea</th>
                            </tr>
                        </thead>
                        <tbody id="player-table">
                            <?php $sql->__fnShowTopRangos( ); ?>
                        </tbody>
                        
                    
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 

TopRangos.php
Código PHP:
<?php

namespace Traits\Sql;

use 
Lib\db;
use 
Traits\Utils;

require_once 
'./lib/db.php';
require_once 
'./traits/Utils.php';

class 
TopRangos {
  use dbUtils;

  private $insigneas = array(
    "./assets/0.png",
    "./assets/1.png",
    "./assets/2.png",
    "./assets/3.png",
    "./assets/4.png",
    "./assets/5.png",
    "./assets/6.png",
    "./assets/7.png",
    "./assets/8.png",
    "./assets/9.png",
    "./assets/10.png",
    "./assets/11.png",
    "./assets/12.png",
    "./assets/13.png",
    "./assets/14.png",
    "./assets/15.png",
    "./assets/16.png",
    "./assets/17.png",
    "./assets/18.png"
  );

  private $rangos = array(
    "Unranked",
    "Silver I",
    "Silver II",
    "Silver III",
    "Silver IV",
    "Silver Elite",
    "Silver Elite Master"
    "Gold Nova I",
    "Gold Nova II",
    "Gold Nova III",
    "Gold Nova Master",
    "Master Guardian I",
    "Master Guardian II",
    "Master Guardian Elite",
    "Distinguished Master Guardian",
    "Legendary Eagle",
    "Legendary Eagle Master",
    "Supreme Master First Class",
    "The Global Elite"
  );
  /*
    CREATE TABLE csgo_table2 
    (
        id_cuenta INT PRIMARY KEY NOT NULL,
        rango int(2) NOT NULL DEFAULT '0',
        frags int(10) NOT NULL DEFAULT '0',
        hs int(10) NOT NULL DEFAULT '0',
        kills int(10) NOT NULL DEFAULT '0',
        deaths int(10) NOT NULL DEFAULT '0'
    );
  */
  public function __fnShowTopRangos( )
  {
      $num 1;
      $query $this->__fnConectar( )->prepare"SELECT * FROM zp_cuentas INNER JOIN csgo_table2 ON id = id_cuenta ORDER BY rango DESC, frags DESC LIMIT 15" );
      $query->execute( );

      while( $aRow $query->fetch( ) )
      {
        echo 
        '
          <tr>'
;
            if($num == 1)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-25230-1d5tage.png" alt="Girl in a jacket" width="30" height="30"></td>';
            else if($num == 2)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-32371-okxtro.png" alt="Girl in a jacket" width="30" height="30"></td>';
            else if($num == 3)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-10310-1y5kc6y.png" alt="Girl in a jacket" width="30" height="30"></td>'
            else 
              echo '<td class="text-center">'$num .'</td>';
        echo 
        '    
            <td><img src="'
$this->getImagen($aRow'steam_id' ]) .'" width="50px" height="50px"></td>
            <td>'
$aRow'Pj' ] .'</td>
            <td>'
$this->rangos[$aRow'rango' ]] .'</td>
            <td>'
$aRow'frags' ] .'</td>
            <td><img src="'
$this->insigneas[$aRow'rango' ]] .'"></td>
          </tr>
        '
;
        
        
++$num;
      }
  }


Utils.php
Código PHP:
<?php

namespace Traits;

trait 
Utils {
  protected $key 'your key';

  private function getImagen($steamid) {
    if ($steamid == 'STEAM_ID_LAN') {
      return 'https://i.imgur.com/fnWHQPW.png';
    }
    return $this->getSteamImg($steamid);
  }

  private function getSteamImg($steamid64) {
    $curl curl_init();

    $steamid64 $this->getSteam64($steamid64);
    
    curl_setopt_array
($curl, array(
      CURLOPT_URL => "https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$this->key}&steamids={$steamid64}&format=json",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'GET',
    ));

    $response curl_exec($curl);
    curl_close($curl);
    $json json_decode($responsefalse);
    $avatar $json->response->players[0]->avatarfull;

    return $avatar;
  }

  private function getSteam64($steamid) {

    $split explode(":"$steamid); // STEAM_?:?:??????? format

    $x substr($split[0], 61);
    $y $split[1];
    $z $split[2];

    $steamid64 $z;
    $steamid64 $steamid64 2;
    $steamid64 bcadd($steamid6461197960265728);

    if ($y == 1) {
      $steamid64 $steamid64 1;
    };
    $steamid64 "765$steamid64";

    return $steamid64;
  }



db.php
Código PHP:
<?php
namespace Lib;

use 
PDO;
use 
PDOException;

trait 
db
{
    private $host "";
    private $user "";
    private $password "";
    private $db "";
    private $charset "";

    private function __fnConectar( )
    {
        try
        {
            $conexion "mysql:host=" $this->host ";dbname=" $this->db ";charset=" $this->charset;
            $pdo = new PDO$conexion$this->user$this->password );
            return $pdo;
        }
        catch( PDOException $e )
        {
            echo 'err';
            print_r"Error en la conexión: " $e );
        }
    }
}

?>

Es similar al del url puesto arriba, nomas que no es ese xd, la unica dif es que este mostraba las chapitas del csgo

necesitas php y mysql
[Imagen: zcsztw-4.png] [Imagen: 6u5fj2-4.png]
[Imagen: linkedin_thumb_image.png][Imagen: 76561198283253977.png][Imagen: linkedin_thumb_image.png]
1
Responder
#3
(16/02/2022, 02:22 PM)MatiasGFaria escribió: Holaa buenas tardes ando buscando un top10 que lleve algunos tipos de rango, Principiante, Oro, Plata, Diamante, Veterano, etc; alguien tendrá algún tipo de plugin o si alguien me puede hacer uno Obvio se le (pagara $)  Proud

(16/02/2022, 11:00 PM)Hinami escribió: tengo este desde ya hace tiempo.

https://prnt.sc/26xdiov

estilos
Código PHP:
@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@300;500;600&display=swap");

body 
{
    font-family"Rubik"sans-serif;
    text-aligncenter;
    background-color#240046;
    margin-left20px;
    margin-right20px;
    color#fff;
}

table {
    width100%;
    min-width400px;
    margin30px auto 0 auto;
}

  
th 
{
    bordernone;
    background-color#5a189a;
    /* color: white; */
    text-transformuppercase;
    padding10px;
}

tr,
td {
    bordernone;
    background-color#3c096c;
    color#fff;
    padding5px 20px;


archivo central
Código PHP:
<?php

use Traits\Sql\TopRangos;

require 
'./traits/sql/TopRangos.php';
    $sql = new TopRangos();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>TOP PLAYERS</title>

    <link rel="stylesheet" href="css/main.css">
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <h2 class="text-center text-white mb-4 mt-4">TOP PLAYERS</h2>
                <div class="table-responsive">
                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr class="success">
                                <th class="text-center">#</th>
                                <th>Avatar</th>
                                <th>Nick</th>
                                <th>Rango</th>
                                <th>Frags</th>
                                <th>Insignea</th>
                            </tr>
                        </thead>
                        <tbody id="player-table">
                            <?php $sql->__fnShowTopRangos( ); ?>
                        </tbody>
                        
                    
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 

TopRangos.php
Código PHP:
<?php

namespace Traits\Sql;

use 
Lib\db;
use 
Traits\Utils;

require_once 
'./lib/db.php';
require_once 
'./traits/Utils.php';

class 
TopRangos {
  use dbUtils;

  private $insigneas = array(
    "./assets/0.png",
    "./assets/1.png",
    "./assets/2.png",
    "./assets/3.png",
    "./assets/4.png",
    "./assets/5.png",
    "./assets/6.png",
    "./assets/7.png",
    "./assets/8.png",
    "./assets/9.png",
    "./assets/10.png",
    "./assets/11.png",
    "./assets/12.png",
    "./assets/13.png",
    "./assets/14.png",
    "./assets/15.png",
    "./assets/16.png",
    "./assets/17.png",
    "./assets/18.png"
  );

  private $rangos = array(
    "Unranked",
    "Silver I",
    "Silver II",
    "Silver III",
    "Silver IV",
    "Silver Elite",
    "Silver Elite Master"
    "Gold Nova I",
    "Gold Nova II",
    "Gold Nova III",
    "Gold Nova Master",
    "Master Guardian I",
    "Master Guardian II",
    "Master Guardian Elite",
    "Distinguished Master Guardian",
    "Legendary Eagle",
    "Legendary Eagle Master",
    "Supreme Master First Class",
    "The Global Elite"
  );
  /*
    CREATE TABLE csgo_table2 
    (
        id_cuenta INT PRIMARY KEY NOT NULL,
        rango int(2) NOT NULL DEFAULT '0',
        frags int(10) NOT NULL DEFAULT '0',
        hs int(10) NOT NULL DEFAULT '0',
        kills int(10) NOT NULL DEFAULT '0',
        deaths int(10) NOT NULL DEFAULT '0'
    );
  */
  public function __fnShowTopRangos( )
  {
      $num 1;
      $query $this->__fnConectar( )->prepare"SELECT * FROM zp_cuentas INNER JOIN csgo_table2 ON id = id_cuenta ORDER BY rango DESC, frags DESC LIMIT 15" );
      $query->execute( );

      while( $aRow $query->fetch( ) )
      {
        echo 
        '
          <tr>'
;
            if($num == 1)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-25230-1d5tage.png" alt="Girl in a jacket" width="30" height="30"></td>';
            else if($num == 2)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-32371-okxtro.png" alt="Girl in a jacket" width="30" height="30"></td>';
            else if($num == 3)
              echo '<td class="text-center"><img src="./assets/image_processing20200511-10310-1y5kc6y.png" alt="Girl in a jacket" width="30" height="30"></td>'
            else 
              echo '<td class="text-center">'$num .'</td>';
        echo 
        '    
            <td><img src="'
$this->getImagen($aRow'steam_id' ]) .'" width="50px" height="50px"></td>
            <td>'
$aRow'Pj' ] .'</td>
            <td>'
$this->rangos[$aRow'rango' ]] .'</td>
            <td>'
$aRow'frags' ] .'</td>
            <td><img src="'
$this->insigneas[$aRow'rango' ]] .'"></td>
          </tr>
        '
;
        
        
++$num;
      }
  }


Utils.php
Código PHP:
<?php

namespace Traits;

trait 
Utils {
  protected $key 'your key';

  private function getImagen($steamid) {
    if ($steamid == 'STEAM_ID_LAN') {
      return 'https://i.imgur.com/fnWHQPW.png';
    }
    return $this->getSteamImg($steamid);
  }

  private function getSteamImg($steamid64) {
    $curl curl_init();

    $steamid64 $this->getSteam64($steamid64);
    
    curl_setopt_array
($curl, array(
      CURLOPT_URL => "https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$this->key}&steamids={$steamid64}&format=json",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'GET',
    ));

    $response curl_exec($curl);
    curl_close($curl);
    $json json_decode($responsefalse);
    $avatar $json->response->players[0]->avatarfull;

    return $avatar;
  }

  private function getSteam64($steamid) {

    $split explode(":"$steamid); // STEAM_?:?:??????? format

    $x substr($split[0], 61);
    $y $split[1];
    $z $split[2];

    $steamid64 $z;
    $steamid64 $steamid64 2;
    $steamid64 bcadd($steamid6461197960265728);

    if ($y == 1) {
      $steamid64 $steamid64 1;
    };
    $steamid64 "765$steamid64";

    return $steamid64;
  }



db.php
Código PHP:
<?php
namespace Lib;

use 
PDO;
use 
PDOException;

trait 
db
{
    private $host "";
    private $user "";
    private $password "";
    private $db "";
    private $charset "";

    private function __fnConectar( )
    {
        try
        {
            $conexion "mysql:host=" $this->host ";dbname=" $this->db ";charset=" $this->charset;
            $pdo = new PDO$conexion$this->user$this->password );
            return $pdo;
        }
        catch( PDOException $e )
        {
            echo 'err';
            print_r"Error en la conexión: " $e );
        }
    }
}

?>

Es similar al del url puesto arriba, nomas que no es ese xd, la unica dif es que este mostraba las chapitas del csgo

necesitas php y mysql
Me sirve
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)