Whats Wrong ? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Whats Wrong ? (
/showthread.php?tid=196659)
Whats Wrong ? -
iRana - 06.12.2010
Hi guys I make a login register system It was working perfect When I set PInfo,pass as a int but now I change it to string
and its not getting right str and saving "Wrong pass"
pawn Код:
enum pInfo
{
Password[255],
pAdminLevel,
pScore,
pCash,
pLPrice,
};
pawn Код:
if(dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext))return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
PlayerInfo[playerid][Password] = dini_Get(file,"Password");
if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
{
SendClientMessage(playerid,RED,"Sorry Wrong Password!");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
}
else
{
OnLogin(playerid, inputtext);
}
}
return 1;
}
Re: Whats Wrong ? -
leong124 - 06.12.2010
Always use strcmp for string:
Код:
if(strcmp(udb_hash(inputtext),PlayerInfo[playerid][Password]),false))
Go to wiki to know more.
Re: Whats Wrong ? -
Lenny the Cup - 06.12.2010
Don't forget that it returns 0 if one string is empty though
Re: Whats Wrong ? -
Joe_ - 06.12.2010
Something like this, try not to get into a habbit of using strlen for simple things like this !
pawn Код:
if(dialogid == 2)
{
new
name[MAX_PLAYER_NAME], file[50], tmp[50];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
// Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character
// To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'.
// This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.
if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password"));
format(PlayerInfo[playerid][Password], 50, "%s", tmp);
if(udb_hash(inputtext) != PlayerInfo[playerid][Password])
{
SendClientMessage(playerid,RED,"Sorry Wrong Password!");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
return 1;
}
OnLogin(playerid, inputtext);
return 1;
}
// Other dialogs
return 0;
}
Re: Whats Wrong ? -
iRana - 06.12.2010
Quote:
Originally Posted by Joe_
Something like this, try not to get into a habbit of using strlen for simple things like this !
pawn Код:
if(dialogid == 2) { new name[MAX_PLAYER_NAME], file[50], tmp[50];
GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
// Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character // To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'. // This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.
if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password")); format(PlayerInfo[playerid][Password], 50, "%s", tmp);
if(udb_hash(inputtext) != PlayerInfo[playerid][Password]) { SendClientMessage(playerid,RED,"Sorry Wrong Password!"); ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel"); return 1; } OnLogin(playerid, inputtext); return 1; } // Other dialogs return 0; }
|
Oh thanks I got idea about it.....
Re: Whats Wrong ? -
iRana - 07.12.2010
Quote:
Originally Posted by Joe_
Something like this, try not to get into a habbit of using strlen for simple things like this !
pawn Код:
if(dialogid == 2) { new name[MAX_PLAYER_NAME], file[50], tmp[50];
GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
// Your previous example used strlen, which loops around every character in the string until it finds the '\0' escape character // To check if there's no input, simply check if the first character is not a valid character, thus it must be '\0'. // This is much quicker than checking all characters, when you only want to check if there is a character, if there is text, the first character will not be '\0'.
if(!inputtext) return ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel");
format(tmp, sizeof(tmp), "%s", dini_Get(file, "Password")); format(PlayerInfo[playerid][Password], 50, "%s", tmp);
if(udb_hash(inputtext) != PlayerInfo[playerid][Password]) { SendClientMessage(playerid,RED,"Sorry Wrong Password!"); ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Your registered!","Welcome back :P\nPlease sign-in below:","Login","Cancel"); return 1; } OnLogin(playerid, inputtext); return 1; } // Other dialogs return 0; }
|
Not getting right pass "Sorry Wrong Password!".......
Re: Whats Wrong ? -
iRana - 07.12.2010
I got it Working ....