03.02.2018, 22:41
(
Последний раз редактировалось Ducati; 04.02.2018 в 14:29.
Причина: Fixed
)
When i /register, the password successfully saves to my user file, but when I exit the game and rejoin, the login dialog wont recognise my password anymore and I cant login (even though its still in the userfile after rejoining)
Can anybody figure this out? I've been looking over this for ages and cant find any problem with it
Dialog_Register:
Dialog_Login:
SavePlayerStats:
LoadUser:
udb_hash:
Can anybody figure this out? I've been looking over this for ages and cant find any problem with it
Dialog_Register:
Код:
case DIALOG_REGISTER: { if (!response) return SendClientMessage(playerid,COLOR_ERROR,"Registration Cancelled"); if(response) { if(strlen(inputtext) < 6) { SendClientMessage(playerid, COLOR_ERROR, "Your Password Is Too Short, Enter a Long Password."); format(string, sizeof(string), "{0835C7}Sikanderi Deathmatch (0.3z)\n \n{FFFFFF}New Registration\nName: {146AC7}%s\n \n{FFFFFF}Do {FF0000}Not {FFFFFF}Register Multiple Accounts\nDo {FF0000}Not {FFFFFF}Use The Same Password That You Use Elsewhere\nMinimum {FF0000}6 Chars {FFFFFF}Maximum {FF0000}12 Chars\n \nPlease {D6D631}Enter A Password {FFFFFF}For Your Account:",PlayerInfo[playerid][pName],playerid); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registration",string, "Register", "Cancel"); return 1; } if(strlen(inputtext) > 12) { SendClientMessage(playerid, COLOR_ERROR, "Your Password Is Too Long, Enter a Short Password."); format(string, sizeof(string), "{0835C7}Sikanderi Deathmatch (0.3z)\n \n{FFFFFF}New Registration\nName: {146AC7}%s\n \n{FFFFFF}Do {FF0000}Not {FFFFFF}Register Multiple Accounts\nDo {FF0000}Not {FFFFFF}Use The Same Password That You Use Elsewhere\nMinimum {FF0000}6 Chars {FFFFFF}Maximum {FF0000}12 Chars\n \nPlease {D6D631}Enter A Password {FFFFFF}For Your Account:",PlayerInfo[playerid][pName],playerid); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registration",string, "Register", "Cancel"); return 1; } //stats saving 3 new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player Info"); INI_WriteInt(File,"Hitman",0); INI_WriteInt(File,"pSkOldRecords",0); INI_WriteInt(File,"pSkNewRecords",0); INI_WriteInt(File,"PlayerGivenRep",0); INI_WriteInt(File,"PlayerReputations",0); INI_WriteInt(File,"FishRod",0); INI_WriteInt(File,"FishRodWearing",0); INI_WriteInt(File,"FishCooler",0); INI_WriteInt(File,"Fishes",0); INI_WriteInt(File,"ShowDamage",0); INI_WriteInt(File,"DingSound",0); INI_WriteInt(File,"DuelsLost",0); INI_WriteInt(File,"DuelsWon",0); INI_WriteInt(File,"TypingsWon",0); INI_WriteInt(File,"MathsWon",0); INI_WriteInt(File,"WeaponHolder",0); INI_WriteInt(File,"ChastityBelt",0); INI_WriteInt(File,"Gender",0); INI_WriteInt(File,"NoPM",0); INI_WriteInt(File,"StopGoto",1); INI_WriteInt(File,"MoneyBagsFound",0); INI_WriteInt(File,"Years",0); INI_WriteInt(File,"DaysAlive2",0); INI_WriteInt(File,"DaysAlive1",0); INI_WriteInt(File,"Minutes",0); INI_WriteInt(File,"Seconds",0); INI_WriteInt(File,"Regular",0); INI_WriteInt(File,"FlashKills",0); INI_WriteInt(File,"KillStreaks",0); INI_WriteInt(File,"BonusKills",0); INI_WriteInt(File,"TimesRaped",0); INI_WriteInt(File,"Skin",-1); INI_WriteInt(File,"Drugs",0); INI_WriteInt(File,"Pills",0); INI_WriteInt(File,"Disabled",0); INI_WriteInt(File,"Score",0); INI_WriteInt(File,"Banned",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Donator",0); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteInt(File,"Adminlevel",0); INI_Close(File);
Код:
case DIALOG_LOGIN: { if(!response) return Kick (playerid); if(response) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass] && strlen(inputtext) > 0) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); if (PlayerInfo[playerid][Banned]) { new str1[128]; format(str1,sizeof(str1),">>KICK: %s (%d) (ACCOUNT BANNED) Account Banned", PlayerInfo[playerid][pName], playerid); SendClientMessageToAll(COLOR_ADMIN, str1); SendClientMessage(playerid,COLOR_RED,"You Have Been Banned From The Server."); Kick(playerid); } if(fexist(UserBanPath(playerid))) { INI_ParseFile(UserBanPath(playerid), "LoadBanUser_%s", .bExtra = true, .extra = playerid); if(PlayerInfo[playerid][pBanPerm]==1) { new reso[256]; SendClientMessage(playerid,COLOR_ADMIN,">> This Account Has Been Disabled By An Admin."); format(reso,sizeof(reso),">> Reason: %s",PlayerInfo[playerid][pBanres]); SendClientMessage(playerid,COLOR_ADMIN,reso); format(reso,sizeof(reso),"***KICK: %s (%d) (ACCOUNT DISABLED) This Account is Disabled.",PlayerInfo[playerid][pName],playerid); SendClientMessageToAll(COLOR_ADMIN,reso); SetTimerEx("KickPlayer",100,false,"i",playerid); } else { if(gettime() > PlayerInfo[playerid][pBanexp]) { fremove(UserBanPath(playerid)); fremove(UserIPPath(playerid)); SendClientMessage(playerid,COLOR_ADMIN,"You Are Unbanned Now!"); } else { new d,m,y,h,mi,s; TimestampToDate(PlayerInfo[playerid][pBanexp],y,m,d,h,mi,s,GMT_H,GMT_M); new str[540]; format(str,sizeof(str),"Your Account Has Been Disabled By The Adminstration Until %i-%i-%i",d,m,y); SendClientMessage(playerid,COLOR_ADMIN,str); format(str,sizeof(str),"***KICK: %s (%d) (ACCOUNT DISABLED) This Account is Disabled.",PlayerInfo[playerid][pName],playerid); SendClientMessageToAll(COLOR_ADMIN, str); SetTimerEx("KickPlayer",100,false,"i",playerid); } } } else if(fexist(UserIPPath(playerid))) { INI_ParseFile(UserIPPath(playerid), "LoadIPUser_%s", .bExtra = true, .extra = playerid); if(PlayerInfo[playerid][pBanPerm]==1) { new reso[256]; format(reso,sizeof(reso),">> KICK : %s (%d) (IP Disabled), Originally Banned Player : %s.",PlayerInfo[playerid][pName],playerid,PlayerInfo[playerid][pBanIPP]); SendClientMessageToAll(COLOR_ADMIN,reso); format(reso,sizeof(reso),"{85BB65}Reason: {f0f000}%s",PlayerInfo[playerid][pBanres]); SendClientMessage(playerid,-1,reso); SetTimerEx("KickPlayer",100,false,"i",playerid); } else { if(gettime() > PlayerInfo[playerid][pBanexp]) { new pat[100]; fremove(UserIPPath(playerid)); format(pat,sizeof(pat),"Bans/%s.ini",PlayerInfo[playerid][pBanIPP]); fremove(pat); SendClientMessage(playerid,COLOR_ADMIN,">> This IP is Unbanned Now!"); } else { new d,m,y,h,mi,s; new str[540]; TimestampToDate(PlayerInfo[playerid][pBanexp],y,m,d,h,mi,s,GMT_H,GMT_M); format(str,sizeof(str),">> KICK : %s (%d) (IP Disabled) Until %i-%i-%i Originally Banned Player %s",PlayerInfo[playerid][pName],playerid,d,m,y,PlayerInfo[playerid][pBanIPP]); SendClientMessageToAll(COLOR_ADMIN,str); format(str,sizeof(str),"Expires on[TIME] -- %i-%i[Time Format: 24 Hour Clock][UTC 0]",h,mi); SendClientMessage(playerid,COLOR_ADMIN, str); format(str,sizeof(str),"{85BB65}Reason -- {f0f000}%s",PlayerInfo[playerid][pBanres]); SendClientMessage(playerid, -1, str); SetTimerEx("KickPlayer",100,false,"i",playerid); } } } PlayerInfo[playerid][pLogged] = 1; StatsSaveOnDisConnect[playerid]=1; GiveCash(playerid, PlayerInfo[playerid][pCash]); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); SetPlayerColor(playerid,COLOR_WHITE); format(string,sizeof(string),"~n~~n~~w~Current Life~n~"); SendGameText(playerid,string); DaysAliveTimer[playerid] = SetTimerEx("DaysAlive", 1000, 1, "i", playerid); STATS_SAVE[playerid] = SetTimerEx("AUTO_SAVE", 4*60*1000, 1, "i", playerid); new F1[15],F2[15],F3[15],F4[15],F5[15],F6[15],F7[15],F8[15],F9[15],F10[15],F11[15]; if(!dini_Exists(UserClothPath(playerid))) { dini_Create(UserClothPath(playerid)); for(new x = 1; x < MAX_CLOTHES_SLOTS; x++) { if(IsPlayerAttachedObjectSlotUsed(playerid, x)) { format(F1,15,"O_Model_%d",x); dini_IntSet(UserClothPath(playerid),F1,0); format(F2,15,"O_Bone_%d",x); dini_IntSet(UserClothPath(playerid),F2,0); format(F3,15,"O_OffX_%d",x); dini_FloatSet(UserClothPath(playerid),F3,0.0); format(F4,15,"O_OffY_%d",x); dini_FloatSet(UserClothPath(playerid),F4,0.0); format(F5,15,"O_OffZ_%d",x); dini_FloatSet(UserClothPath(playerid),F5,0.0); format(F6,15,"O_RotX_%d",x); dini_FloatSet(UserClothPath(playerid),F6,0.0); format(F7,15,"O_RotY_%d",x); dini_FloatSet(UserClothPath(playerid),F7,0.0); format(F8,15,"O_RotZ_%d",x); dini_FloatSet(UserClothPath(playerid),F8,0.0); format(F9,15,"O_ScaleX_%d",x); dini_FloatSet(UserClothPath(playerid),F9,0.0); format(F10,15,"O_ScaleY_%d",x); dini_FloatSet(UserClothPath(playerid),F10,0.0); format(F11,15,"O_ScaleZ_%d",x); dini_FloatSet(UserClothPath(playerid),F11,0.0); } } } if(PlayerInfo[playerid][pAdminlevel] == 1) { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Server Admin."); } else if(PlayerInfo[playerid][pAdminlevel] == 2) { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Co Owner."); } else if(PlayerInfo[playerid][pAdminlevel] == 3) { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Server Owner."); } else if(PlayerInfo[playerid][pDonator] == 1) { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Donating Player."); } else if(PlayerInfo[playerid][pRegular] == 1) { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Regular Player."); } else { SendClientMessage(playerid,0xFFFFFFFF, "Logged in As {00B9FF}Registered Player."); } if(fexist(UserDisablePath(playerid))) { INI_ParseFile(UserDisablePath(playerid), "LoadDisableUser_%s", .bExtra = true, .extra = playerid); new D,M,Y,H,Mi,S; getdate(Y,M,D); gettime(H,Mi,S); if((D>DisableInfo[playerid][pDisableExp] && M>=DisableInfo[playerid][pDisableM] && Y>=DisableInfo[playerid][pDisableY]) || (D>DisableInfo[playerid][pDisableExp] && M==DisableInfo[playerid][pDisableM]) || (M>DisableInfo[playerid][pDisableM] || Y>DisableInfo[playerid][pDisableY]) || (D==DisableInfo[playerid][pDisableExp] && M==DisableInfo[playerid][pDisableM] && Y==DisableInfo[playerid][pDisableY] && H>=DisableInfo[playerid][pDisableH] && Mi>=DisableInfo[playerid][pDisableMi])) { fremove(UserDisablePath(playerid)); } else { SpawnPlayer(playerid); new Day = DisableInfo[playerid][pDisableExp], Month = DisableInfo[playerid][pDisableM], Year = DisableInfo[playerid][pDisableY]; format(string,sizeof(string),"Your Account Has Been Disabled By The Adminstration Until %i-%i-%i",Day,Month,Year); SendClientMessage(playerid,COLOR_ADMIN,string); format(string, sizeof(string), "***KICK: %s (%d) (ACCOUNT DISABLED) This Account is Disabled.",PlayerInfo[playerid][pName], playerid); SendClientMessageToAll(COLOR_ADMIN, string); KickEx(playerid); } } } else { new loginstr[128]; LOGIN_ATTEMPTS[playerid]++; if(LOGIN_ATTEMPTS[playerid] == 1) { SendClientMessage(playerid, COLOR_ERROR,"* You Have Entered Wrong Password. (1/3) - 2 Attempts Remaining."); format(string, sizeof(string), "{0835C7}Sikanderi Deathmatch (0.3z)\n \n{146AC7}Player Login\n \n{FFFFFF}This Nick, {146AC7}%s, {FFFFFF}is Registered.\nIf This Is Not Your Account, Please Quit And Change Your Name.\n \nPlease {D6D631}Enter Your Password {FFFFFF}To Login:",PlayerInfo[playerid][pName],playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD , "Login", string, "Login", "Cancel"); } if(LOGIN_ATTEMPTS[playerid] == 2) { SendClientMessage(playerid, COLOR_ERROR,"* You Have Entered Wrong Password. (2/3) - 1 Attempts Remaining."); format(string, sizeof(string), "{0835C7}Sikanderi Deathmatch (0.3z)\n \n{146AC7}Player Login\n \n{FFFFFF}This Nick, {146AC7}%s, {FFFFFF}is Registered.\nIf This Is Not Your Account, Please Quit And Change Your Name.\n \nPlease {D6D631}Enter Your Password {FFFFFF}To Login:",PlayerInfo[playerid][pName],playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD , "Login", string, "Login", "Cancel"); } if(LOGIN_ATTEMPTS[playerid] == 3) { SendClientMessage(playerid,COLOR_ERROR,"* You Have Been Kicked - Multiple Fail Login Attempts. (3/3)."); format(loginstr, sizeof(loginstr), "***KICK: %s (%i) (Failed Logins) Failed To Login.",PlayerInfo[playerid][pName],playerid); SendClientMessageToOthers(playerid,COLOR_ADMIN,loginstr); LOGIN_ATTEMPTS[playerid] = 0; KickEx(playerid); } } return 1;
Код:
stock OnSavePlayerStats(playerid) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player Info"); INI_WriteInt(File,"Hitman",PlayerInfo[playerid][pHitman]); INI_WriteInt(File,"PlayerInterests",PlayerInfo[playerid][pInterest]); INI_WriteInt(File,"BankInsurance",PlayerInfo[playerid][pBankInsurance]); INI_WriteInt(File,"BankRobberies",PlayerInfo[playerid][pBankRobberies]); INI_WriteInt(File,"PlayerGivenRep",PlayerInfo[playerid][pRepGiven]); INI_WriteInt(File,"PlayerReputations",PlayerInfo[playerid][pRep]); INI_WriteInt(File,"FishRod",PlayerInfo[playerid][pFishingRod]); INI_WriteInt(File,"FishRodWearing",PlayerInfo[playerid][pFishingRodWearing]); INI_WriteInt(File,"FishCooler",PlayerInfo[playerid][pFishCooler]); INI_WriteInt(File,"Fishes",PlayerInfo[playerid][pFishes]); INI_WriteInt(File,"Pet",PlayerInfo[playerid][pPet]); INI_WriteInt(File,"ShowDamage",PlayerInfo[playerid][pShowDamage]); INI_WriteInt(File,"DingSound",PlayerInfo[playerid][pDingSound]); INI_WriteInt(File,"DuelsLost",PlayerInfo[playerid][pDuelsLost]); INI_WriteInt(File,"DuelsWon",PlayerInfo[playerid][pDuelsWon]); INI_WriteInt(File,"TypingsWon",PlayerInfo[playerid][pTypingWon]); INI_WriteInt(File,"MathsWon",PlayerInfo[playerid][pMathWon]); INI_WriteInt(File,"WeaponHolder",PlayerInfo[playerid][pWeaponHolder]); INI_WriteInt(File,"ChastityBelt",PlayerInfo[playerid][pChastityBelt]); INI_WriteInt(File,"Gender",PlayerInfo[playerid][pGender]); INI_WriteInt(File,"NoPM",PlayerInfo[playerid][pNoPM]); INI_WriteInt(File,"StopGoto",PlayerInfo[playerid][pStopGoto]); INI_WriteInt(File,"MoneyBagsFound",PlayerInfo[playerid][pMoneyBags]); INI_WriteInt(File,"Years",PlayerInfo[playerid][pYear]); INI_WriteInt(File,"DaysAlive2",PlayerInfo[playerid][pDaysAlive2]); INI_WriteInt(File,"DaysAlive1",PlayerInfo[playerid][pDaysAlive1]); INI_WriteInt(File,"Minutes",PlayerInfo[playerid][pMins]); INI_WriteInt(File,"Seconds",PlayerInfo[playerid][pSecs]); INI_WriteInt(File,"Regular",PlayerInfo[playerid][pRegular]); INI_WriteInt(File,"FlashKills",PlayerInfo[playerid][pFlashKills]); INI_WriteInt(File,"KillStreaks",PlayerInfo[playerid][pKillStreaks]); INI_WriteInt(File,"BonusKills",PlayerInfo[playerid][pBonusKills]); INI_WriteInt(File,"TimesRaped",PlayerInfo[playerid][pTimesRaped]); INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]); INI_WriteInt(File,"Drugs",PlayerInfo[playerid][pDrugs]); INI_WriteInt(File,"Pills",PlayerInfo[playerid][pPills]); INI_WriteInt(File,"Disabled",PlayerInfo[playerid][pDisabled]); INI_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_WriteBool(File,"Banned",PlayerInfo[playerid][Banned]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]); INI_WriteInt(File,"Cash",GetPlayerCash(playerid)); INI_WriteInt(File,"HouseId", PlayerInfo[playerid][pHouseId]); INI_WriteInt(File,"House", PlayerInfo[playerid][pHouse]); INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]); INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][pAdminlevel]); INI_Close(File); }
Код:
forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Adminlevel",PlayerInfo[playerid][pAdminlevel]); INI_Int("Password", PlayerInfo[playerid][pPass]); INI_Int("Donator",PlayerInfo[playerid][pDonator]); INI_Int("House", PlayerInfo[playerid][pHouse]); INI_Int("HouseId", PlayerInfo[playerid][pHouseId]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Bank",PlayerInfo[playerid][pBank]); INI_Int("Kills",PlayerInfo[playerid][pKills]); INI_Int("Deaths",PlayerInfo[playerid][pDeaths]); INI_Int("Score",PlayerInfo[playerid][pScore]); INI_Bool("Banned",PlayerInfo[playerid][Banned]); INI_Int("Disabled",PlayerInfo[playerid][pDisabled]); INI_Int("Pills",PlayerInfo[playerid][pPills]); INI_Int("Drugs",PlayerInfo[playerid][pDrugs]); INI_Int("Skin",PlayerInfo[playerid][pSkin]); INI_Int("TimesRaped",PlayerInfo[playerid][pTimesRaped]); INI_Int("BonusKills",PlayerInfo[playerid][pBonusKills]); INI_Int("KillStreaks",PlayerInfo[playerid][pKillStreaks]); INI_Int("FlashKills",PlayerInfo[playerid][pFlashKills]); INI_Int("Regular",PlayerInfo[playerid][pRegular]); INI_Int("Seconds",PlayerInfo[playerid][pSecs]); INI_Int("Minutes",PlayerInfo[playerid][pMins]); INI_Int("DaysAlive1",PlayerInfo[playerid][pDaysAlive1]); INI_Int("DaysAlive2",PlayerInfo[playerid][pDaysAlive2]); INI_Int("Years",PlayerInfo[playerid][pYear]); INI_Int("MoneyBagsFound",PlayerInfo[playerid][pMoneyBags]); INI_Int("StopGoto",PlayerInfo[playerid][pStopGoto]); INI_Int("NoPM",PlayerInfo[playerid][pNoPM]); INI_Int("Gender",PlayerInfo[playerid][pGender]); INI_Int("ChastityBelt",PlayerInfo[playerid][pChastityBelt]); INI_Int("WeaponHolder",PlayerInfo[playerid][pWeaponHolder]); INI_Int("MathsWon",PlayerInfo[playerid][pMathWon]); INI_Int("TypingsWon",PlayerInfo[playerid][pTypingWon]); INI_Int("DuelsWon",PlayerInfo[playerid][pDuelsWon]); INI_Int("LottoWon",PlayerInfo[playerid][pLotteryWon]); INI_Int("DuelsLost",PlayerInfo[playerid][pDuelsLost]); INI_Int("DingSound",PlayerInfo[playerid][pDingSound]); INI_Int("ShowDamage",PlayerInfo[playerid][pShowDamage]); INI_Int("Pet",PlayerInfo[playerid][pPet]); INI_Int("Fishes",PlayerInfo[playerid][pFishes]); INI_Int("FishCooler",PlayerInfo[playerid][pFishCooler]); INI_Int("FishRodWearing",PlayerInfo[playerid][pFishingRodWearing]); INI_Int("FishRod",PlayerInfo[playerid][pFishingRod]); INI_Int("PlayerReputations",PlayerInfo[playerid][pRep]); INI_Int("PlayerGivenRep",PlayerInfo[playerid][pRepGiven]); INI_Int("BankRobberies",PlayerInfo[playerid][pBankRobberies]); INI_Int("BankInsurance",PlayerInfo[playerid][pBankInsurance]); INI_Int("PlayerInterests",PlayerInfo[playerid][pInterest]); INI_Int("Hitman",PlayerInfo[playerid][pHitman]); return 1; }
Код:
stock udb_hash(buf[]) { new length=strlen(buf); new s1 = 1; new s2 = 0; new n; for (n=0; n<length; n++) { s1 = (s1 + buf[n]) % 65521; s2 = (s2 + s1) % 65521; } return (s2 << 16) + s1; }