【发布时间】:2016-05-04 10:43:50
【问题描述】:
我有一个 csgo 投注网站,当至少 2 名玩家将他们的皮肤存入该网站时,游戏开始,机器人需要 2 分钟才能选出获胜者。
一切正常,游戏开始,游戏开始后 2 分钟选出获胜者,但本应显示剩余秒数的倒计时文本不起作用。
这是我的代码Time left: <h4 id="countdown-timer"><span id="timeleft">0</span></h4>
已接受 XXXXXXX (XXXXXXXXXXXXXX) 的交易报价 #1211760373 当前玩家:1 已接受 XXXXXXXXX (XXXXXXXXXXXXXXX) 的交易报价 #1211760308 当前玩家:2 找到 2 名玩家
这就是机器人所说的
这是timeleft.php http://prnt.sc/b03ute
PHP 代码
<?php
@include_once ("set.php");
$game = fetchinfo("value", "info", "name", "current_game");
$r = fetchinfo("starttime", "games", "id", $game);
$somebodywon = fetchinfo("winner", "games", "id", $game);
if ($r == 2147483647)
die("120");
$r += 120 - time();
if ($r < 0) {
$r = 0; /* if(empty($somebodywon)) include_once('getwinner34634f.php'); */
} echo $r;
?>
也找到了这个,叫做 ssetimeleft.php
<
?php
@include_once ("set.php");
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache'); // recommended to prevent caching of event data.
/**
* Constructs the SSE data format and flushes that data to the client.
*
* @param string $id Timestamp/id of this connection.
* @param string $msg Line of text that should be transmitted.
*/
function sendMsg($id, $msg) {
echo "id: $id" . PHP_EOL;
echo "data: $msg" . PHP_EOL;
echo PHP_EOL;
ob_flush();
flush();
}
while (1) {
$game = fetchinfo("value","info","name","current_game");
$r = fetchinfo("starttime","games","id",$game);
if($r == 2147483647){
$var=120;
}else{
$var = $r += 120-time();
if($r < 0)
{
$var = 0;
/*if(empty($somebodywon))
include_once('getwinner34634f.php');*/
}
}
sendMsg(time(),$var);
usleep(500000); //1000000 = 1 seconds
}
?>
【问题讨论】:
-
请提供更新时间显示文本的代码。 (可能是 javascript?)
-
请使用此代码更新您的问题,使其更具可读性。
-
我刚做了,你知道怎么帮我吗?