SAMP-PHP-API集成
我想显示服务器中的玩家数量,而不是未知的东西,我还没有启用API,我可以得到帮助吗,我想将进度条集成到游戏中的所有玩家中,就像 如果玩家是50/100 =将填充50%的钢筋。 就像这个条应该随着api的更新而工作一样SAMP-PHP-API集成,php,html,sa-mp,Php,Html,Sa Mp,我想显示服务器中的玩家数量,而不是未知的东西,我还没有启用API,我可以得到帮助吗,我想将进度条集成到游戏中的所有玩家中,就像 如果玩家是50/100 =将填充50%的钢筋。 就像这个条应该随着api的更新而工作一样 <div class="is-clearfix"></div> <section class="section dark-grey has-text-centered"> <div class="container">
<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>
我们的服务器
87.98.241.207:7775
未知玩家在线
现在玩
只需使用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>
87.98.241.207:7775主机名:
游戏模式:
地图:
玩家:
在线抓取玩家
我们从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>
$(文档).ready(函数(){
$('.progress').val();
$('.playersOnline').html(+'playersOnline');
$('.hosting').html(“”);
$('.game mode').html(“”);
$('.language').html(“”);
});
您可以在以下网址找到API: