06.05.2012, 01:55
(
Последний раз редактировалось PCheriyan007; 06.05.2012 в 03:21.
)
So I've recently started working on an old gamemode of mine, that I halted development on, and I came across one problem. When I start up SA-MP and connect to my server, the screen looks something like this...
What I'm trying to make the server do is to check a folder to see if there are any bans associated with a connecting player. If there is a ban associated then the player will be kicked and notified of why they were banned in the first place. If there aren't any bans, then the player will be let in and welcomed.
It just hangs there like that forever. Here's the code of my OnPlayerConnect which is where I believe the problem lies...
Anything to note?
What I'm trying to make the server do is to check a folder to see if there are any bans associated with a connecting player. If there is a ban associated then the player will be kicked and notified of why they were banned in the first place. If there aren't any bans, then the player will be let in and welcomed.
It just hangs there like that forever. Here's the code of my OnPlayerConnect which is where I believe the problem lies...
pawn Код:
public OnPlayerConnect(playerid)
{
new banfile[64], ipstring[32], string[128];
SendClientMessage(playerid, COLOR_DEADCONNECT, "|_Ban Check Started_|");
SendClientMessage(playerid, COLOR_YELLOW, "Checking for bans...");
GetPlayerIp(playerid, ipstring, sizeof(ipstring));
format(banfile, sizeof(banfile),"SArcr/Users/Bans/%s.ban", ipstring);
if(DOF2_FileExists(banfile))
{
new banmsg[128];
if(!strcmp(DOF2_GetString(banfile, "BanName"), PlayerName(playerid), true))
{
SendClientMessage(playerid, COLOR_YELLOW, "====================================BANNED=====================================");
SendClientMessage(playerid, COLOR_YELLOW, "This player name has been banned from [Sarcr]");
format(banmsg, sizeof(banmsg), "Date of Ban: %s", dUser(PlayerName(playerid)).("BanDate"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Time of Ban: %s", dUser(PlayerName(playerid)).("BanTime"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Banned By: %s", dUser(PlayerName(playerid)).("BannedBy"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Banned For: %s", dUser(PlayerName(playerid)).("BanReason"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
SendClientMessage(playerid, COLOR_YELLOW, "If you feel that this ban is a mistake, please make an appeal at www.sa-rcr.com");
SendClientMessage(playerid, COLOR_YELLOW, "===============================================================================");
Kick(playerid);
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "====================================BANNED=====================================");
SendClientMessage(playerid, COLOR_YELLOW, "This IP Address has been banned from [Sarcr]");
format(banmsg, sizeof(banmsg), "Date of Ban: %s", dUser(PlayerName(playerid)).("BanDate"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Time of Ban: %s", dUser(PlayerName(playerid)).("BanTime"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Banned By: %s", dUser(PlayerName(playerid)).("BannedBy"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
format(banmsg, sizeof(banmsg), "Banned For: %s", dUser(PlayerName(playerid)).("BanReason"));
SendClientMessage(playerid, COLOR_YELLOW, banmsg);
SendClientMessage(playerid, COLOR_YELLOW, "If you feel that this ban is a mistake, please make an appeal at www.sa-rcr.com");
SendClientMessage(playerid, COLOR_YELLOW, "===============================================================================");
Kick(playerid);
}
return 1;
}
if(udb_Exists(PlayerName(playerid)))
{
if(dUserINT(PlayerName(playerid)).("Banned") == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "====================================BANNED=====================================");
SendClientMessage(playerid, COLOR_YELLOW, "This player name has been banned from [Sarcr]");
SendClientMessage(playerid, COLOR_YELLOW, "The data regarding this ban is unavailable.");
SendClientMessage(playerid, COLOR_YELLOW, "If you feel that this is a mistake, please write an appeal at www.sa-rcr.com");
SendClientMessage(playerid, COLOR_YELLOW, "===============================================================================");
Kick(playerid);
}
ShowLoginScreen(playerid);
}
else if(!udb_Exists(PlayerName(playerid)))
{
ShowRegisterScreen(playerid);
}
SendClientMessage(playerid, COLOR_DEADCONNECT, "|_Ban Check Complete_|");
SendClientMessage(playerid, COLOR_GREEN, "No Bans were found");
new name[24], str[128];
GetPlayerName(playerid, name, 24);
ircSay(EchoConnection, EchoChan,str);
format(str, 128, "%s(%d) Has Joined San Andreas Roleplay/Cops/Robbers v%s", name,playerid,sversion);
SendClientMessageToAll(0x808080AA, str);
printf("%s(%d) Has Joined San Andreas Roleplay/Cops/Robbers v%s (IP: %s)", str,playerid,sversion,ipstring);
InShamal[playerid] = 0;
SetPlayerColor(playerid,COLOR_DEADCONNECT);
SetPlayerVirtualWorld(playerid,0);
format(string, sizeof(string), "San Andreas Roleplay/Cops/Robbers - Script Version %s",sversion);
SendClientMessage(playerid,COLOR_WHITE, string);
SendClientMessage(playerid,0x87CEEBAA, "This is NOT a deathmatch server. Do not randomly kill players");
SendClientMessage(playerid,0x87CEEBAA, "Visit our website to report bugs/suggestions/complaints etc");
SendClientMessage(playerid,0x87CEEBAA, "There is a full list of commands/rules and other information on our website" );
SendClientMessage(playerid,0x87CEEBAA, "Visit our website at www.sa-rcr.com");
//little variables that I deleted just now so that you can have an easier time reading :P
return 1;
}
- I'm using Double-O-Files 2 for any file reading type stuff.
- Please excuse my not-so-professional-sounding self since it's been awhile (7 days short of a year to be precise).