This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Tom Grobbe edited this page Sep 12, 2017
·
1 revision
- Webserver with PHP support
- jQuery (jQuery CDN example provided below)
- Some general knowledge about JavaScript/jQuery
To get started, download the zip file and extract the proxy.php, servermodule.js and jquery.ajax-cross-origin.min.js files to the root html folder on your webserver.
Inside the: <head>
tags of the html page where you want to use this API from, put the following lines:
<!-- Getting jQuery using jQuery CDN, change this if you prefer to use a local jQuery version. -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<!-- Getting the Cross Origin plugin -->
<script src="jquery.ajax-cross-origin.min.js" type="text/javascript"></script>
<!-- Getting the servermodule.js file, this contains all the functions you'll need to get the information about a server. -->
<script src="servermodule.js" type="text/javascript"></script>
Next insert the following script anywhere below the </head>
tag, make sure to replace the <yourServerIP> and <yourServerPort> parts with your own values.
<script>loadServerData("<yourServerIP>:<yourServerPort>");</script>
You're now ready to use the API.
<!DOCTYPE html>
<html>
<head>
<!-- Getting jQuery using jQuery CDN, change this if you prefer to use a local jQuery version. -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<!-- Getting the Cross Origin plugin -->
<script src="jquery.ajax-cross-origin.min.js" type="text/javascript"></script>
<!-- Getting the servermodule.js file, this contains all the functions you'll need to get the information about a server. -->
<script src="servermodule.js" type="text/javascript"></script>
</head>
<script>loadServerData("149.210.238.117:30120");</script>
<body>
<div id="server-hostname"></div>
<div id="server-version"></div>
</body>
<script>
document.getElementById('server-hostname').innerHTML = getServerHostname();
document.getElementById('server-version').innerHTML = getServerVersion();
</script>
</html>
The example above would look something like this:
- LoadServerData
- GetServerIcon
- GetServerHostname
- GetServerAddress
- GetResources
- GetResource
- GetResourceCount
- GetPlayers
- GetPlayer
- GetPlayerIdFromServerId
- GetPlayerServerId
- GetPlayerIP
- GetPlayerPing
- GetPlayerName
- GetPlayerIdentifiers
- GetPlayerIdentifierFromIndex
- GetPlayerCount
- GetMaxPlayerCount
- GetGameType
- GetMapName
- IsScriptHookEnalbed
- GetServerVersion