=FAS=Shigawire Posted October 11, 2008 Share Posted October 11, 2008 Hello Guys, I'm looking for a working MTA server query for a very long time. I didnt find any. Isn't there a basic script that shows IP, Players, Map? Like the one on gamemonitor, but i don't wanna use that, coz it's branded. Don't rape me if there is an existing one, i used search, google, etc. In the Development wiki are several http functions, i guess, they are necessary for querying a server. Problem is: Lua is my first and only scripting language Ah, and btw. If this is the wrong forum: Kill me, delete my posts and do whatever you want with my corpse. Or i will never learn to post in the right one Link to comment
Gamesnert Posted October 11, 2008 Share Posted October 11, 2008 Ehm... If you want it to be on your own website, you could use MySQL. There is a MTA/SA:MP querier for XFire... (game-monitor! ) For the rest: dunno... Btw, shouldn't this fit better in DM Server-side? Link to comment
Ace_Gambit Posted October 11, 2008 Share Posted October 11, 2008 It really isn't that hard. All you have to do is tell MTA the exported server function is accepting HTTP requests and use any language of your taste that supports HTTP requests. AJAX for example has the XMLHttpRequest object but you can also use sockets in C++. I know MTA DM has HTTP interface classes that you can use (PHP and AJAX). Just search the wiki or look at this very basic example. HTTPExample.lua function getServerPortEx() return getServerPort() end meta.xml <meta> <export function="getServerPortEx" http="true" /> </meta> HTTPExample.js var xhr = false; try { xhr = new XMLHttpRequest(); } catch (e) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Foo"); } } } xhr.onreadystatechange = function () { if (xhr.readyState == 4) { try { alert("Server Port: " + xhr.responseText); } catch (err) { } } } function getServerPort() { xhr.open("POST", "http://localhost:[port]/[resource]/call/getServerPortEx", true, "user", "pass"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(null); } index.html <html> <head> <script src="./HTTPExample.js" type="text/javascript"></script> </head> <body> <button onclick="getServerPort(); return false;">Get Server Port</button> </body> </html> Link to comment
eAi Posted October 11, 2008 Share Posted October 11, 2008 You can actually directly export MTA internal functions, you don't even need to add any code to your resource. Purely a meta that exports getServerPort to http would be enough. http://development.mtasa.com/index.php?title=PHP_SDK provides some code that will make this pretty much painless, if you know basic PHP. Link to comment
Ace_Gambit Posted October 11, 2008 Share Posted October 11, 2008 That was just a basic example. You should indeed use inline code for MTA functions. I was just trying to show how you could call functions when the website is not located in the resource root. In the end that is exactly what the PHP SDK is doing. Using HTTP requests to call functions. Link to comment
eAi Posted October 11, 2008 Share Posted October 11, 2008 Don't sound so defensive! It's a perfectly good example, I was just making sure he didn't waste time reinventing the wheel when there's code out there already. Link to comment
Brophy Posted October 11, 2008 Share Posted October 11, 2008 PHPSDK is awesome, I use it for http://www.vces.net/cms/stats.php tho you might need to contact your website host (as in our case) incase it doesnt work, as some block none standard ports Link to comment
=FAS=Shigawire Posted October 12, 2008 Author Share Posted October 12, 2008 OMG, thanks for trying to help You. Then i will try to use HTTP and the PHP Development Kit Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now