SA-MP Forums Archive
Login System (By Me) Problem - 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: Login System (By Me) Problem (/showthread.php?tid=399388)



Login System (By Me) Problem - DanyelKing - 14.12.2012

I'm italian, i've created a login & register system ... register system works fine, but login system has a problem: I write exactly password in Dialog but the server tell me it's wrong ... Why?

There's the Script:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid,name,sizeof(name));

 if(dialogid == DIALOG_LOGIN)
 {
 INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
  if(!response)
  {
   new string[256];
   Kick(playerid);
   format(string,sizeof(string),"[SERVER]: %s и stato cacciato dal Server.[Motivo: Falsa Identificazione.]",name);
   printf("[SERVER]: %s и stato cacciato dal Server.[Motivo: Falsa Identificazione.]",name);
   SendClientMessageToAll(COLOR_RED,string);
   }
   if(response)
    {
    if(udb_hash(inputtext) == PlayerInfo[playerid][pPassHash])
     {
      GivePlayerMoney(playerid,PlayerInfo[playerid][pSoldi]);
      SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);

      if(PlayerInfo[playerid][pAdmin] >= 1)
       {
        new string[256];
        format(string,sizeof(string),"~L'Admin %s si и Connesso | ID: %d | Lv. Admin: %d ~",name,playerid,PlayerInfo[playerid][pLivello]);
        SendClientMessageToAll(YELLOW,string);
        printf("~L'Admin %s si и Connesso | ID: %d | Lv. Admin: %d ~",name,playerid,PlayerInfo[playerid][pLivello]);
       }
      if(PlayerInfo[playerid][pAdmin] == 0)
	   {
	   new string[256];
       format(string,sizeof(string),"~ %s si и Connesso | ID: %d ~",name,playerid);
       SendClientMessageToAll(COLOR_GREEN,string);
       printf("~ %s si и Connesso | ID: %d ~",name,playerid);
       }
	  return 1;
     }
   if(udb_hash(inputtext) != PlayerInfo[playerid][pPassHash])
    {
     new string[256];
     Kick(playerid);
     format(string,sizeof(string),"[SERVER]: %s и stato cacciato dal Server.[Motivo: Password Errata.]",name);
     printf("[SERVER]: %s и stato cacciato dal Server.[Motivo: Password Errata.]",name);
     SendClientMessageToAll(COLOR_RED,string);
    }
  return 1;
  }
 }
 if(dialogid == DIALOG_REGISTER)
 {
  if(response)
  {
   if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Bari Multimode - Registrazione","Password non valida.\nScrivi una Password per registrarti.","Registra","Annulla");
   new INI:File = INI_Open(UserPath(playerid));
   INI_SetTag(File,"data");
   INI_WriteInt(File,"Pass Hash",udb_hash(inputtext));
   INI_WriteInt(File,"Soldi",GetPlayerMoney(playerid));
   INI_WriteInt(File,"Admin",0);
   INI_WriteInt(File,"Livello",0);
   INI_WriteInt(File,"Rep",0);
   INI_WriteInt(File,"Vip",0);
   INI_WriteInt(File,"Num. Morti",0);
   INI_WriteInt(File,"Num. Uccisioni",0);
   INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
   INI_Close(File);
   new string[256];
   GetPlayerName(playerid,name,sizeof(name));
   format(string,sizeof(string),"{99FF00}Complimenti %s, Account Registrato!",name);
   SendClientMessage(playerid,WHITE,string);
   }
  }

 return 0;
}
I'm using y_ini ... The script in Pawno has no errors...


Re: Login System (By Me) Problem - RajatPawar - 14.12.2012

pawn Код:
{
    if(udb_hash(inputtext) == PlayerInfo[playerid][pPassHash])
     {
      GivePlayerMoney(playerid,PlayerInfo[playerid][pSoldi]);
      SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);
} //Weren't you missing this bracket? Or is it a part of the script...



Re: Login System (By Me) Problem - DanyelKing - 14.12.2012

No, It's a part of the script .... It is:

