{SOLVED}[WEB] php/html CraftAPI server status script HOW TO ?

Discussion in 'Spigot Help' started by Deepz0neTRinPC, Jun 23, 2015.

  1. THANKS TO @SeiRruf FOR HELPING ME! HE SOLVED ALL OF THEESE!
    Im using craftapi.com. This site sending Server Status Json Like This:

    [​IMG]

    İ can Use "server", "status" , "motd" , "version" or "latency".(Alone Elements)
    But i cant use "online" or "max":

    [​IMG]
    İf i Write;
    [​IMG]
    its saying to me;
    [​IMG]
    ma +data.max : ma is my random text, and +data.max is undefined...

    Help me: How can i use it ?
     
    #1 Deepz0neTRinPC, Jun 23, 2015
    Last edited: Jun 23, 2015
  2. I see that "online" and "max" are nested in an array, within the array.

    Instead of "data.players+online" (which I see you are using now)
    Try instead: data.players.online and data.players.max

    Working example: http://jsfiddle.net/zhbxrncp/1/
     
    #2 SeiRruf, Jun 23, 2015
    Last edited: Jun 23, 2015
    • Agree Agree x 1
  3. @SeiRruf
    How can i find u dude?
    Because i wanna hug you!!
     
    • Like Like x 1
    • Friendly Friendly x 1
  4. Your appreciation is all I need. :)
     
  5. @SeiRruf
    Thank you so much!
    You'r the best! REALLY!

    [​IMG]
    Can i do that like: (e.g.) Online Players: 5/50
     
  6. Yes, that code structure should work fine, if you add the forggoten '+' between ".online" and "/" :)
    What you have would output "5/10" exclusively (where 5 and 10 would be your servers numbers).
    Also, what ever element it would populate, would need to have the id 'online'.

    Code (Text):

    document.getElementById('online').textContent = "Online Players: " + data.players.online + "/" + data.players.max;
     
     
    • Optimistic Optimistic x 1
  7. @SeiRruf
    Theese all text are Black, how to be colored theese?
    [​IMG]

    or here:
    [​IMG]

    (its old pics but %80 its same)
     
  8. Use '.innerHTML=" instead of '.textContent=' and then style them with css/html.

    Example:
    Code (Text):

    document.getElementById('online').innerHTML = '<span style="color:#F00">Online Players: ' + data.players.online + '/' + data.players.max + '</span>';
     
    It would output something like: Online Players: 5/10

    OR (more preferably) style your elements which contain the ID. So say you had <span id="online" style="color:#F00"></span>
    Then anything you put in there with your existing javascript (.textContent) would be the color of the container it is in.