PHP SDK

From Multi Theft Auto: Wiki
Revision as of 19:27, 26 June 2007 by EAi (talk | contribs) (→‎Examples)
Jump to navigation Jump to search

You can access the MTA Web Interface from almost any programming language that can request web pages using HTTP POST and encode and decode JSON.

PHP can do this very easily! This SDK provides one function "callFunction" that will allow you to call any exported script functions on any server that you have access to.

The download below includes two example pages - one that shows a simple scoreboard, the other that shows the automatic handling of element and resource objects.

Examples

[php]
include ( "mta.php" );
$retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getThisResource" ); // $retn is an array containing the values the function returned
$resource = $retn[0]; // the first returned value is the resource
$retn = callFunction ( "bastage.student.utwente.nl:33004", "echobot", "getResourceName", $resource ); 
$resourceName = $retn[0]; // contains the name of the resource 'echobot'

Download