Hello everyone this is my first post please take it easy on me.
here goes nothing.
I followed xxmadexx's tutorial https://forum.multitheftauto.com/topic/74834-introduction-to-the-php-sdk/
It works and my site show the users. but I was wondering how do I go about exporting more information such as score and other information stored on the server.
This is my server.lua file
function getAllPlayersForWebsite ( )
local players = {}
for k, player in ipairs( getElementsByType ("player") ) do
local name = getPlayerName( player )
table.insert( players, name )
end
return players
end
my meta xml
<meta>
<info author="xXMADEXx" type="script" version="1.0" name="MTA PHP" />
<!-- Include our awesome script -->
<script src="server.lua" />
<!-- Export our function -- Make sure to allow HTTP to access it -->
<export function="doPrint" type="server" http="true" />
<export function="getAllPlayersForWebsite" type="server" http="true" />
</meta>
and the php file
<?php
include "sdk/mta_sdk.php"; # Include the MTA PHP SDK - Give us the classes and methods that we'll need
$MY_SERVER = [
"host" => "54.153.65.51", #The host/IP of your MTA server
"http_port" => 22005, #The HTTP port for your MTA server (Default 22005)
"http_user" => "user", #The username that we created in the previous step
"http_pass" => "password" #The password for the username that we created
];
#Create a new mta object
$SERVER = new mta ( $MY_SERVER['host'], $MY_SERVER['http_port'], $MY_SERVER['http_user'], $MY_SERVER['http_pass'] );
try {
$RESOURCE = $SERVER->getResource ( "mta_php" ); # We need to get our resource Object
$RESULT[] = $RESOURCE->call ( "getAllPlayersForWebsite" );
foreach ( $RESULT [ 0 ] [ 0 ] as $index=>$playerName ) {
print_r ( $playerName );
echo "<br /><br />";
}
#Catch any errors that occurred
} catch ( Exception $e ){
#Output error message
echo "<strong>Oops, Something went wrong!</strong><br />Error: {$e->getMessage()}<br /><br />e printout:<br />";
#Print the error table
print_r ( $e );
}
?>
Where should I start?