samp.directory
← Scripts y librerías

BN-M/Api

Api for your SAMP server - BETA 1.3

Otro★ 1actualizado jul 2023Sin licencia
Abrir en GitHub

Este repositorio no tiene archivo de licencia. Se puede leer, pero eso por sí solo no da permiso para reutilizarlo.

README.md

Introduction

Dependencies

  • None

Installation

  1. Place the API.amx file in your filterscripts folder.
  2. Add on server startup in server.cfg

2.1 filterscripts API

  1. Done

Getting started


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;
}
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
POST /HTTP/1.1
Host: api/Gateway/index.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 29

token=mytoken&funcname=myfunc
Content-Length: 41

token=mytoken&funcname=myfunc&params=[20]
Content-Length: 92

token=mytoken&data=Lorem Ipsum is simply dummy text of the printing and typesetting industry

forward OnApiReceiveRemoteData(const data[], data_size);
public OnApiReceiveRemoteData(const data[], data_size)
{
	printf("OnApiReceiveRemoteData | %s - %d", data, data_size);

	return 1;
}

Error Codes

1..6 - WHILE RECEIVING PACKET / WHILE GENERATING TOKEN (API request error)

200 - token (INVALID / EXPIRED TOKEN)
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

apiremote-controlsa-mpsa-mp-serversampsanandreasmultiplayer

Esta página se genera con lo que GitHub publica sobre el repositorio. samp.directory no aloja el código. Informar de un problema con esta ficha