SA-MP Forums Archive
Help plz - 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 plz (/showthread.php?tid=94320)



Help plz - The_Tough - 29.08.2009

Код:
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.


Re: Help plz - RSX - 29.08.2009

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.


Re: Help plz - dice7 - 29.08.2009

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


Re: Help plz - ded - 29.08.2009

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.


Re: Help plz - The_Tough - 29.08.2009

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


Re: Help plz - ded - 29.08.2009

What errors are you receiving now?


Re: Help plz - The_Tough - 29.08.2009

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...


Re: Help plz - RSX - 29.08.2009

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!)


Re: Help plz - The_Tough - 29.08.2009

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


Re: Help plz - Lightning[SV] - 29.08.2009

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