20.12.2012, 23:12
My server crashes when a banned player enters the server, he receives the message and the server crashes (shut down)
The ban check is at OnPlayerRequestSpawn, i moved it to OnPlayerConnect and then the server doesn't crashes anymore and it makes the banned player not be able to connect to the server but he doesn't receive the message with the info so if someone can see something wrong with it here is the code:
The ban check is at OnPlayerRequestSpawn, i moved it to OnPlayerConnect and then the server doesn't crashes anymore and it makes the banned player not be able to connect to the server but he doesn't receive the message with the info so if someone can see something wrong with it here is the code:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if(IsPlayerNPC(playerid))
{
SpawnPlayer(playerid);
return true;
}
new string[128];
new string3[128];
new ip[16];
GetPlayerIp(playerid, ip, sizeof ip);
format(string3, sizeof(string3), "Banneds/%s.ini", PlayerName(playerid));
if(fexist(string3)) //autoban
{
ClearChatbox(playerid, 10);
strmid(BanInfo[playerid][pReason], dini_Get(string3,"Reason"), 0, strlen(dini_Get(string3,"Reason")), 255);
strmid(BanInfo[playerid][pAdmBan], dini_Get(string3,"Admin"), 0, strlen(dini_Get(string3,"Admin")), 255);
strmid(BanInfo[playerid][pDate], dini_Get(string3,"Date"), 0, strlen(dini_Get(string3,"Date")), 255);
strmid(BanInfo[playerid][pHour], dini_Get(string3,"Hour"), 0, strlen(dini_Get(string3,"Hour")), 255);
SendClientMessage(playerid, COLOR_WHITE, "|_______________[ Ban Information ]_______________|");
format(string, sizeof(string), "Your Nick:[%s] is banned from {00EE00}Samp {FFD700}Test {00B2EE}Server.", PlayerName(playerid));
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, sizeof(string), "Reason: %s", BanInfo[playerid][pReason]);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "Admin: %s", BanInfo[playerid][pAdmBan]);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "Day: %s, Hour: %s", BanInfo[playerid][pDate], BanInfo[playerid][pHour]);
SendClientMessage(playerid, COLOR_YELLOW, string);
SendClientMessage(playerid, COLOR_YELLOW, "For ban appeal visit: www.testserver.com");
SendClientMessage(playerid, COLOR_YELLOW, "You'll only be unbanned if you're innocent!");
new stri[64], tmp[20], tmp2[20];
format(stri, sizeof(stri), "BannedIps/%s.ini",ip);
getdate(Year, Month, Day);
format(tmp, 20, "%d/%d/%d", Day, Month, Year);
gettime(Hour, Minute, Second);
format(tmp2, 20, "%d:%d:%d", Hour, Minute, Second);
if(dini_Exists(stri))
{
Kick(playerid);
}
else
{
dini_Create(stri);
dini_Set(stri,"Reason",BanInfo[playerid][pReason]);
dini_Set(stri,"Admin",BanInfo[playerid][pAdmBan]);
dini_Set(stri,"Date",BanInfo[playerid][pDate]);
dini_Set(stri,"Hour",BanInfo[playerid][pHour]);
dini_Set(stri,"Nick",PlayerName(playerid));
}
Kick(playerid);
}
format(string3, sizeof(string3), "BannedIps/%s.ini", ip);
if(fexist(string3))
{
ClearChatbox(playerid, 10);
strmid(BanInfo[playerid][pMotivo], dini_Get(string3,"Reason"), 0, strlen(dini_Get(string3,"Reason")), 255);
strmid(BanInfo[playerid][pAdmBan], dini_Get(string3,"Admin"), 0, strlen(dini_Get(string3,"Admin")), 255);
strmid(BanInfo[playerid][pData], dini_Get(string3,"Date"), 0, strlen(dini_Get(string3,"Date")), 255);
strmid(BanInfo[playerid][pHora], dini_Get(string3,"Hour"), 0, strlen(dini_Get(string3,"Hour")), 255);
strmid(BanInfo[playerid][pNick], dini_Get(string3,"Nick"), 0, strlen(dini_Get(string3,"Nick")), 255);
SendClientMessage(playerid, COLOR_WHITE, "|_______________[ Informaзхes do Ban ]_______________|");
format(string, sizeof(string), "Your Ip:[%s] is banned from {00EE00}Samp {FFD700}Test {00B2EE}Server.", ip);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, sizeof(string), "Reason: %s", BanInfo[playerid][pReason]);
SendClientMessage(playerid, COLOR_YELLOW, string);
if(strcmp(BanInfo[playerid][pNick],"", true ) == 0)
{
format(string, sizeof(string), "Admin: %s", BanInfo[playerid][pAdmBan]);
}
else
{
format(string, sizeof(string), "Admin: %s, Nick Fake: %s", BanInfo[playerid][pAdmBan], BanInfo[playerid][pNick]);
}
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "Day: %s, Hour: %s", BanInfo[playerid][pDate], BanInfo[playerid][pHour]);
SendClientMessage(playerid, COLOR_YELLOW, string);
SendClientMessage(playerid, COLOR_YELLOW, "For ban appeal visit: www.testserver.com");
SendClientMessage(playerid, COLOR_YELLOW, "You'll only be unbanned if you're innocent!");
/*new stri[64], tmp[20], tmp2[20];
format(stri, sizeof(stri), "Banneds/%s.ini",PlayerName(playerid));
getdate(Year, Month, Day);
format(tmp, 20, "%d/%d/%d", Day, Month, Year);
gettime(Hour, Minute, Second);
format(tmp2, 20, "%d:%d:%d", Hour, Minute, Second);
if(dini_Exists(stri))
{
Kick(playerid);
}
else
{
dini_Create(stri);
dini_Set(stri,"Reason","Fake IP");
dini_Set(stri,"Admin","Spider_Man");
dini_Set(stri,"Date",tmp);
dini_Set(stri,"Hour",tmp2);
}*/
Kick(playerid);
}