Closed logistic94 closed 1 year ago
I don't rely see why e new table needs to be added to track the players online time.
Since player_stats already do it.
Column player_online_time
stores how long the player have been online in total and is updated when the player disconnects.
When a player connects to the server he is added to a list of online players that keep track of the online time. when the player disconnect then player_online_time
is updated with the x minutes online this session.
Well it would make sens add it to server save to,😅
Well it would make sens add it to server save to,😅
allredy
I don't rely see why e new table needs to be added to track the players online time. Since player_stats already do it. Column
player_online_time
stores how long the player have been online in total and is updated when the player disconnects.When a player connects to the server he is added to a list of online players that keep track of the online time. when the player disconnect then
player_online_time
is updated with the x minutes online this session.
I whant to create charts like this, if you say i allredy have all information for do this. Can you help me when you have time, with sql querry
Here are some examples on how to collect the data required to build charts. dbfiddle
Here are some examples on how to collect the data required to build charts. dbfiddle
wow its awesome, so cool thnx you, i have one question: I have wipe in friday every week can i give information from friday to friday with no date.
If you clear the table data on every wipe (friday) you could just remove the between statement and return all the data from the table.
But if you want to keep the data for a longer period etc one month you need to add between witch date & time you want to collect the data from. BETWEEEN '2022-08-23 00:00:00' AND '2022-08-30 20:59:59'
for all day or BETWEEEN '2022-08-23 20:00:00' AND '2022-08-30 20:00:00'
for specifik wipe times where server where restarted
I prefer to use 00:00:00 so instead for '2022-08-30 23:59:59'
i would use '2022-09-1 00:00:00'
You should also be able to change your charts options to just display the time even if a date and time are supplied.
Hello, I was a little busy, I got to the charts, but I have a problem, it turns out something like this The problem is that I don't understand how to interpret "connected" in 1 And then sum them up to show on the graph how many people there were in the current period. And by the way, here is my miracle code)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<title>Document</title>
</head>
<body>
<?php
$con = new mysqli('ip','user','password','namedatabase');
$query = $con->query("
SELECT * FROM `player_connect_log` ORDER BY `time` DESC
");
foreach($query as $data)
{
$time[] = $data['time'];
$state[] = $data['state'];
}
?>
<div style="width: 500px;">
<canvas id="myChart"></canvas>
</div>
<script>
const labels = <?php echo json_encode($time) ?>;
const data = {
labels: labels,
datasets: [{
label: 'Online',
data: <?php echo json_encode($state) ?>,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(255, 159, 64, 0.2)',
'rgba(255, 205, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(201, 203, 207, 0.2)'
],
borderColor: [
'rgb(255, 99, 132)',
'rgb(255, 159, 64)',
'rgb(255, 205, 86)',
'rgb(75, 192, 192)',
'rgb(54, 162, 235)',
'rgb(153, 102, 255)',
'rgb(201, 203, 207)'
],
borderWidth: 1
}]
};
const config = {
type: 'bar',
data: data,
options: {
scales: {
y: {
beginAtZero: true
}
}
},
};
var myChart = new Chart(
document.getElementById('myChart'),
config
);
</script>
</body>
</html>
No problem me to.
You almost got it right. Instead for $state[] = $data['state'];
you should get the amount of players online with a sql query.
I have edited your code take a look here.
https://gist.github.com/Limmek/4fcf37d715e0838f598f02af22aff106
The code tag did not work... so i posted it on gist.
Hello. Interested in this topic. I tried your code in operation, it does not work out on the graph when there are no players on the server. One player is always displayed.([1,1,1,1,2,6,8,12,13,11], tell me where to fix it?
What about the new functionality, the number of online players in a certain period of time, and which I wrote about. Or you didn't have time to do it? Thnx