Help! - 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: Help! (
/showthread.php?tid=144977)
Help! -
[cA]Unforseen - 30.04.2010
i was making a login command for an admin system...
but when i try to login everytime it success... i mean any password is working -.-
here is my command:
Код:
dcmd_login(playerid,params[])
{
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,RED,"You are already logged in.");
if (!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: '/login [password]'");
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
new pFile[256];
format(pFile,sizeof(pFile),File,pName);
PlayerInfo[playerid][Password] = dini_Int(pFile,"Password");
new param = strval(params);
if(param != PlayerInfo[playerid][Password])
{
SendClientMessage(playerid,RED,"Invalid Password!");
}
if(param == PlayerInfo[playerid][Password])
{
SendClientMessage(playerid,GREEN,"You are now logged-in!");
}
return 1;
}
any help??
Re: Help! -
dice7 - 30.04.2010
PlayerInfo[playerid][Password] needs to be a string and
pawn Код:
PlayerInfo[playerid][Password] = dini_Get(pFile,"Password");
is correct, since passwords are strings, not integers (unless you can only have numbers for passwords on your server)
You can't do this
pawn Код:
new param = strval(params);
that will try and transform your string into a number and will always return 0, since you don't have any numbers in your password.
And since the same thing happens here
pawn Код:
PlayerInfo[playerid][Password] = dini_Int(pFile,"Password");
then both variables hold zero, which means every login will be correct.
Use strcmp for comparing strings
https://sampwiki.blast.hk/wiki/Strcmp
Re: Help! -
[cA]Unforseen - 30.04.2010
Quote:
Originally Posted by dice7
PlayerInfo[playerid][Password] needs to be a string and
pawn Код:
PlayerInfo[playerid][Password] = dini_Get(pFile,"Password");
is correct, since passwords are strings, not integers (unless you can only have numbers for passwords on your server)
You can't do this
pawn Код:
new param = strval(params);
that will try and transform your string into a number and will always return 0, since you don't have any numbers in your password.
And since the same thing happens here
pawn Код:
PlayerInfo[playerid][Password] = dini_Int(pFile,"Password");
then both variables hold zero, which means every login will be correct.
Use strcmp for comparing strings
https://sampwiki.blast.hk/wiki/Strcmp
|
thx...
lol i made a big mistake xD