Help with login FS
#1

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?
Reply
#2

bump
Reply
#3

Problem solved..
Reply
#4

Just an advice - Put includes before defines
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)