23.05.2014, 16:29
I have a problem with my login system.
When the player connects the first time, they can register perfectly, and it creates their save file.
But if they relog, they need to login... fine, but when they enter their password they used when they registered, it says "Incorrect Password".
Here is my code:
Loading, saving:
Dialogs, and Onplayerconnect:
Please help me
When the player connects the first time, they can register perfectly, and it creates their save file.
But if they relog, they need to login... fine, but when they enter their password they used when they registered, it says "Incorrect Password".
Here is my code:
Loading, saving:
Код:
forward LoadUser_data(playerid, name[], value[]); public LoadUser_data(playerid, name[], value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash", PlayerInfo[playerid][pCash]); INI_Int("Skin",PlayerInfo[playerid][pSkin]); INI_Int("Admin", PlayerInfo[playerid][pAdmin]); return 1; } forward SaveChar(playerid); public SaveChar(playerid) { if(!IsPlayerConnected(playerid)) return 1; if(GetPVarInt(playerid, "prelogin") == 1) return 1; if(GetPVarInt(playerid, "Quiz") == 1) return print("Did not save, in quiz."); if(Connected[playerid] != 1) return print("Did not save, not logged in."); if(AdminDuty[playerid] == 1) return print("Did not save, admin duty."); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Data"); INI_WriteInt(File, "Cash", PlayerInfo[playerid][pCash]); INI_WriteInt(File, "Skin", PlayerInfo[playerid][pSkin]); INI_WriteInt(File, "Admin", PlayerInfo[playerid][pAdmin]); INI_Close(File); return 1; }
Код:
public OnPlayerConnect(playerid) { new PlayerIp[32]; GetPlayerIp(playerid, PlayerIp, 32); GetPlayerIp(playerid, PlayerInfo[playerid][pIp], 50); SetPlayerColor(playerid, 0xFFFFFF00); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1); SetPVarInt(playerid, "prelogin", 1); if(fexist(UserPath(playerid))) { new str[128], string[256], IP[24]; INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GetPlayerIp(playerid, IP, sizeof(IP)); format(str, sizeof(str), "Login - %s", GetName(playerid)); format(string, sizeof(string), "Welcome to Legion of Los Angeles, %s \n\n IP Address: %s \n\n That name you are using is registered, please login below.", GetName(playerid), IP); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, str, string, "Login", "Cancel"); } else { new str[128], string[164], IP[24]; format(str, sizeof(str), "Register - %s", GetName(playerid)); format(string, sizeof(string), "Welcome to Legion of Los Angeles, %s \n\n IP Address: %s \n\n You may register an account by entering a desired password here:", GetName(playerid), IP); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, str, string, "Register", "Cancel"); } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch( dialogid ) { case DIALOG_REGISTER: { if (!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit"); new skin = random(299); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File, "Data"); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_Close(File); PlayerInfo[playerid][pSkin] = skin; PlayerInfo[playerid][pCash] = 10000; PlayerInfo[playerid][pAdmin] = 0; SetSpawnInfo(playerid, 0, skin, 1642.6699, -2238.2620, 13.4974, 177.0089, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); SetCameraBehindPlayer(playerid); SetPVarInt(playerid, "prelogin", 0); AdminDuty[playerid] = 0; Connected[playerid] = 1; // SaveChar(playerid); } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(udb_hash(inputtext) != PlayerInfo[playerid][pPass]) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Incorrect Password. \nPlease try again.", "Login", "Cancel"); if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 1642.6699, -2238.2620, 13.4974, 177.0089, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); SetCameraBehindPlayer(playerid); SetPVarInt(playerid, "prelogin", 0); Connected[playerid] = 1; AdminDuty[playerid] = 0; } return 1; } } } return 1; }