Help plz
#1

Код:
dcmd_login(playerid, params[]) {
  new string[128], playername[MAX_PLAYER_NAME];
  GetPlayerName(playerid,playername,sizeof(playername));
  format(file, sizeof(file), "tAdmin/users/%s.ini",playername);
  if(!strlen(params)) return LRS(playerid,"[ ! ] Correct usage : /login <password>");
  if(!dini_Exists(file)) return ACM(playerid,"[ DATA ERROR ] You are not registered!");
  if(PlayerData[playerid][Loggined] == 11) return LRS(playerid,"[ ERROR ] You are already logged in!");
  new tmp[256];
  tmp = dini_Get(file,"Password");
  if(strlen(params) != strval(tmp)) return ACM(playerid,"[ ! ] You typed an incorrect password !");
	PlayerData[playerid][Loggined] = 1;
  PlayerData[playerid][Level] = dini_Int(file,"Level");
  PlayerData[playerid][Banned] = dini_Int(file,"Banned");
  PlayerData[playerid][Jailed] = dini_Int(file,"Jailed");
  PlayerData[playerid][Muted] = dini_Int(file,"Muted");
	PlayerData[playerid][Spectating] = dini_Int(file,"Spectating");
  LRS(playerid,"[ ! ] You have succesfully logged in!");
  printf("%s logged in with password %s",playername,params);
  {
	if(PlayerData[playerid][Banned] == 1)
	{
	SendClientMessage(playerid,COLOUR_YELLOW,"[ NOTICE ] This account is banned ! You cant use it untill its unbanned !");
	return Ban(playerid);
	}
	if(PlayerData[playerid][Muted] == 1)
	{
	SendClientMessage(playerid,COLOUR_YELLOW,"[ NOTICE ] You were mutted before ! You are muted and now !");
	}
	if(PlayerData[playerid][Level] >= 1)
	{
	new adminname[MAX_PLAYER_NAME];
	new level;
	level = PlayerData[playerid][Level];
	GetPlayerName(playerid,adminname,sizeof(adminname));
	format(string,sizeof(string),"[ ! ] Welcome administrator %s level %d",adminname,level);
	SendClientMessage(playerid,COLOUR_GREEN,string);
	}
  }
	return 1;
}
I changed them because I could login with any password,now I cant loggin at all,help please.
Reply
#2

I noticed only 2 mistakes (i checked till msg "you have logged in"
1.Mistake was that player can login how many times he want, cause in check if he's logged in, in place of 1 is 11
2.I didn't see any check with entered and from file got data.
Reply
#3

pawn Код:
if(strlen(params) != strval(tmp)) return ACM(playerid,"[ ! ] You typed an incorrect password !");
Why are you comparing the lengths of the passwords ? Use strcmp to compare them and other strings
Reply
#4

Quote:
Originally Posted by dice7
pawn Код:
if(strlen(params) != strval(tmp)) return ACM(playerid,"[ ! ] You typed an incorrect password !");
Why are you comparing the lengths of the passwords ? Use strcmp to compare them and other strings
That code is fine, if a player enters no params after using /login then it will display that message.
Reply
#5

So whats the mistake ?

I fixed the "11",I didnt noticed it...

ok I will try to fix it but I still need the help,plz post more
Reply
#6

What errors are you receiving now?
Reply
#7

I get no errors...I added this at the old version

if(strval(params) != strval(pass)) return ACM(playerid,"[ ! ] You type wrong password");
if(strval(params) == strval(pass))
{
etc.

but now i can loggin with every password...
Reply
#8

This code allows only numeric passwords... if you need Alphabetical, then you need encrypt and, I hope all other is ok, and then you need to not compare sizes(strval(params) == strval(pass)), but strcmp(params,pass) something like that, only if you use encrypt, then before this check you need to encrypt params now (pass got from file should be encrypted already!)
Reply
#9

The point is I dont know how to encrypt them:/
Any suggestions ?
Reply
#10

Theres a nice guide here which shows how to make a registration system and encrypt passwords

http://forum.sa-mp.com/index.php?topic=69810.0

Hope it helps
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)