14.06.2014, 09:23
Hello!
I have a weird problem in OnPlayerRequestClass callback.
Whenever player fails to login at first attempt and if they enter the password at second attempt and he/she is successfully logged in, the OnPlayerRequestClass screen isn't showing up, it shows some random blank screen without classes. it only shows up correctly if they are successfully logged in at first attempt.
Everything was fine before, i made the login attempts script and the bug showed up.
Login dialog:
OnPlayerRequestClass:
I have been working to fix this issue since 2 hours and couldn't figure out what is wrong, so i came here for help.
I have a weird problem in OnPlayerRequestClass callback.
Whenever player fails to login at first attempt and if they enter the password at second attempt and he/she is successfully logged in, the OnPlayerRequestClass screen isn't showing up, it shows some random blank screen without classes. it only shows up correctly if they are successfully logged in at first attempt.
Everything was fine before, i made the login attempts script and the bug showed up.
Login dialog:
pawn Код:
Dialog_Login(playerid, response, inputtext[])
{
new msg[128], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
if(!response)
{
format(msg, 128, "%s has been kicked from the server! [Quitting the Login Dialog]", Name);
SendClientMessageToAll(RED, msg);
SendClientMessage(playerid, DARK_RED, "You must Login to your Account before entering the server!");
Timer_Disconnect[playerid] = SetTimerEx("DisconnectPlayer", 100, false, "d", playerid);
}
if(response)
{
if(udb_hash(inputtext) == pInfo[playerid][PlayerPassword])
{
pInfo[playerid][LoggedIn] = true;
SendClientMessage(playerid, LIGHT_GREEN, "[ACCOUNT] You are successfully Logged in. Welcome back!");
BankFile_Load(playerid);
DeleteTextDraws(playerid);
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
INI_ParseFile(InventoryPath(playerid), "LoadInventory_%s", .bExtra = true, .extra = playerid);
}
else
{
if(LoginAttempts[playerid] < MAX_FAIL_LOGINS)
{
LoginAttempts[playerid]++;
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "{FFFFFF}LOGIN", "{00FF00}Welcome back!\n\n{FFFFFF}Please enter your Password bellow to login:", "Login", "");
format(msg, 128, "Wrong password! Attempts: %i/%i", LoginAttempts[playerid], MAX_FAIL_LOGINS);
SendClientMessage(playerid, DARK_RED, msg);
}
else if(LoginAttempts[playerid] == MAX_FAIL_LOGINS)
{
format(msg, 128, "%s has been kicked from the server! [Too many login attempts]", Name);
SendClientMessageToAll(RED, msg);
SendClientMessage(playerid, DARK_RED, "You failed to login, you have been kicked!");
Timer_Disconnect[playerid] = SetTimerEx("DisconnectPlayer", 100, false, "d", playerid);
}
}
}
return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if(pInfo[playerid][LoggedIn] == true)
{
SetPlayerPos(playerid,-2378.0867, -579.2721, 132.1665);
SetPlayerVirtualWorld(playerid, 1);
SetPlayerFacingAngle(playerid, 132.1665);
SetPlayerCameraPos(playerid, -2383.2615, -577.4695, 132.0175);
SetPlayerCameraLookAt(playerid, -2382.3948, -577.9800, 132.1530);
switch (classid)
{
case 0, 1, 2, 3, 4, 5, 6, 7:
{
GameTextForPlayer(playerid, "~g~Trucker", 3000, 6);
pInfo[playerid][PlayerClass] = TRUCKER;
}
case 8:
{
GameTextForPlayer(playerid, "~y~Pilot", 3000, 6);
pInfo[playerid][PlayerClass] = PILOT;
}
case 9, 10, 11:
{
GameTextForPlayer(playerid, "~b~Police", 3000, 6);
pInfo[playerid][PlayerClass] = POLICE;
}
case 12:
{
GameTextForPlayer(playerid, "~p~Mechanic", 3000, 6);
pInfo[playerid][PlayerClass] = MECHANIC;
}
}
}
return 1;
}