Closed noa1ms closed 1 year ago
I am interested too. I am not a pro like you guys and I am interested to learn some API things. I see that pugbr api is based on php, so we send a request to the api and he decideds what to do I think so? And on script side how should it look? (Forgive me I am a newbie) For example can we send api request to auto start a server?
https://github.com/SmileYzn/LogApi - I think with this project we can notify the API/Server that server is activated/deactivated for example.
If you guys can share a bit information I will be hapy. Also, noa, I think you must write your own API script based on something PHP, Nodejs, dunno.
LogApi is not fully done yet, but it can do some things for now. With PHP or some other thing that support json HTTP requests.
For example, the LogAPI PHP Class:
<?php
class LogAPI
{
/**
* On Receive Event
*/
function OnEvent()
{
// Parse request as json event
$request = json_decode(file_get_contents('php://input'), true);
// If event is not empty
if(!empty($request['Event']))
{
// Process paramemeters as array
$parameters = array_values($request);
// Return from function call
return $this->{$request['Event']}(...$parameters);
}
// Return
return null;
}
/**
* Called when a unknow function is received
*
* @param string $name Function name
* @param type $arguments Function argument list
*/
function __call($name, $arguments)
{
// No function found
}
/**
* On Server Activate Event
*
*
* @param string $Event Event Name
* @param string $EdictCount Entity Count in Server (Number of edict)
* @param string $ClientMax Number of maximum allowed clients in server
*/
function ServerActivate($Event, $EdictCount, $ClientMax)
{
// Return
return null;
}
/**
* On Server Deactivate Event
*
* @param string $Event Event Name
*/
function ServerDeactivate($Event)
{
// Return
return null;
}
/**
* On Server Alert Message
*
* @param string $Event Event Name
* @param string $Type Alert Mesasge Type (Always 5 at_logged)
* @param string $Message Log string
*/
function ServerAlertMessage($Event, $Type, $Message)
{
// Return
return null;
}
/**
* On Client Connect
*
* @param string $Event Event Name
* @param string $UserId User Index
* @param string $Name Client Name
* @param string $AuthId Client AuthId
* @param string $Address Client IP Address
*/
function ClientConnect($Event, $UserId, $Name, $AuthId, $Address)
{
// Return
return null;
}
/**
* On Client Put In Server
*
* @param string $Event Event Name
* @param string $UserId User Index
* @param string $Name Client Name
* @param string $AuthId Client AuthId
*/
function ClientPutInServer($Event, $UserId, $Name, $AuthId)
{
// Return
return null;
}
/**
* On Client Disconnect
*
* @param string $Event Event Name
* @param string $UserId User Index
* @param string $Name Client Name
* @param string $AuthId Client AuthId
*/
function ClientDisconnect($Event, $UserId, $Name, $AuthId)
{
// Return
return null;
}
/**
* On Client Killed
*
* @param string $Event Event Name
* @param string $UserId User Index
* @param string $Name Client Name
* @param string $AuthId Client AuthId
*/
function ClientKill($Event, $UserId, $Name, $AuthId)
{
// Return
return null;
}
/**
* On Client Information Changed
*
* @param string $Event Event Name
* @param string $UserId User Index
* @param string $Name Client Name
* @param string $AuthId Client AuthId
* @param string $InfoBuffer KeyInfoBuffer
*/
function ClientUserInfoChanged($Event, $UserId, $Name, $AuthId, $InfoBuffer)
{
// Return
return null;
}
}
On some index.php at webserver, just:
// Process Event
$eventResult = (new LogAPI)->OnEvent();
// Die with event result
die(json_encode($eventResult));
On LogAPI Class, for example: Kick HLTV and BOT auth id
function ClientConnect($Event, $UserId, $Name, $AuthId, $Address)
{
$result = [];
//
if(in_array($AuthId,['BOT','HLTV'])
{
$result["ServerExecute"] = "kick #{$UserId} HLTV or BOT's is not allowed!";
}
// Return
return $result;
}
This is the main idea with LogAPI, you can do what you want with server since the
$result["ServerExecute"] = "SOME SERVER COMMAND";
Will be executed on server side. Also i will not stuck on 'protocols' do do things in server. It will do what is needed to do!
And finally, it is only a simple example with ServerExecute return. In future that can do more things when needed.
Good evening! I wanted to clarify do you have a php script API CS