Jump to content
  • 0

Q>Convert PVP Ladder


Sallycantdance

Question


  • Group:  Members
  • Topic Count:  225
  • Topics Per Day:  0.14
  • Content Count:  798
  • Reputation:   12
  • Joined:  12/04/20
  • Last Seen:  

hello is there anyway to convert this pvp ladder display in website into mvp ladder too  thank you

 

Quote

            </div> <!-- ./castle-holders -->            

            
                    <?php     
                        // Get Top 10 PvP ladder
                        $sql =  "SELECT pvpladder.char_id AS player_charid, pvpladder.name AS player_name, pvpladder.kills AS player_kills, pvpladder.deaths AS player_deaths, char.class AS job_class, char.base_level AS baseLvl, char.job_level AS jobLvl, char.sex AS gender FROM {$athenaServer->charMapDatabase}.pvpladder ";
                        $sql .= "LEFT JOIN {$athenaServer->charMapDatabase}.char ON pvpladder.char_id = char.char_id ";
                        $sql .= "ORDER BY `kills` DESC LIMIT 10";
                        $sth = $server->connection->getStatement($sql);
                        $sth->execute();
                        $top10list = $sth->fetchAll();                                                    
                    ?>                                
                
                <div class="top10-rankings">
                    <h2 class="text-warning item-title" data-aos="fade-left" data-aos-delay="600">Server Rankings</h2>
                        <div class="table-responsive pvp-ladder">
                            <table cellpadding="5" cellspacing="0">
                                <tr data-aos="fade-left" data-aos-delay="900">
                                    <th width="20%" class="text-center">Rank</th>
                                    <th width="40%">Player Name</th>
                                    <th width="20%" class="text-center">Kills</th>
                                    <th width="20%" class="text-center">Deaths</th>
                                </tr>
                                <?php $i = 0; $delayAOS = 300; foreach($top10list as $top10): ?>
                                        <tr data-aos="fade-left" data-aos-delay="<?php echo $delayAOS; ?>">
                                            <td class="text-center"><?php echo $i + 1;?></td>
                                            <td><?php echo htmlspecialchars($top10->player_name);?></td>
                                            <td class="text-center"><?php echo htmlspecialchars($top10->player_kills);?></td>
                                            <td class="text-center"><?php echo htmlspecialchars($top10->player_deaths);?></td>
                                        </tr>
                                <?php $i++; $delayAOS += 300; ?>
                                <?php endforeach ?>
                            </table>
                        </div>
                </div>

        </div> <!-- ./castle-container -->    

Quote

heres the mvp_ladder

/*
CREATE TABLE `mvpladder` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `char_id` int(11) unsigned NOT NULL default '0',
    `mob_id` INT NOT NULL,
    `kills` INT DEFAULT 0,
      PRIMARY KEY (`id`),
    INDEX (`char_id`),
    INDEX (`mob_id`),
    INDEX (`kills`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
*/

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  996
  • Reputation:   47
  • Joined:  11/13/11
  • Last Seen:  

You should create a php file that will fetch data from your mvp ladder and display it in your FluxCP 

 

Example of it is the following:

 

create a file named "top_mvp.php"

<?php
if (!defined('FLUX_ROOT')) exit;

$title = "Top MVP Players";

// Fetching the top 3 players from the mvpladder table
$sql = "SELECT `char_id`, `name`, `mvp_points` FROM `mvpladder` ORDER BY `mvp_points` DESC LIMIT 3";

try {
    $sth = $server->connection->getStatement($sql);
    $sth->execute();
    $topPlayers = $sth->fetchAll();
} catch (PDOException $e) {
    Flux::message('Database Error: ' . $e->getMessage());
    $topPlayers = [];
}
?>

 

Add the following code to the corresponding .tpl file or create a new template if necessary. For example, create a file top_mvp.tpl in your theme folder.

<div class="content">
    <h1><?php echo htmlspecialchars($title); ?></h1>
    <?php if (!empty($topPlayers)): ?>
        <table>
            <thead>
                <tr>
                    <th>Rank</th>
                    <th>Character Name</th>
                    <th>MVP Points</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($topPlayers as $rank => $player): ?>
                    <tr>
                        <td><?php echo $rank + 1; ?></td>
                        <td><?php echo htmlspecialchars($player['name']); ?></td>
                        <td><?php echo (int)$player['mvp_points']; ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    <?php else: ?>
        <p>No data available at this time.</p>
    <?php endif; ?>
</div>

 

Save the PHP Script: Place the top_mvp.php file in your Flux Control Panel's pages directory.

Create the Template File: Save the top_mvp.tpl file in the corresponding theme directory for your Flux CP.

Access the Page: Navigate to yourfluxurl/index.php?module=top_mvp to view the top 3 MVP players.

 

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  225
  • Topics Per Day:  0.14
  • Content Count:  798
  • Reputation:   12
  • Joined:  12/04/20
  • Last Seen:  

5 hours ago, Diconfrost VaNz said:

You should create a php file that will fetch data from your mvp ladder and display it in your FluxCP 

 

Example of it is the following:

 

create a file named "top_mvp.php"

<?php
if (!defined('FLUX_ROOT')) exit;

$title = "Top MVP Players";

// Fetching the top 3 players from the mvpladder table
$sql = "SELECT `char_id`, `name`, `mvp_points` FROM `mvpladder` ORDER BY `mvp_points` DESC LIMIT 3";

try {
    $sth = $server->connection->getStatement($sql);
    $sth->execute();
    $topPlayers = $sth->fetchAll();
} catch (PDOException $e) {
    Flux::message('Database Error: ' . $e->getMessage());
    $topPlayers = [];
}
?>

 

Add the following code to the corresponding .tpl file or create a new template if necessary. For example, create a file top_mvp.tpl in your theme folder.

<div class="content">
    <h1><?php echo htmlspecialchars($title); ?></h1>
    <?php if (!empty($topPlayers)): ?>
        <table>
            <thead>
                <tr>
                    <th>Rank</th>
                    <th>Character Name</th>
                    <th>MVP Points</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($topPlayers as $rank => $player): ?>
                    <tr>
                        <td><?php echo $rank + 1; ?></td>
                        <td><?php echo htmlspecialchars($player['name']); ?></td>
                        <td><?php echo (int)$player['mvp_points']; ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    <?php else: ?>
        <p>No data available at this time.</p>
    <?php endif; ?>
</div>

 

Save the PHP Script: Place the top_mvp.php file in your Flux Control Panel's pages directory.

Create the Template File: Save the top_mvp.tpl file in the corresponding theme directory for your Flux CP.

Access the Page: Navigate to yourfluxurl/index.php?module=top_mvp to view the top 3 MVP players.

 

 

thanks bro! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...