简体   繁体   English

SAMP PHP API集成

[英]SAMP PHP API Integration

ServerStats

I want to show the number of players in the server instead of that UNKNOWN thing, I haven't enabled the API yet, can I get help that, I want to integrate the progress bar to the total players in game like if players are 50/100 = 50% of the bar will be filled. 我想显示服务器中的玩家数量,而不是那未知的东西,我还没有启用API,能否获得帮助,我想将进度条集成到游戏中的玩家总数中(例如50岁) / 100 =条形的50%将被填充。 Like the bar should work as the api updates. 就像该栏应该随着api更新一样工作。

<div class="is-clearfix"></div> 
<section class="section dark-grey has-text-centered">
    <div class="container">
        <div class="heading">
            <h1 class="title">Our Servers</h1>
            <br>
        </div>
        <div class="columns is-gapless">
            <div class="column">
                <div class="card card-server">
                    <div class="card-image">
                        <figure class="image is-2by1">
                            <img src="./OutBreak Gaming_files/sfcnr_card1.png">
                        </figure></div> <div class="card-content">
                        <div class="title" style="font-size: 1.25em; color: rgb(119, 119, 119); margin-top: 0.5em;">87.98.241.207:7775</div> 
                        <div class="players is-marginless">
                            <div class="content playersOnline">
                                Unknown PLAYERS ONLINE
                            </div> 
                            <progress value="0" max="100" class="progress is-success"></progress>
                            <br></div> <a class="button is-info is-medium is-fullwidth">Play Now</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
</div>

Just use the SACNR monitor API, and 只需使用SACNR监视器API,然后

<div class="columns is-gapless">
<div class="column"><div class="card card-server">
<div class="card-image">
<figure class="image is-2by1">
<img src="./OutBreak Gaming_files/sfcnr_card1.png"></figure></div> 
<div class="card-content">
<div class="title" style="font-size: 1.25em; color: rgb(119, 119, 119); margin-top: 0.5em;">87.98.241.207:7775</div> Hostname:
<div class="hosting"></div>Gamemode:
<div class="game-mode"></div>Map:
<div class="language"></div> Players:
<div class="players is-marginless"><div class="content playersOnline">
    FETCHING PLAYERS ONLINE
  </div> 
<progress value="0" max="100" class="progress is-success"></progress><br></div> 
<a href="samp://87.98.241.207:7775"><a class="button is-info is-medium is-fullwidth">Play Now</a></a></div></div></div></div></div></section></div>

Where We fetch from API the following things 我们从API获取以下内容的地方

<?php
require_once("sampsvr.php");
$monitor = new SACNR\Monitor;
//$obj = $monitor->get_info_by_id(1790345);
$obj = $monitor->get_info_by_ip('87.98.241.207','7775');
$players = $obj->Players;
$hostName = $obj->Hostname;
$Gamemode = $obj->Gamemode;
$Mapname = $obj ->Language;
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

  $('.progress').val(<?php echo $players;?>);
  $('.playersOnline').html(<?php echo $players;?> +' PLAYERS ONLINE' );
  $('.hosting').html("<?php echo $hostName;?>");
  $('.game-mode').html("<?php echo $Gamemode;?>");
  $('.language').html("<?php echo $Mapname;?>");
});
</script>

You may find the API at http://monitor.sacnr.com/api.html 您可以在http://monitor.sacnr.com/api.html上找到该API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM