
/*
Этот FS не дает реконектится игроку быстрее чем через 5 сек.
после выхода. Для проверки используется IP игрока.
Скрипт оптимизирован, юзает динамическую память и
надежную систему запрета доступа.
MX_Master, 14.07.2010 2:46:25
*/
#include <a_samp>
const player_machine = 1, // ид виртуальной машины для хранения IP игроков, которые онлайн
rec_delay_sec = 5; // сек. после дисконекта, после котороых снова можно конектится
public OnFilterScriptExit()
{
// при выгрузке скрипта, освободим, используюемую им, память
for ( new s = GetMaxPlayers() - 1; s >= 0; --s )
if ( existproperty( player_machine, _, s ) ) deleteproperty( player_machine, _, s );
}
public OnPlayerConnect ( playerid )
{
new cur_str_ip[16];
GetPlayerIp( playerid, cur_str_ip, 16 );
setproperty( player_machine, _, playerid, cur_str_ip );
return 1;
}
public OnPlayerDisconnect ( playerid, reason )
{
if ( reason == 0 ) return 1; // если был тайм аут соединения у игрока
new saved_str_ip[16];
getproperty( player_machine, _, playerid, saved_str_ip );
deleteproperty( player_machine, _, playerid );
strunpack( saved_str_ip, saved_str_ip );
new rcon_cmd[32];
format( rcon_cmd, 32, "banip %s", saved_str_ip );
SendRconCommand(rcon_cmd);
SetTimerEx( "unban_ip", rec_delay_sec * 1000, 0, "s", saved_str_ip );
return 1;
}
forward unban_ip ( ip[] );
public unban_ip ( ip[] )
{
new rcon_cmd[32];
format( rcon_cmd, 32, "unbanip %s", ip );
SendRconCommand(rcon_cmd);
}
#include <a_samp>
#define RTIME 5
new LastIP[MAX_PLAYERS][20],LastTime[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
new str_ip[20];
GetPlayerIp( playerid, str_ip, 20 );
for(new i,s = gettime();i<sizeof(LastIP),i++)
{
if(!strlen(LastIP[i]))break;
if(strcmp(str_ip,LastIP[i],false) == 0)
{
if(s-LastTime[i] < RTIME)return Kick(playerid);
else
{
LastIP[i] = "";
LastTime[i] = 0;
break;
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
for(new i,s = gettime();i<sizeof(LastIP),i++)
{
if(s-LastTime[i] > RTIME)
{
LastIP[i] = "";
LastTime[i] = 0;
}
if(strlen(LastIP[i]))continue;
GetPlayerIp(playerid, LastIP[i], 20 );
LastTime[i] = gettime();
break;
}
return 1;
}
[16:14:00] [join] Test has joined the server (3:127.0.0.1) [16:14:03] [part] Test has left the server (3:1) [16:14:03] Incoming connection: 127.0.0.1:4097 [16:14:03] [join] Test has joined the server (3:127.0.0.1) [16:14:03] [part] Test has left the server (3:2) [16:14:04] Incoming connection: 127.0.0.1:4099 [16:14:04] [join] Test has joined the server (4:127.0.0.1) [16:14:04] [part] Test has left the server (4:2) [16:14:05] Incoming connection: 127.0.0.1:4101 [16:14:05] [join] Test has joined the server (5:127.0.0.1) [16:14:05] [part] Test has left the server (5:2) [16:14:05] Incoming connection: 127.0.0.1:4103 [16:14:05] [join] Test has joined the server (6:127.0.0.1) [16:14:05] [part] Test has left the server (6:2) [16:14:06] Incoming connection: 127.0.0.1:4105 [16:14:06] [join] Test has joined the server (7:127.0.0.1) [16:14:06] [part] Test has left the server (7:2) [16:14:07] Incoming connection: 127.0.0.1:4107 [16:14:07] [join] Test has joined the server (8:127.0.0.1) [16:14:07] [part] Test has left the server (8:2) [16:14:07] Incoming connection: 127.0.0.1:4109 [16:14:07] [join] Test has joined the server (9:127.0.0.1) [16:14:07] [part] Test has left the server (9:2) [16:14:08] Incoming connection: 127.0.0.1:4111 [16:14:08] [join] Test has joined the server (10:127.0.0.1) [16:14:08] [part] Test has left the server (10:2) [16:14:08] Incoming connection: 127.0.0.1:4113 [16:14:08] [join] Test has joined the server (11:127.0.0.1) [16:14:08] [part] Test has left the server (11:2) [16:14:09] Incoming connection: 127.0.0.1:4115 [16:14:09] [join] Test has joined the server (12:127.0.0.1) [16:14:09] [part] Test has left the server (12:2) [16:14:10] Incoming connection: 127.0.0.1:4117 [16:14:10] [join] Test has joined the server (13:127.0.0.1) [16:14:10] [part] Test has left the server (13:2) [16:14:10] Incoming connection: 127.0.0.1:4119 [16:14:10] [join] Test has joined the server (14:127.0.0.1) [16:14:10] [part] Test has left the server (14:2) [16:14:11] Incoming connection: 127.0.0.1:4121 [16:14:11] [join] Test has joined the server (15:127.0.0.1) [16:14:11] [part] Test has left the server (15:2) [16:14:11] Incoming connection: 127.0.0.1:4123 [16:14:11] [join] Test has joined the server (16:127.0.0.1) [16:14:11] [part] Test has left the server (16:2) [16:14:12] Incoming connection: 127.0.0.1:4125 [16:14:12] [join] Test has joined the server (17:127.0.0.1) [16:14:12] [part] Test has left the server (17:2) [16:14:13] Incoming connection: 127.0.0.1:4129 [16:14:13] [join] Test has joined the server (19:127.0.0.1) [16:14:13] [part] Test has left the server (19:1) [16:14:14] Incoming connection: 127.0.0.1:4131 [16:14:14] [join] Test has joined the server (20:127.0.0.1) [16:14:14] [part] Test has left the server (20:1) [16:14:15] Incoming connection: 127.0.0.1:4133 [16:14:15] [join] Test has joined the server (4:127.0.0.1) [16:14:15] [part] Test has left the server (4:1) [16:14:16] Incoming connection: 127.0.0.1:4135 [16:14:16] [join] Test has joined the server (5:127.0.0.1) [16:14:17] [part] Test has left the server (5:1) [16:14:17] Incoming connection: 127.0.0.1:4137 [16:14:17] [join] Test has joined the server (6:127.0.0.1) [16:14:18] [part] Test has left the server (6:1) [16:14:18] Incoming connection: 127.0.0.1:4139 [16:14:18] [join] Test has joined the server (7:127.0.0.1) [16:14:18] [part] Test has left the server (7:2) [16:14:19] Incoming connection: 127.0.0.1:4141 [16:14:19] [join] Test has joined the server (8:127.0.0.1) [16:14:20] [part] Test has left the server (8:1) [16:14:20] Incoming connection: 127.0.0.1:4143 [16:14:20] [join] Test has joined the server (8:127.0.0.1) [16:14:20] [part] Test has left the server (8:2) [16:14:21] Incoming connection: 127.0.0.1:4145 [16:14:21] [join] Test has joined the server (8:127.0.0.1) [16:14:21] [part] Test has left the server (8:1) [16:14:21] Incoming connection: 127.0.0.1:4147 [16:14:21] [join] Test has joined the server (11:127.0.0.1) [16:14:21] [part] Test has left the server (11:2) [16:14:22] Incoming connection: 127.0.0.1:4149 [16:14:22] [join] Test has joined the server (12:127.0.0.1) [16:14:23] [part] Test has left the server (12:1) [16:14:23] Incoming connection: 127.0.0.1:4151 [16:14:23] [join] Test has joined the server (13:127.0.0.1) [16:14:23] [part] Test has left the server (13:2) [16:14:24] Incoming connection: 127.0.0.1:4153 [16:14:24] [join] Test has joined the server (14:127.0.0.1) [16:14:24] [part] Test has left the server (14:1) [16:14:24] Incoming connection: 127.0.0.1:4155 [16:14:24] [join] Test has joined the server (14:127.0.0.1) [16:14:24] [part] Test has left the server (14:2) [16:14:26] Incoming connection: 127.0.0.1:4157 [16:14:26] [join] Test has joined the server (14:127.0.0.1) [16:14:26] [part] Test has left the server (14:1) [16:14:26] Incoming connection: 127.0.0.1:4159 [16:14:26] [join] Test has joined the server (14:127.0.0.1) [16:14:26] [part] Test has left the server (14:2) [16:14:27] Incoming connection: 127.0.0.1:4161 [16:14:27] [join] Test has joined the server (15:127.0.0.1) [16:14:27] [part] Test has left the server (15:1) [16:14:28] Incoming connection: 127.0.0.1:4163 [16:14:28] [join] Test has joined the server (15:127.0.0.1) [16:14:28] [part] Test has left the server (15:2)
банить только с 20 раза, изза чего так может быть?
public OnPlayerDisconnect(playerid, reason)
{
new
string[64],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch(reason)
{
case 0: format(string,sizeof string,"%s left the server. (Timed out)",name);
case 1: format(string,sizeof string,"%s left the server. (Leaving)",name);
case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name);
}
SendClientMessageToAll(0xFFFFFFAA,string);
return 1;
}
|
самый главный аспект - фс может быть включен уже после того, как игроки на серв законектились. и как раз таких игроков фс твой выпустит из виду. это ваще ошибка многих фсописателей. забывается, что фс это не мод, который загружается до любого из конектов. а фс - это динамичный скрипт, который требует в себе больше динамики в обработке данных.
|
|
ты после вылета игры сможешь зайти обратно быстрее чем за 5 секунд? ))
|
|
если помудить с настройками драйверов видеокарты, то вполне возможно:d
|

