Help with login FS - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with login FS (
/showthread.php?tid=313237)
Help with login FS -
ttloko2 - 25.01.2012
i need you help i have a problem, i made a fs for login heres the situation:
you register,it save your password and level but when you go login it accept any password
Hole script:
Код:
#define FILTERSCRIPT
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define COLOR_BLUE 0xADD8E6FF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
#include <a_samp>
#include <dini>
Код:
public OnPlayerConnect(playerid)
{
new str[64];
new name [MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),"/Accounts/%s.txt",name);
if(dini_Exists(str))
{
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Login","Enter your password below","Login","Cancel");
}
else
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register","Enter your password below:","Register","Cancel");
}
return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==DIALOG_REGISTER)
{ if(response==0)
{
SendClientMessage(playerid,COLOR_RED,"You did not registered");
Kick(playerid);
return 1;
}
if(response==1)
{
Register(playerid,inputtext);
}
return 1;
}
if(dialogid==DIALOG_LOGIN) {
if(response==0) {
SendClientMessage(playerid,0x800080AA,"You did not login");
Kick(playerid);
return 1;
}
if(response==1)
{
Login(playerid,inputtext);
return 1;
}
}
return 1;
}
Код:
stock Register(playerid, key[])
{
new str[64];
new name [MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),"/Accounts/%s.txt",name);
dini_Create (str);
dini_Set (str,"Password",key);
SendClientMessage(playerid,COLOR_YELLOW,"You have registered sucessfully!");
dini_IntSet(str,"level",0);
return 1;
}
stock Login(playerid, key[])
{
new str[64];
new name [MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),"/Accounts/%s.txt",name);
if(!strcmp(key,dini_Get(str,"Password"),false))
{
SetPlayerScore(playerid,dini_Int(str,"Level"));
SendClientMessage(playerid,COLOR_RED,"Logged in sucessfuly");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"Incorrect Password");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Cancel");
return 1;
}
return 1;
}
Any ideas? i suspect this:
Код:
if(!strcmp(key,dini_Get(str,"Password"),false))
Dont ifentify if its right or wrong, soo what should i use?
Re: Help with login FS -
ttloko2 - 25.01.2012
bump
Re: Help with login FS -
ttloko2 - 25.01.2012
Problem solved..
Re: Help with login FS -
KingHual - 25.01.2012
Just an advice - Put includes before defines