So, I've quickly created and tested out a filterscript which would perform something of this manner.
Код:
#include <a_samp>
#include <a_http>
new cmdstate = 1;
forward OnServerCommand(playerid, response_code, data[]);
forward ProcessCommand(playerid, response_code, data[]);
forward CheckHTTP ();
public OnFilterScriptInit ()
{
SetTimerEx("CheckHTTP", 1000, true, "i");
return 1;
}
public CheckHTTP ()
{
HTTP(0, HTTP_GET, "state.txt", "", "OnServerCommand");
}
public OnServerCommand(playerid, response_code, data[])
{
new string[1028];
if(response_code == 200)
{
format(string, sizeof(string), "%s", data);
if (strval(string) == cmdstate)
{
if (strval(string) == 1)
{
cmdstate = 0;
}
else
{
cmdstate = 1;
}
HTTP(0, HTTP_GET, "command.txt", "", "ProcessCommand");
}
}
else
{
//request failed
}
return 1;
}
public ProcessCommand(playerid, response_code, data[])
{
new string[1028];
if(response_code == 200)
{
format(string, sizeof(string), "%s", data);
new cmd[256];
format (cmd, sizeof(cmd), "ID %s has been muted!", string);
SendClientMessageToAll (-1, cmd);
//add mute command here//
}
else
{
//request failed
}
return 1;
}
So, the way it works is that through your PHP file; you will make amendments to two files called state.txt and command.txt, state.txt informs the SA:MP server that you are processing a new command whilst command.txt informs the SA:MP server of the ID you want to perform the command with.
Through your PHP script, you should check the value of state.txt then differ the value between 0 and 1, the opposite of the value which is currently assigned, but ensure that the command.txt has been replaced with the correct ID beforehand.
I've tested it out and it does work, although you could probably make it more advance by sorting out data within a single file instead of one and maybe prefixes to distinguish bans, mutes, kicks and etc.
Edit:
In terms of the PHP, you could also do something as simple as this:
PHP код:
<?php
$user = $_GET["user"];
$file = fopen ("command.txt", "w");
fwrite ($file, $user);
fclose ($file);
$status = file_get_contents ("state.txt");
$sfile = fopen ("state.txt", "w");
if ($status == 0)
{
fwrite ($sfile, "1");
fclose ($sfile);
}
else
{
fwrite ($sfile, "0");
fclose ($sfile);
}
echo ("ID $user has been muted from the server.");
?>
Save that as a PHP file, for example mute.php
If you want to mute someone visit:
http://yourwebsite.com/mute.php?user=3 - this will mute ID 3.