|
степаха, прасти меня, я невнимательно читал твой код (((: но мой все равно быстрее
![]() -- посморел, подумал, пишу -- кста, я невнимателно читал, т.к. там ваще ни хрена непонятно, особенно, при дисконекте игрока -- еще посморел -- возможно, в твоем коде не учитывается ситуация, когда у игрока, который быстро реконектнулся изменился ид -- важное замечание -- в твоем и моем случае можно было бы использовать динамические массивы property вместо статичных массивов, которые всегда висят в памяти. переделаю-ка я свой код (: на проперти массив.. |
public OnPlayerDisconnect(playerid, reason)
{
for(new i,s = gettime();i<sizeof(LastIP),i++)//думаю понятно, пробегаемся по массиву где храняться IP адреса
{
if(s-LastTime[i] > RTIME)//если встречаем запись у которой время больше 5 секунд обнуляем значения адреса и времени
{
LastIP[i] = "";
LastTime[i] = 0;
}
if(strlen(LastIP[i]))continue;//если находим ненулевую строку пропускаем её, в случае если предыдущая проверка обнулила строку запись проиведется в неё
GetPlayerIp(playerid, LastIP[i], 20 );//узнаем IP вышедшего игрока
LastTime[i] = gettime();//записываем время выхода
break;//обрываем дальнейшую проверку
}
return 1;
}