Help with password -
D1am0nd - 25.09.2015
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:
Код:
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;
}
}
Re: Help with password -
jlalt - 25.09.2015
i don't think player password loading at this moment can you show me player load faction?
PHP код:
if(!strcmp(buf,pInfo[playerid][pPassword]))
Re: Help with password -
D1am0nd - 25.09.2015
PHP код:
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;
}
}
Re: Help with password -
Aly - 25.09.2015
Dude, you have to load the player's password before you check if the passwords match,I mean before this sequence:
Код:
new buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
if(!strcmp(buf,pInfo[playerid][pPassword]))
Can you show me this function:
Re: Help with password -
Erwin. - 25.09.2015
DELETE
Re: Help with password -
D1am0nd - 25.09.2015
PHP код:
public LoadUser_data(playerid,name[],value[])
{
INI_String("pPassword", pInfo[playerid][pPassword], 129);
INI_Int("pXP",pInfo[playerid][pXP]);
INI_Int("pKills",pInfo[playerid][pKills]);
INI_Int("pDeaths",pInfo[playerid][pDeaths]);
INI_Int("pRank",pInfo[playerid][pRank]);
INI_Int("pEvac",pInfo[playerid][pEvac]);
INI_Int("pAdminLevel",pInfo[playerid][pAdminLevel]);
INI_Int("pVipLevel",pInfo[playerid][pVipLevel]);
INI_Int("pHour",pInfo[playerid][pHour]);
INI_Int("pMin",pInfo[playerid][pMin]);
INI_Int("pSec",pInfo[playerid][pSec]);
INI_Int("pMapsPlayed",pInfo[playerid][pMapsPlayed]);
INI_Int("pCoins",pInfo[playerid][pCoins]);
return 1;
}
Re: Help with password -
Aly - 25.09.2015
Put a printf after the datas are loaded, like this
Код:
public LoadUser_data(playerid,name[],value[])
{
INI_String("pPassword", pInfo[playerid][pPassword], 129);
INI_Int("pXP",pInfo[playerid][pXP]);
INI_Int("pKills",pInfo[playerid][pKills]);
INI_Int("pDeaths",pInfo[playerid][pDeaths]);
INI_Int("pRank",pInfo[playerid][pRank]);
INI_Int("pEvac",pInfo[playerid][pEvac]);
INI_Int("pAdminLevel",pInfo[playerid][pAdminLevel]);
INI_Int("pVipLevel",pInfo[playerid][pVipLevel]);
INI_Int("pHour",pInfo[playerid][pHour]);
INI_Int("pMin",pInfo[playerid][pMin]);
INI_Int("pSec",pInfo[playerid][pSec]);
INI_Int("pMapsPlayed",pInfo[playerid][pMapsPlayed]);
INI_Int("pCoins",pInfo[playerid][pCoins]);
printf("Password: %s", pInfo[playerid][pPassword]);
return 1;
}
Then post your server log please.
Re: Help with password -
jlalt - 25.09.2015
i hope this will work
PHP код:
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);
INI_String("pPassword", pInfo[playerid][pPassword], 129);
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;
}
}
Re: Help with password -
D1am0nd - 25.09.2015
Код:
----------
Loaded log file: "server_log.txt".
----------
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team
[21:37:01]
[21:37:01] Server Plugins
[21:37:01] --------------
[21:37:01] Loading plugin: streamer
[21:37:01] Loaded.
[21:37:01] Loading plugin: sscanf
[21:37:01]
[21:37:01] ===============================
[21:37:01] sscanf plugin loaded.
[21:37:01] © 2009 Alex "******" Cole
[21:37:01] 0.3d-R2 500 Players "dnee"
[21:37:01] ===============================
[21:37:01] Loaded.
[21:37:01] Loading plugin: Whirlpool
[21:37:01]
[21:37:01] ==================
[21:37:01]
[21:37:01] Whirlpool loaded
[21:37:01]
[21:37:01] ==================
[21:37:01]
[21:37:01] Loaded.
[21:37:01] Loaded 3 plugins.
[21:37:01]
[21:37:01] Filterscripts
[21:37:01] ---------------
[21:37:01] Loading filterscript 'bunnyhop.amx'...
[21:37:01] Loading filterscript 'antiafk.amx'...
[21:37:01] Unable to load filterscript 'antiafk.amx'.
[21:37:01] Loaded 1 filterscripts.
[21:37:01]
[21:37:01]
[21:37:01]
[21:37:01] =======================================
[21:37:01] | |
[21:37:01] | YSI version 3.09.0684 |
[21:37:01] | By Alex "******" Cole |
[21:37:01] | |
[21:37:01] =======================================
[21:37:01]
[21:37:01]
[21:37:01]
[21:37:01]
----------------------------------
[21:37:01] TESTTING SERVER
[21:37:01] ----------------------------------
[21:37:01] Number of vehicle models: 0
[21:37:27] [connection] (hidden IP) requests connection cookie.
[21:37:28] [connection] incoming connection: (hidden IP) id: 0
[21:37:28] [join] D1am0nd has joined the server ((hidden IP))
[21:37:28] Password: 3BFC49C2C54A8C5EAE234B78A794B07EBFCC0ABA50EAE579629CCB6A303E26FBAAAE440E7653EB8F52406926AED935F52B1D3A0F5BF75806D3E84BA402EF8B88
[21:37:31] Password: 3BFC49C2C54A8C5EAE234B78A794B07EBFCC0ABA50EAE579629CCB6A303E26FBAAAE440E7653EB8F52406926AED935F52B1D3A0F5BF75806D3E84BA402EF8B88
[21:37:31] 3BFC49C2C54A8C5EAE234B78A794B07EBFCC0ABA50EAE579629CCB6A303E26FBAAAE440E7653EB8F52406926AED935F52B1D3A0F5BF75806D3E84BA402EF8B88
[21:37:33] loading Map /Maps/0.ini
[21:37:33]
--------------------------------------
[21:37:33] No Map Objects Did not Load
[21:37:33] --------------------------------------
[21:37:33] Filterscript 'nonezma.amx' loaded.
[21:37:33] Map ID 0's Information Has Been Loaded.
[21:37:34] Selected humans
[21:37:34] Finished Selecting teams
[21:37:45] [part] D1am0nd has left the server (0:1)
Re: Help with password -
Aly - 25.09.2015
Hmm... it gets loaded.Now let's try to see if the password you enter into the dialog is correctly hashed.
Put a printf again
Код:
new buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
printf("DialogPass: %s",buf);
printf("FilePass: %s",pInfo[playerid][pPassword]);
Do this once with the same password and then with a wrong password and please post the results.(server log)