Hi!
I was wondering if anybody knows how to implement/code something like this into a Xenforo forum.
Thanks!
~ Stress
I was wondering if anybody knows how to implement/code something like this into a Xenforo forum.
Thanks!
~ Stress
Thank you for your quick reply, I was wondering if you could show some screenshots or something, as I am fairly new to this.Yep, that's pretty simple. Just use MCAPI. It gives you a JSON response back with the data. All you have to do is output it.
Thanks so much!<script>
var playerCount = document.getElementById("playersOnline")
var playerCountRequest = new XMLHttpRequest();
playerCountRequest.open("GET", "https://mcapi.ca/v2/query/players/?ip=skyblock-mc.net", true);
playerCountRequest.onreadystatechange = function() {
if (playerCountRequest.readyState === 4 && playerCountRequest.status === 200) {
var playerCountReply = JSON.parse(playerCountRequest.responseText)
playerCount.innerHTML = playerCountReply.players.online
}
}
playerCountRequest.send(null)
</script>
and call it in with a span:
<h1>There are <span id="playersOnline"></span> online!</h1>
Hi there,<script>
var playerCount = document.getElementById("playersOnline")
var playerCountRequest = new XMLHttpRequest();
playerCountRequest.open("GET", "https://mcapi.ca/v2/query/players/?ip=skyblock-mc.net", true);
playerCountRequest.onreadystatechange = function() {
if (playerCountRequest.readyState === 4 && playerCountRequest.status === 200) {
var playerCountReply = JSON.parse(playerCountRequest.responseText)
playerCount.innerHTML = playerCountReply.players.online
}
}
playerCountRequest.send(null)
</script>
and call it in with a span:
<h1>There are <span id="playersOnline"></span> online!</h1>
Hi there,<head>
<script>
Put in here
</script
</head>
Actually you should put it before the body closing tag. That way all the DOM content has loaded and you wont be accessing unbuilt DOM content on slow connections.You have to have it wherever you coded the header at.
I may have someone do this for us, as I am still VERY confused. As said above, we're very inexperienced with this kind of thing, so yes. Thanks for all of your help.You have to have it wherever you coded the header at.
Add to the footer if you can. That way it will work for users with slow connections.I may have someone do this for us, as I am still VERY confused. As said above, we're very inexperienced with this kind of thing, so yes. Thanks for all of your help.
Also, by "header" do you mean Admin Home > Styles > Website_theme > Header and Navigation > ?
Awesome! Would the code go under this line of code?Add to the footer if you can. That way it will work for users with slow connections.
No that's CSS. I'm not sure how XenForo works but you need to add it before the </body> tagAwesome! Would the code go under this line of code?
Alright, great. I believe that we've decided to post a thread and try to find someone to do this for us. Since we're focusing on different things, getting this off of our backs would be a lot better.No that's CSS. I'm not sure how XenForo works but you need to add it before the </body> tag
I'd be happy to it for you.
