Stats bar

CosmoPeak

PeakRP.com
May 15, 2016
271
268
You'd be better off using a websocket for live data. I believe on rage/flux/whatever, it sent an ajax request every 5 seconds to the server to get the health directly from the database (really not a great solution, but it'd work). Every 5 seconds is also not live, so it would only be useful to see your health when you're not doing anything, not when it's most important (eg. while fighting or healing for example). If you can't figure out websockets, I'd just not have stats bars at all.
 

Ghost

Legacy, it's all anyone leaves behind.
Jun 8, 2012
1,640
503
Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
    $('#Status').load("client #Status");
    }, 5000); // refresh every 5000 milliseconds / 5 Seconds, 1000 Miliseconds = 1 second
</script>

Put that in on your client add
id="Status"

where ever <div class="container" for the status bar is.

unsure if this works, used this for my /me page when I did Hotrooms so the rooms refreshed automatically without you having to refresh the whole page.
 
Nov 27, 2014
238
35
I've figured my error. I'm using a 'foreign' page to collect the data from a database, encode it into JSON and return it. But, when I try to parse it using jquery, it errors: JSON.parse: unexpected character at line 1 column 1 of the JSON data. I've tried stringifying the return value then parsing it, but it still doesn't work.
 

Users who are viewing this thread

Top