SA-MP Forums Archive
Dialog 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: Dialog Problem (/showthread.php?tid=531371)



Dialog Problem - arlindi - 12.08.2014

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response)
            {
                 
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must register to play at "NAME"","Close","");
                
Kick(playerid);
            }
            if(
response)
            {
                new 
str[256],IP[16],hashpass[129];
                
GetPlayerIp(playeridIPsizeof(IP));
                if(!
strlen(inputtext))
                {
                    
format(str,sizeof(str),""chat"Welcome %s to "NAME"",PlayerName(playerid));
                    
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD,str,""chat" Welcome to "NAME" you'll be forced to register please click register!","Register","Quit");
                }
                
WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
                
new INI:File INI_Open(UserPath(playerid));
                
/*new INI:File = INI_Open(UserPath(playerid));
                WP_Hash(buf, sizeof(buf), inputtext);*/
                
INI_SetTag(File,"data");
                
//INI_WriteString(File, "pPassword", buf);
                
INI_WriteString(File,"Password",inputtext);
                
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,"pAdminDuty",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_WriteInt(File,"pBanned",0);
                
INI_WriteInt(File,"gLeader",0);
                
INI_WriteInt(File,"gMember",0);
                
INI_Close(File);
                
                 
TextDrawHideForPlayer(playeridlogin0);
                
TextDrawHideForPlayer(playeridlogin1);
                
TextDrawHideForPlayer(playeridlogin2);
                
TextDrawHideForPlayer(playeridlogin3);
                
playedtimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);
                
pInfo[playerid][pLogged] = 1;
            }
        }
        case 
DIALOG_LOGIN:
        {
              if(!
response)
            {
                 
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"Kicked",""chat" You must login to play at "NAME"","Close","");
                
Kick(playerid);
            }
            if(
response)
            {
                new 
hashpass[129];
                
WP_Hash(hashpass,sizeof(hashpass),inputtext);
                if(!
strcmp(inputtext,pInfo[playerid][pPassword]))
                {
                    
//INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
                    
INI_ParseFile(UserPath(playerid), "LoadUser_data",.bExtra true, .extra playerid);
                    
pInfo[playerid][pLogged] = 1;
                    
playedtimer[playerid] = SetTimerEx("TimeOnServer"10001"i"playerid);
                    
SendClientMessage(playerid,-1,""chat""COL_LGREEN" Logged in!");
                    
printf("%s",pInfo[playerid][pPassword]);
                    
TextDrawHideForPlayer(playeridlogin0);
                    
TextDrawHideForPlayer(playeridlogin1);
                    
TextDrawHideForPlayer(playeridlogin2);
                    
TextDrawHideForPlayer(playeridlogin3);
                }
                else
                {
                    new 
string[256];
                    
format(string,sizeof(string),""chat" Welcome back %s",PlayerName(playerid));
                    
ShowPlayerDialog(playeridDIALOG_LOGIN,DIALOG_STYLE_PASSWORD,string,""chat" Our system have detected your username registered please login","Login","Quit");
                }
                return 
1;
            }
        } 
Idk what is the problem here but, dont have errors .
when i login when is correct and incorrect password he logged in
help mee please how to fix this.


Re: Dialog Problem - Jstylezzz - 12.08.2014

strcmp will return 0 when the strings are the same, but also when one of the strings is empty. Have you checked if the password is saved in the ini file? Is the ini file created in the first place?


Re: Dialog Problem - arlindi - 12.08.2014

I dont understand nothing Please give mee code.


Re: Dialog Problem - Jstylezzz - 12.08.2014

I can't give you any code. I asked you, if the password string is saved in the ini file. If you don't understand English, ask in the language section for your language. If that language section does not exist, try translating my text with a translation program or let someone translate it who knows both languages.


Re: Dialog Problem - silenthill - 12.08.2014

Look see this model similar record, try to correct your


Re: Dialog Problem - Stinged - 12.08.2014

You're saving inputtext in DIALOG_REGISTER, not the hashed password.


Re: Dialog Problem - arlindi - 12.08.2014

Heah i want to save the inputtext and in dialog login i want the inputtext


Re: Dialog Problem - arlindi - 12.08.2014

Bump. AnyOne?


Re: Dialog Problem - arlindi - 12.08.2014

Bump PLEASEEEEE


Re: Dialog Problem - Stinged - 12.08.2014

For everyone's sake, follow the damn rules...
Don't bump before 24 hours.

You're hashing in DIALOG_LOGIN, but you're not hashing DIALOG_REGISTER.

It's better if you hash them. I wouldn't join your server if you can know my password.