Jump to content

[PHP] MTA Server Query


TaTT_DoGG

Recommended Posts

  • 2 months later...

Sorry to bump this, but the script works perfectly fine. I'm posting this for people who want this thing to get to work but don't know how to.

This is a list of thing you'll need to remember when you're going to use this:

  • Copy paste the code from that gamemonitor thread
  • Put the code in a .php file with php tags around it
  • To actually get variables use the following:
    $data = mta_getServer("127.0.0.1","22003");
  • Now the type of information is probably not what you're used to, it's not a string nor an array, but it's a class.
  • Now this is the code you want: echo $data->players . "/" . $data->maxplayers;
  • Instead of players or maxplayers you can also use: gameshort (type of game (mta)), port, name (server name), map and public (0 = private, 1 = public).
  • There's also something called rules, this is an array with stuff like the name of the gamemode and the version, so to get the gamemode name out of "rules" use: $data->rules["game"];
    Note the quotes around game!

For a full overview of what the query returns use:

print_r($x);

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...