antiblock
diamwall
  • Chatbox

    You don't have permission to chat.
    Load More
  • 0
Sign in to follow this  
TMS SERVICES

Contador de Contas + jogadores online (web)

Question

Boas,

Preciso do script que conta todas as contas + contador de jogadores online, os scripts que tinha não são compatíveis...

Género do meu script:


 

$stmt = $db_player->prepare("SELECT name, level, mortes FROM player WHERE name NOT LIKE '[%]%' ORDER BY mortes DESC LIMIT 10");
$stmt->execute();
$ranking_pvp = $stmt->fetchAll(PDO::FETCH_ASSOC);

 

Obrigado desde já a quem me conseguir ajudar!

Share this post


Link to post
Share on other sites

8 answers to this question

  • 0
SELECT COUNT(*) as players_online FROM player.player WHERE DATE_SUB(NOW(), INTERVAL 10 MINUTE) < last_play;

 

O resto é contigo, fazes da maneira que quiseres.

Share this post


Link to post
Share on other sites
antiblock
Rodnia | Alpha & Omega
  • 0
3 minutos atrás, Cσяvσ⋆ disse:

SELECT COUNT(*) as players_online FROM player.player WHERE DATE_SUB(NOW(), INTERVAL 10 MINUTE) < last_play;

 

O resto é contigo, fazes da maneira que quiseres.


Boas,
Dá erro: ARRAY%
 

Share this post


Link to post
Share on other sites
  • 0
3 minutos atrás, relax2 disse:


Boas,
Dá erro: ARRAY%
 

 

???????????

Share this post


Link to post
Share on other sites
  • 0

 // Jogadores Online
$stmt = $db_player->prepare("SELECT COUNT(*) as count FROM player.player WHERE DATE_SUB(NOW(), INTERVAL 10 MINUTE) < last_play;");
$stmt->execute();
$jogadores_online = $stmt->fetchAll(PDO::FETCH_ASSOC);

Share this post


Link to post
Share on other sites
  • 0
15 minutos atrás, relax2 disse:

sFHNcab.jpg

 

lmao, tens algum problema na função de correr a query, não te consigo ajudar porque nunca a executei dessa maneira.

Share this post


Link to post
Share on other sites
  • 0

"SELECT count(*) FROM player WHERE DATE_SUB(NOW(), INTERVAL 15 MINUTE) < last_play"

 

E.G:

    public function runQueryPlayer($sql)
    {
        $stmt = $this->player->prepare($sql);
        return $stmt;
    }
	function countOnlinePlayers_minute($m)
	{
		global $database;
		
		$stmt = $database->runQueryPlayer("SELECT count(*) FROM player WHERE DATE_SUB(NOW(), INTERVAL ? MINUTE) < last_play");
		$stmt->bindParam(1, $m, PDO::PARAM_INT);
		$stmt->execute(); 
		$count = $stmt->fetchColumn(); 

		return $count;
	}
          countOnlinePlayers_minute(15);

 

Edited by StormHunter (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this