Dieses Repository hat keine Lizenzdatei. Es ist öffentlich lesbar, aber das allein gibt noch keine Erlaubnis, es weiterzuverwenden.
README.md
SAMP-API
Public Beta 1st Release - (May, Friday 26 2023)
ES: Nuestra API se encarga de comunicar tu servidor de SA-MP con tu entorno de desarrollo.
EN: Our API is in charge of communicating your SA-MP server with your development environment.
Explore the docs »
Releases ^
Announcements
- 14/07/23
- ES: Tras el lanzamiento de esta actualización, en la siguiente nos centraremos en el recibimiento de información directa al servidor (Sin pre-procesado predefinido) se estima su fecha para el 15/07/23 - 17/07/23.
- EN: After the launch of this update, in the next one we will focus on receiving information directly to the server (No preset pre-processing) its estimated at 07/15/23 - 07/17/23.
- 06/07/23
- ES: La primera actualización de la API se estima para la fecha 14/07/23, Añadiendo la posibilidad de llamar funciones publicas con 1 parametro.
- EN: The first update of the API is estimated at 07/14/23, adding the possibility of calling public functions with 1 parameter.
- 26/05/23
- ES: Se abre al público la v1.0, Estaremos al tanto de errores o inconvenientes respecto a la API y FS recuerden que estamos en BETA.
- EN: v1.0 is released, we will be aware of errors or inconveniences remember the API and FS still in BETA.
Introduction
What is it about
Currently our API develops communication functions (Environment -> Server).
Current Version (1.3 BETA)
Available functions
· RCON commands
· Call of remote functions (Public's - With 1 parameter)
. Receive remote data
Information (Requests)
ALL: Server & Client side
Path Method Params (* -> Optional) Supported data Mode neshy-rp.com/api/Gateway/ GET [string] => token GET Client Only neshy-rp.com/api/Gateway/ POST [string] => token - [string | 128] => data | [string] => funcname - [array] => params (*) POST - HEADERS ALL neshy-rp.com/api/Gateway/ PUT [string] => token - [int] => id - [string] => order POST - HEADERS ALL neshy-rp.com/api/Gateway/ DELETE [string] => token - [int] => id POST - HEADERS ALLDependencies
- None
Installation
- Place the
API.amxfile in your filterscripts folder. - Add on server startup in
server.cfg
2.1 filterscripts API
- Done
Getting started
Our API uses a token system to identify clients (Server side and client side), so don't share it with anyone
Function's
GetApiKey() - Generate a new token for use, it calls the public function -> OnApiGenerateToken(const token[]) Which receives as a parameter the generated token
CheckApiRequest(const token[]) - It is in charge of reviewing orders registered in the API with the token
Server side
new const API_KEY[20];
public OnGamemodeInit()
{
CallRemoteFunction("GetApiKey", ""); // Generate token
return 1;
}
forward OnApiGenerateToken(const token[]); // Receive token
public OnApiGenerateToken(const token[])
{
format(API_KEY, sizeof API_KEY, token);
SetTimer("ApiTimer", 5000, true); // Every 5 seconds check if there are pending orders
return 1;
}
forward ApiTimer();
public ApiTimer()
{
CallRemoteFunction("CheckApiRequest", "s", API_KEY);
return 1;
}
Client side (global - rcon)
POST /HTTP/1.1
Host: api/Gateway/index.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 40
token=mytoken&funcname=rcon password 123
In about 5 seconds on sa-mp server, the password will be set to 123 via RCON command
Note: The method doesn`t need the rcon password because is called natively from the sa-mp server (FS)
Client side (global - functions)
POST /HTTP/1.1
Host: api/Gateway/index.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 29
token=mytoken&funcname=myfunc
In about 5 seconds on sa-mp server, the public function (myfunc) should be called
1.2 Beta - Parameters
Content-Length: 41
token=mytoken&funcname=myfunc¶ms=[20]
In 5 seconds on sa-mp server, the public function (myfunc) should be called with the params (int:20)
Params note(s):
- The parameters needs to follow the function (myfunc in this case) order, otherwhise you can get and error or crash - myfunc(int, string .....).
- The parameters don`t need the format because the API (FS) automatically detect and format the function data tags (INT, STRING, FLOAT) based on parameters
1.3 Beta - Remote data
Content-Length: 92
token=mytoken&data=Lorem Ipsum is simply dummy text of the printing and typesetting industry
In 5 seconds on sa-mp server, the callback (OnApiReceiveRemoteData) should be called
(Server Side)
forward OnApiReceiveRemoteData(const data[], data_size);
public OnApiReceiveRemoteData(const data[], data_size)
{
printf("OnApiReceiveRemoteData | %s - %d", data, data_size);
return 1;
}
Error Codes
These codes allow reporting in case of errors
Server side
1..6 - WHILE RECEIVING PACKET / WHILE GENERATING TOKEN (API request error)
200 - token (INVALID / EXPIRED TOKEN)
Client side
200 - token (INVALID TOKEN)
200 - id (REQUEST ID NOT EXITS / ALREADY SEND TO SERVER)
200 - empty (REQUEST'S QUEUE IS EMPTY)
200 - params (API REQUEST FUNCTION PARAMETERS ERROR)
400 - bad request's (API REQUEST SYNTAX ERROR)
Contact & More
© BryanM - BryanM#0871 (Discord)
Any review will be welcome (Respect above all), I'm also new in github so any hazing forgive me hehe.
Thanks to neshy (Web Host)
All sections of this document have been created with a template (Credits to their creators)
apiremote-controlsa-mpsa-mp-serversampsanandreasmultiplayer
Diese Seite wird aus dem erstellt, was GitHub über das Repository veröffentlicht. samp.directory hostet den Code nicht. Ein Problem mit diesem Eintrag melden