1.0.2 • Published 10 months ago

mta-sdk v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

MTA SDK

Library created with the purpose of streamlining development, enabling developers to establish a direct connection with MTA:SA more efficiently.

Resources

  • Execute functions
  • Fetch data from servers or from a server.

API Documentation

Import SDK.

import SDK from "mta-sdk";

Retrieve all servers and their information.

const sdk = new SDK();
const result = await sdk.api.getAll();

Retrieve information for the ip server.

const sdk = new SDK();
const result = await sdk.api.getFromIP(ip);
ParameterTypeDescription
IPstringRequired. The IP of the server from which you want to retrieve the information.

Retrieve information for the specified server.

const sdk = new SDK();
const result = await sdk.api.getFromIPandPort(ip, port);
ParameterTypeDescription
IPstringRequired. The IP of the server from which you want to retrieve the information.
PORTstringRequired. The PORT connection in server from which.

Execute an HTTP function on the server.

Set up the SDK first to execute the function correctly.

const sdk = new SDK(IP, PORT, USERNAME, PASSWORD, PROTOCOL);
ParameterTypeDescription
IPstringRequired. The IP of the server from which you want to retrieve the information.
PORTstringRequired. The HTTP PORT connection in server from which.
USERNAMEstringRequired. Admin account username.
PASSWORDstringRequired. Admin account password.

After the proper setup, provide the parameters correctly to execute your function.

const sdk = new SDK(IP, PORT, USERNAME, PASSWORD, PROTOCOL);
const result = await sdk.mta.execute(resource, functionName, object);
ParameterTypeDescription
RESOURCEstringRequired. Name of the resource that contains the function to be executed.
functionNamestringRequired. Function name to be executed.
objectobjectRequired. object containing the information to be sent.

Start socket.

const sdk = new SDK();
sdk.socket.init(1337, "0.0.0.0", () => {
    console.log("Socket open in port 1337");
});
ParameterTypeDescription
portstringRequired. Port to open socket.
ipstringRequired. IP to open socket..
callbackfunctionRequired. Function to receive opening data

Here's a basic example with plain socket:

sdk.socket.on("connection", socket => {
    console.log("new client");

    socket.on("data", buffer => {
        const message = buffer.toString().trim();
        console.log(message);
    });

    socket.write("Hello from SDK-Socket");
});

Authors

License

MIT

1.0.2

10 months ago

1.0.1

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago