login dialog
#1

i have this code for login but when i entering password i saw again login dialog.

PHP код:
enum pInfo{
    
pIp[16],
    
pRegistrationdate[11],
    
pHashPW,
    
pPassword[128],
    
pAdminlevel,
    
pViplevel,
    
pScore,
    
pMoney,
    
pDeaths,
    
pDeathspree,
    
pKills,
    
pKillspree,
    
pZones,
    
pZonespree,
    
Float:pRatio,
    
pRegistered,
    
pBan,
    
pAban[128],
    
pRban[128],
    
pWarn,
    
pFight,
    
pLicense,
    
pClanid,
    
pClan,
    
pClanname[128],
    
pMember[128],
    
pClanlevel,
    
pTutorial,
    
bool:pMute,
    
bool:pFreeze,
    
bool:pJail,
    
bool:pLogged};
new 
PlayerData[MAX_PLAYERS][pInfo]; 
PHP код:
public LoadUser_data(playerid,name[],value[]){
    
INI_String("ip",PlayerData[playerid][pIp],16);
    
INI_String("Registrationdate",PlayerData[playerid][pRegistrationdate],11);
    
INI_Int("HashPW",PlayerData[playerid][pHashPW]);
    
INI_String("Password",PlayerData[playerid][pPassword],128);
    
INI_Int("Adminlevel",PlayerData[playerid][pAdminlevel]);
    
INI_Int("Viplevel",PlayerData[playerid][pViplevel]);
    
INI_Int("Score",PlayerData[playerid][pScore]);
    
INI_Int("Money",PlayerData[playerid][pMoney]);
    
INI_Int("Deaths",PlayerData[playerid][pDeaths]);
    
INI_Int("Deathspree",PlayerData[playerid][pDeathspree]);
    
INI_Int("Kills",PlayerData[playerid][pKills]);
    
INI_Int("Killspree",PlayerData[playerid][pKillspree]);
    
INI_Int("Zones",PlayerData[playerid][pZones]);
    
INI_Int("Zonespree",PlayerData[playerid][pZonespree]);
    
INI_Float("Ratio",PlayerData[playerid][pRatio]);
    
INI_Int("Registered",PlayerData[playerid][pRegistered]);
    
INI_Int("Ban",PlayerData[playerid][pBan]);
    
INI_String("Adminban",PlayerData[playerid][pAban],128);
    
INI_String("Reasonban",PlayerData[playerid][pRban],128);
    
INI_Int("Fight",PlayerData[playerid][pFight]);
    
INI_Int("License",PlayerData[playerid][pLicense]);
    
INI_Int("Clanid",PlayerData[playerid][pClanid]);
    
INI_Int("Clan",PlayerData[playerid][pClan]);
    
INI_String("Clanname",PlayerData[playerid][pClanname],128);
    
INI_String("Member",PlayerData[playerid][pMember],128);
    
INI_Int("Clanlevel",PlayerData[playerid][pClanlevel]);
    
INI_Int("Tutorial",PlayerData[playerid][pTutorial]);
    
INI_Bool("Mute",PlayerData[playerid][pMute]);
    
INI_Bool("Freeze",PlayerData[playerid][pFreeze]);
    
INI_Bool("Jail",PlayerData[playerid][pJail]);
    
INI_Bool("Logged",PlayerData[playerid][pLogged]);
     return 
1;} 
PHP код:
if(dialogid==DIALOG_LOGIN){
           if(
response==0)return Kick(playerid);
         if(
response==1){
             
INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra=true,.extra=playerid);
            if(
udb_hash(inputtext)==PlayerData[playerid][pHashPW]){
                 
GivePlayerMoney(playerid,PlayerData[playerid][pMoney]);
                 
SetPlayerScore(playerid,PlayerData[playerid][pScore]);
                 return 
1;}
               if(
udb_hash(inputtext)!=PlayerData[playerid][pHashPW]){
                   
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,""COL_RED"Login(incorrect password)",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to "COL_LIGHT_GREEN"login.","Login","Quit");
                   return 
1;}
               return 
1;}} 
Reply
#2

Use strcmp for strings and not the default operators,
Reply
#3

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Use strcmp for strings and not the default operators,
Where do I put this?
Reply
#4

if(udb_hash(inputtext)!=PlayerData[playerid][pHashPW])

Do it like that if(strcmp(udb_hash(inputtext),PlayerData[playerid][pHashPW],true))
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
if(udb_hash(inputtext)!=PlayerData[playerid][pHashPW])

Do it like that if(strcmp(udb_hash(inputtext),PlayerData[playerid][pHashPW],true))
Код:
C:\Users\Aref\Desktop\Aref\CODv4\pawno\CODv4.pwn(402) : error 035: argument type mismatch (argument 1)
Reply
#6

The variabile pHashPW is an integer and I think udb_hash returns a string or something different than integer. Fix the data types and use the correct comparator (strcmp to check if string equals string or "==" to check if number equals number).
Reply
#7

pHashPW[128]
Reply
#8

udb_hash does return an integer, it was used in dudb by DracoBlue (that code is almost 10 years old)
udb_hash shouldn't be used for various reasons I won't state here

Anyway you should switch to SHA256_PassHash, its a native introduced in SA-MP 0.3.7 R1

Apart from that I see no functional problems in your dialog code

You should reset your password and try to login with a new one, also check the output of the hashes with printf
Also check if your saving / loading code works flawless
Reply
#9

Is it true ?
PHP код:
new hashpass[64+1];
SHA256_PassHash(inputtext,"78sdjs86d2h",hashpass,sizeof(hashpass)); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)