17.06.2013, 17:08
Well guys, I need some help from you all to fix this bug
Well, when I connect to the server, it shows the login DialogBox

After that, when I enter a wrong password, it automatically spawns

It spawns to this specific location because of this code:
(NOTE: This is under OnPlayerSpawn function!)
This is the Login Dialogbox's code
This is the login attempt code under OnPlayerLogin(playerid) function:
Well, when I connect to the server, it shows the login DialogBox

After that, when I enter a wrong password, it automatically spawns

It spawns to this specific location because of this code:
(NOTE: This is under OnPlayerSpawn function!)
Код:
if(gPlayerLogged[playerid] == 0)
{
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 20);
SetPlayerPos(playerid, -1979.9329,138.0958,27.6875);
SetPlayerPos(playerid,-1979.9329,138.0958,27.6875);
SetPlayerFacingAngle(playerid, 90);
SetCameraBehindPlayer(playerid);
return 1;
}
Код:
if(dialogid == 1) //LOGIN
{
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if(response)
{
if(!strlen(inputtext))
{
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
return 1;
}
if(strlen(inputtext) >= 50)
{
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
return 0;
}
new tmppass[64];
new playername[MAX_PLAYER_NAME];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
GetPlayerName(playerid, playername, sizeof(playername));
if(strlen(playername) == 3)
{
if(strcmp(playername, "Smo", true) == 0)
{
return 0;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, that name is too short, please change it.");
Kick(playerid);
return 1;
}
}
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass,inputtext);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You chose to leave the server.");
Kick(playerid);
}
}
Код:
if(strcmp(PlayerInfo[playerid][pKey],password, true ) != 0)
{
if(LogAttempt[playerid] < 3)
{
++LogAttempt[playerid];
new relogstring[256];
format(relogstring, sizeof(relogstring), "{FF0000}You've entered a wrong password \n{FFFFFF}Please re-enter your password, and make sure that you enter it correct this time. (Case senstive)\n You have %d/3 attempts left.", LogAttempt[playerid]);
return ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Login", relogstring,"Login","Cancel");
}
else
{
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
new logstring[256];
new year, month, day;
getdate(year, month, day);
SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: Password does not match your name. you have been kicked as a result.");
format(logstring, sizeof(logstring), "%s [%d/%d/%d] Name: %s Pass: %s.", ip, day, month, year,PlayerName(playerid),password2);
BLLog(logstring);
LogAttempt[playerid] = 0;
KickNew(playerid);
}
return 1;
}


