Problem: user System -
[WA]iRonan - 27.11.2013
I am having problems with my log-in screen at the moment. When I press cancel I have to be kicked but somehow I can continue to the class selection.
Code from dialogresponse:
Код:
if(response)
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{FFFFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
return 1;
}
new hashpass[128];
new INI:file = INI_Open(Path(playerid));
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"Money",0);
INI_WriteInt(file,"Score",0);
INI_WriteInt(file,"Deaths",0);
INI_WriteInt(file,"Admin",0);
INI_Close(file);
return 1;
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
new hashpass[129];
if(!strcmp(hashpass, pStats[playerid][password], false))
{
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
}
else
{
SendClientMessage(playerid, COLOR_ACMDSCOMDIR, "You have to log-in in order to play.");
Kick(playerid);
}
return 0;
}
}
}
}
return 1;
}
If somebody could help me I'd be happy. Thanks already.
Re: Problem: user System -
]Rafaellos[ - 27.11.2013
Remove the first if(response) at the top.
Re: Problem: user System -
[WA]iRonan - 27.11.2013
Quote:
Originally Posted by ]Rafaellos[
Remove the first if(response) at the top.
|
That works, epic. But now everyone can log in with a random password.
if you fill in "poopdeck" when your pass is "deckpoop" you will succeed and enter the class selection.
Re: Problem: user System -
[WA]iRonan - 28.11.2013
Bump. I can still fill in random words to log in.
Re: Problem: user System -
[WA]iRonan - 28.11.2013
Really no knowledge? Filling in wrong passwords still works.
Re: Problem: user System -
ikbenremco - 28.11.2013
Change : loadaccount_%s to loadaccount_data
Re: Problem: user System -
[WA]iRonan - 28.11.2013
Quote:
Originally Posted by ikbenremco
Change : loadaccount_%s to loadaccount_data
|
Doesn't work.
Re: Problem: user System -
Lajko1 - 28.11.2013
pawn Код:
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;
}
pawn Код:
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 INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"//","Ok","");
}
}
pawn Код:
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
This is working perfect for me
Re: Problem: user System -
ikbenremco - 28.11.2013
Try to rescript it with this tutorial:
https://sampforum.blast.hk/showthread.php?tid=273088
Re: Problem: user System -
[WA]iRonan - 28.11.2013
Quote:
Originally Posted by Lajko1
pawn Код:
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; }
pawn Код:
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 INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"//","Ok",""); } }
pawn Код:
case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok",""); } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit"); } return 1; } } }
This is working perfect for me
|
Thanks a lot, works great.