25.09.2015, 16:34
Hello.
I am currently working on the regiser/login system, the latest thing which I have updated is, when the player had registered his name and when he re-connected, it would not be possible for him to login without typing a password. Before he was able to login without typing his password, it is like just pressing enter and okay. So I scripted it to be like, he must atleast type a character, to login. But it is not right, the player must type his correct password. For example, he was registered with the pass "hey123", but was always loging in with the pass "he" or whatever it is. Is that something called like hash password?
I want the player to type his password correctly on the login.
Please help me.
Here is some code:
I am currently working on the regiser/login system, the latest thing which I have updated is, when the player had registered his name and when he re-connected, it would not be possible for him to login without typing a password. Before he was able to login without typing his password, it is like just pressing enter and okay. So I scripted it to be like, he must atleast type a character, to login. But it is not right, the player must type his correct password. For example, he was registered with the pass "hey123", but was always loging in with the pass "he" or whatever it is. Is that something called like hash password?
I want the player to type his password correctly on the login.
Please help me.
Here is some code:
Код:
public OnPlayerConnect(playerid) { playerOnline++; ResetVars(playerid); ConnectVars(playerid); new string[128]; if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid); format(string,sizeof(string),""COL_WHITE" Logging",PlayerName(playerid)); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,string,""COL_WHITE"Account Status: {00CF67}REGISTERED\n{FFFFFF}Login by typing your password below:","Login","Quit"); } else { format(string,sizeof(string),""COL_WHITE"Register",PlayerName(playerid)); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,string,""COL_WHITE"Welcome to ...\n{FFFFFF}Account Status: {FF0000}UN-REGISTERED\n{FFFFFF}Register by typing your desidered password below:","Register","Quit"); } return 1; }
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_REGISTER: { if(!response) { ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat"{FF0000} You must Register to play at "NAME"","Close",""); Kick(playerid); } if(response) { new str[256],IP[16],buf[129]; GetPlayerIp(playerid, IP, sizeof(IP)); if(!strlen(inputtext)) { format(str,sizeof(str),""COL_WHITE"Register",PlayerName(playerid)); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,str,""COL_WHITE"Welcome to ...\n{FFFFFF}Account Status: {FF0000}UN-REGISTERED\n{FFFFFF}Register by typing your desidered password below:","Register","Quit"); } new INI:File = INI_Open(UserPath(playerid)); WP_Hash(buf, sizeof(buf), inputtext); INI_SetTag(File,"data"); INI_WriteString(File,"pPassword", buf); INI_WriteInt(File,"pXP",0); INI_WriteInt(File,"pKills",0); INI_WriteInt(File,"pDeaths",0); INI_WriteInt(File,"pRank",0); INI_WriteInt(File,"pEvac",0); INI_WriteInt(File,"pAdminLevel",0); INI_WriteInt(File,"pVipLevel",0); INI_WriteInt(File,"pHour",0); INI_WriteInt(File,"pMin",0); INI_WriteInt(File,"pSec",0); INI_WriteInt(File,"pMapsPlayed",0); INI_WriteInt(File,"pCoins",0); INI_WriteString(File,"pIP",IP); INI_Close(File); playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid); pInfo[playerid][pLogged] = 1; } } case DIALOG_LOGIN: { if(!response) { ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat"{FF0000} You must Login to play at "NAME"","Close",""); Kick(playerid); } if(response) { new buf[129]; WP_Hash(buf, sizeof(buf), inputtext); if(!strcmp(buf,pInfo[playerid][pPassword])) { INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid); pInfo[playerid][pLogged] = 1; playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid); SendClientMessage(playerid,-1,""chat""COL_LGREEN" {66FF66}You have successfully logged in!"); PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0); printf("%s",pInfo[playerid][pPassword]); } else { new string[256]; format(string,sizeof(string),""COL_WHITE" Logging",PlayerName(playerid)); if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,string,""COL_WHITE"Account Status: {00CF67}REGISTERED\n{FFFFFF}Login by typing your password below:","Login","Quit"); } return 1; } }