Jump to content

[HELP] PHP SDK.


iwalidza

Recommended Posts

Posted

iam try to get test string form Lua to php with php sdk thats my cods

Lua

function getAllPlayersForWebsite ( )
    local players = {}
    for k, player in ipairs( getElementsByType ("player") ) do
        local name = getPlayerName( player )
        table.insert( players, name )
    end
    return players
end

function getPlayersNumber ()
    return "test"
end

meta 

<meta>
	<script src="devS.Lua" type="server"/>
	<export function="getAllPlayersForWebsite" type="server" http="true" />
	<export function="getPlayersNumber" type="server" http="true" />
</meta>


php

<?php  
  
include "sdk/mta_sdk.php";
  
  
$MY_SERVER = [ 
    "host" => "localhost",  
    "http_port" => 22005, 
    "http_user" => "php",
    "http_pass" => "phpphp"
]; 
  
  
$SERVER = new mta ( $MY_SERVER['host'], $MY_SERVER['http_port'], $MY_SERVER['http_user'], $MY_SERVER['http_pass'] );



try {

    $RESOURCE = $SERVER->getResource ( "dev2" );

 $RESULT[] = $RESOURCE->call ( "getAllPlayersForWebsite" );

    foreach ( $RESULT [ 0 ] [ 0 ] as $index=>$playerName ) {
      print_r ( $playerName );
        echo "<br /><br />";
    }
 $RESULT[] = $RESOURCE->call ( "getPlayersNumber" );

    foreach ( $RESULT [ 0 ] [ 0 ] as $index=>$sting ) {
      print_r ( $sting );
        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 );
}

?>

result

print to me 

walidza

walidza

Posted
2 minutes ago, iwalidza said:

walidza

use latest version of php sdk firs't

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
Just now, iwalidza said:

idont know how to use ☹️

follow wiki explaining 

  • Like 1

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
19 minutes ago, iwalidza said:

see that img

 

try this

composer require php-http/curl-client guzzlehttp/psr7 php-http/message

in ur cmd

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
Just now, iwalidza said:

its done

see the img

https://prnt.sc/s3p0ko

now it's great just follow wiki now

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
1 minute ago, iwalidza said:

what i need to do now

https://prnt.sc/s3p1xl

ur php code

remove your require or include and add this

 

require "vendor/autoload.php";

or where is ur autoload.php file exist in 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
2 minutes ago, iwalidza said:

autoload.php file exist in

 

so how is it?

is there any wrong now?

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
2 minutes ago, iwalidza said:

you must run this command pro

composer require multitheftauto/mtasa-php-sdk

after running this command :

composer require php-http/curl-client guzzlehttp/psr7 php-http/message

 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted (edited)
Just now, iwalidza said:

cmd

at this position press shift +right click press on open power shell here or open cmd here

then run this command:

composer require multitheftauto/mtasa-php-sdk

 

Edited by Master_MTA

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted (edited)
3 minutes ago, iwalidza said:

display ur php code here not photo

and this notic is okay u should call this page from mta sa server

to return value for u

if u wanna call mta server instead u should see this example on wiki

<?php

require_once('vendor/autoload.php');

use MultiTheftAuto\Sdk\Mta;
use MultiTheftAuto\Sdk\Model\Server;
use MultiTheftAuto\Sdk\Model\Authentication;

$server = new Server('127.0.0.1', 22005);
$auth = new Authentication('myUser', 'myPassword');
$mta = new Mta($server, $auth);

$response = $mta->getResource('someResource')->call('callableFunction', $arg1, $arg2, $arg3, ...);
// or
$response = $mta->getResource('someResource')->call->callableFunction($arg1, $arg2, $arg3, ...);

var_dump($response);

 

Edited by Master_MTA
  • Thanks 1

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
5 minutes ago, Master_MTA said:

display ur php code here not photo

and this notic is okay u should call this page from mta sa server

to return value for u

if u wanna call mta server instead u should see this example on wiki


<?php

require_once('vendor/autoload.php');

use MultiTheftAuto\Sdk\Mta;
use MultiTheftAuto\Sdk\Model\Server;
use MultiTheftAuto\Sdk\Model\Authentication;

$server = new Server('127.0.0.1', 22005);
$auth = new Authentication('myUser', 'myPassword');
$mta = new Mta($server, $auth);

$response = $mta->getResource('someResource')->call('callableFunction', $arg1, $arg2, $arg3, ...);
// or
$response = $mta->getResource('someResource')->call->callableFunction($arg1, $arg2, $arg3, ...);

var_dump($response);

 

https://prnt.sc/s3panr

oh oh sorry 

Posted (edited)

  

1 minute ago, iwalidza said:
  •  
  •  
  • $response = $mta->getResource('someResource')->call('callableFunction', $arg1, $arg2, $arg3, ...);
  • // or
  • $response = $mta->getResource('someResource')->call->callableFunction($arg1, $arg2, $arg3, ...);

bro change this with your own details that mean u have syntax error cuze 

...);

+add username and password + your server ip and port

Edited by Master_MTA

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
$response = $mta->getResource('dev2')->call('getPlayersNumber', $arg1);
echo $response;
function getPlayersNumber ()
    return #getElementsByType('player')
end

like that?

2 minutes ago, Master_MTA said:

bro change this with your own details that mean u have syntax error cuze 

...);

 

 

Posted
1 minute ago, iwalidza said:
$response = $mta->getResource('dev2')->call('getPlayersNumber', $arg1);
echo $response;
function getPlayersNumber ()
    return #getElementsByType('player')
end

like that?

 

u should learn about php a little

<?php

require_once('vendor/autoload.php');

use MultiTheftAuto\Sdk\Mta;
use MultiTheftAuto\Sdk\Model\Server;
use MultiTheftAuto\Sdk\Model\Authentication;

$server = new Server('your ip', your port);
$auth = new Authentication('your username', 'your password');
$mta = new Mta($server, $auth);

$response = $mta->getResource('dev2')->call('getPlayersNumber');

var_dump($response);
// or you can do like this
  echo $response[0];

 

  • Thanks 1

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

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...