Iґve taken the tempban system from Seifґs sBanMachine and placed it into LAdmin. It works just fine and everytime a tbanned user tries to connect he gets kicked. BUT: The server crashes and restarts after every tempban-kick. I dont know why.
Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][Deaths] = 0;
PlayerInfo[playerid][Kills] = 0;
PlayerInfo[playerid][Jailed] = 0;
PlayerInfo[playerid][Frozen] = 0;
PlayerInfo[playerid][Level] = 0;
PlayerInfo[playerid][LoggedIn] = 0;
PlayerInfo[playerid][Registered] = 0;
PlayerInfo[playerid][God] = 0;
PlayerInfo[playerid][GodCar] = 0;
PlayerInfo[playerid][TimesSpawned] = 0;
PlayerInfo[playerid][Muted] = 0;
PlayerInfo[playerid][MuteWarnings] = 0;
PlayerInfo[playerid][Warnings] = 0;
PlayerInfo[playerid][Caps] = 0;
PlayerInfo[playerid][DoorsLocked] = 0;
PlayerInfo[playerid][pCar] = -1;
for(new i; i<PING_MAX_EXCEEDS; i++) PlayerInfo[playerid][pPing][i] = 0;
PlayerInfo[playerid][SpamCount] = 0;
PlayerInfo[playerid][SpamTime] = 0;
PlayerInfo[playerid][PingCount] = 0;
PlayerInfo[playerid][PingTime] = 0;
PlayerInfo[playerid][FailLogin] = 0;
PlayerInfo[playerid][ConnectTime] = gettime();
//------------------------------------------------------
new PlayerName[MAX_PLAYER_NAME], string[128], str[128], file[256];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
new tmp3[50]; GetPlayerIp(playerid,tmp3,50);
//-----------------------------------------------------
if(ServerInfo[ConnectMessages] == 1)
{
new pAKA[256]; pAKA = dini_Get("ladmin/config/aka.txt",tmp3);
if (strlen(pAKA) < 3) format(str,sizeof(str),"*** %s (%d) has joined the server", PlayerName, playerid);
else if (!strcmp(pAKA,PlayerName,true)) format(str,sizeof(str),"*** %s (%d) has joined the server", PlayerName, playerid);
else format(str,sizeof(str),"*** %s (%d) has joined the server (aka %s)", PlayerName, playerid, pAKA );
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && playerid != i)
{
if(PlayerInfo[i][Level] > 2) SendClientMessage(i,grey,str);
else {
format(string,sizeof(string),"*** %s (%d) has joined the server", PlayerName, playerid);
SendClientMessage(i,grey,string);
}
}
}
//-----------------------------------------------------
if (dUserINT(PlayerName2(playerid)).("banned") == 1)
{
SendClientMessage(playerid, red, "This name is banned from this server!");
format(string,sizeof(string),"%s ID:%d was auto kicked. Reason: Name banned from server",PlayerName,playerid);
SendClientMessageToAll(grey, string); print(string);
SaveToFile("KickLog",string); Kick(playerid);
}
//-----------------------------------------------------
if(ServerInfo[NameKick] == 1) {
for(new s = 0; s < BadNameCount; s++) {
if(!strcmp(BadNames,PlayerName,true)) {
SendClientMessage(playerid,red, "Your name is on our black list, you have been kicked.");
format(string,sizeof(string),"%s ID:%d was auto kicked. (Reason: Forbidden name)",PlayerName,playerid);
SendClientMessageToAll(grey, string); print(string);
SaveToFile("KickLog",string); Kick(playerid);
return 1;
}
}
}
//-----------------------------------------------------
if(ServerInfo[PartNameKick] == 1) {
for(new s = 0; s < BadPartNameCount; s++) {
new pos;
while((pos = strfind(PlayerName,BadPartNames,true)) != -1) for(new i = pos, j = pos + strlen(BadPartNames); i < j; i++)
{
SendClientMessage(playerid,red, "Your name is not allowed on this server, you have been kicked.");
format(string,sizeof(string),"%s ID:%d was auto kicked. (Reason: Forbidden name)",PlayerName,playerid);
SendClientMessageToAll(grey, string); print(string);
SaveToFile("KickLog",string); Kick(playerid);
return 1;
}
}
}
//-----------------------------------------------------
if(ServerInfo[Locked] == 1) {
PlayerInfo[playerid][AllowedIn] = false;
SendClientMessage(playerid,red,"Server is Locked! You have 20 seconds to enter the server password before you are kicked!");
SendClientMessage(playerid,red," Type /password [password]");
LockKickTimer[playerid] = SetTimerEx("AutoKick", 20000, 0, "i", playerid);
}
//-----------------------------------------------------
if(strlen(dini_Get("ladmin/config/aka.txt", tmp3)) == 0) dini_Set("ladmin/config/aka.txt", tmp3, PlayerName);
else
{
if( strfind( dini_Get("ladmin/config/aka.txt", tmp3), PlayerName, true) == -1 )
{
format(string,sizeof(string),"%s,%s", dini_Get("ladmin/config/aka.txt",tmp3), PlayerName);
dini_Set("ladmin/config/aka.txt", tmp3, string);
}
}
//-----------------------------------------------------
if(!udb_Exists(PlayerName2(playerid))) SendClientMessage(playerid,orange, "ACCOUNT: Type /register [password] to create an account");
else
{
PlayerInfo[playerid][Registered] = 1;
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName));
new tmp2[256]; tmp2 = dini_Get(file,"ip");
if( (!strcmp(tmp3,tmp2,true)) && (ServerInfo[AutoLogin] == 1) )
{
LoginPlayer(playerid);
if(PlayerInfo[playerid][Level] > 0)
{
format(string,sizeof(string),"ACCOUNT: You have been automatically logged in. (Level %d)", PlayerInfo[playerid][Level] );
SendClientMessage(playerid,green,string);
}
else SendClientMessage(playerid,green,"ACCOUNT: You have been automatically logged in.");
}
else SendClientMessage(playerid, green, "ACCOUNT: This nickname is registed, you can now login by typing /login [password]");
}
//----------------------------------------------------
new ip[15];
new stri[128];
new load[4][32];
new ban_day, ban_month, ban_year, ban_ip[15];
GetPlayerIp(playerid, ip, sizeof ip);
new year, month, day;
getdate(year, month, day);
new File:filez = fopen("TempBans.ban",io_read);
if (filez)
{
while (fread(filez, stri, sizeof stri))
{
split(stri, load, '|');
ban_day = strval(load[0]);
ban_month = strval(load[1]);
ban_year = strval(load[2]);
strmid(ban_ip, load[3], 0, strlen(load[3])-1, 15);
if (!(year >= ban_year && month >= ban_month && day >= ban_day) && !strcmp(ban_ip, ip, true))
{
new playername[24],string[128];
GetPlayerName(playerid,playername,sizeof(playername));
format(str, sizeof str, "|- You are temporarily banned from this server until: %d/%d/%d -|", ban_day, ban_month, ban_year);
SendClientMessage(playerid, ADMIN_RED, str);
format(string,sizeof(string),"%s has been kicked by Megan [reason: Temporarily banned] ",playername);
SendClientMessageToAll(orange,string);
Kick(playerid);
}
}
}
return 1;
}
Well, the messages are getting displayed and you get kicked, and straight after it the server crashes.