if(udb_hash(inputtext) == PlayerInfo[playerid][pPassHash])
{
GivePlayerMoney(playerid,PlayerInfo[playerid][pSoldi]);
SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);
if(PlayerInfo[playerid][pAdmin] >= 1)
{

This script say if the Player is Admin, after his connection Send a message to all players with his name, id and level.. Else if not, Send a message only with name and id.


Re: Login System (By Me) Problem - LarzI - 14.12.2012

First of all, you could just write 'else' instead of the whole 'if(udb_hash(inputtext) != PlayerInfo[playerid][pPassHash])' thingy.

- Nevermind -

Edit: You should learn to indent your code better, by the way
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));

    if(dialogid == DIALOG_LOGIN)
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
        if(!response)
        {
            new string[256];
            Kick(playerid);
            format(string,sizeof(string),"[SERVER]: %s и stato cacciato dal Server.[Motivo: Falsa Identificazione.]",name);
            printf("[SERVER]: %s и stato cacciato dal Server.[Motivo: Falsa Identificazione.]",name);
            SendClientMessageToAll(COLOR_RED,string);
        }
        else
        {
            if(udb_hash(inputtext) == PlayerInfo[playerid][pPassHash])
            {
                GivePlayerMoney(playerid,PlayerInfo[playerid][pSoldi]);
                SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);

                if(PlayerInfo[playerid][pAdmin] >= 1)
                {
                    new string[256];
                    format(string,sizeof(string),"~L'Admin %s si и Connesso | ID: %d | Lv. Admin: %d ~",name,playerid,PlayerInfo[playerid][pLivello]);
                    SendClientMessageToAll(YELLOW,string);
                    printf("~L'Admin %s si и Connesso | ID: %d | Lv. Admin: %d ~",name,playerid,PlayerInfo[playerid][pLivello]);
                }
                if(PlayerInfo[playerid][pAdmin] == 0)
                {
                    new string[256];
                    format(string,sizeof(string),"~ %s si и Connesso | ID: %d ~",name,playerid);
                    SendClientMessageToAll(COLOR_GREEN,string);
                    printf("~ %s si и Connesso | ID: %d ~",name,playerid);
                }
                return 1;
            }
            else
            {
                new string[256];
                Kick(playerid);
                format(string,sizeof(string),"[SERVER]: %s и stato cacciato dal Server.[Motivo: Password Errata.]",name);
                printf("[SERVER]: %s и stato cacciato dal Server.[Motivo: Password Errata.]",name);
                SendClientMessageToAll(COLOR_RED,string);
            }
            return 1;
        }
    }
    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Bari Multimode - Registrazione","Password non valida.\nScrivi una Password per registrarti.","Registra","Annulla");
            new INI:File = INI_Open(UserPath(playerid));
            INI_SetTag(File,"data");
            INI_WriteInt(File,"Pass Hash",udb_hash(inputtext));
            INI_WriteInt(File,"Soldi",GetPlayerMoney(playerid));
            INI_WriteInt(File,"Admin",0);
            INI_WriteInt(File,"Livello",0);
            INI_WriteInt(File,"Rep",0);
            INI_WriteInt(File,"Vip",0);
            INI_WriteInt(File,"Num. Morti",0);
            INI_WriteInt(File,"Num. Uccisioni",0);
            INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
            INI_Close(File);
            new string[256];
            GetPlayerName(playerid,name,sizeof(name));
            format(string,sizeof(string),"{99FF00}Complimenti %s, Account Registrato!",name);
            SendClientMessage(playerid,WHITE,string);
        }
    }

    return 0;
}
Also: Show us your LoadPlayer_ callback.


Re: Login System (By Me) Problem - DanyelKing - 14.12.2012

Thanks for LarzI , i've used INI_WriteString + Whirpool plugin and script, now it's perfect. Report Topic Close Rep +


Re: Login System (By Me) Problem - LarzI - 14.12.2012

Quote:
Originally Posted by DanyelKing
Посмотреть сообщение
Thanks for LarzI , i've used INI_WriteString + Whirpool plugin and script, now it's perfect. Report Topic Close Rep +
No problem.

Quote:
Originally Posted by DanyelKing
Посмотреть сообщение
i've used INI_WriteString + Whirpool plugin
Smart choice. Whirlpool is way more secure than the udb_hash method.

Quote:
Originally Posted by DanyelKing
Посмотреть сообщение
Report Topic Close
Please don't. Others may encounter the same problem as you, and might try to search for a solution. If the topic is closed, then it won't show up in search results, and people will have to start new topics. This is a waste of time and resources as it would be much better for them to just find this topic and the solution right away.