need help something wrong with this code
#1

in this code there is no error but it is not functioning properly
this is login system
the person is able to log in the server if his password is correct or incorrect
code:
Код:
if (dialogid == dialog_login)
	{
	    new Pname[MAX_PLAYER_NAME];
		new name[MAX_PLAYER_NAME + 4];
		new password[30];
		new fail=1;
		GetPlayerName(playerid,Pname,sizeof(Pname));
		format(name,sizeof(name),"%s.txt",Pname);
		format(password,sizeof(password),"Password:%s|",inputtext);
		new File:check = fopen(name,io_read);
		while(fread(check,password))
		{
		    fail = 0;
 	        SendClientMessage(playerid,COLOR_WHITE,"successfully logged in");
			SpawnPlayer(playerid);
  		}
		if(fail)
		{
		    SendClientMessage(playerid,COLOR_GREY,"you failed to login please restart the game and login again");
		    Kick(playerid);
		}
	}
please help
Reply
#2

Password should be %d, or am I wrong?
Reply
#3

Quote:
Originally Posted by Denying
Посмотреть сообщение
Password should be %d, or am I wrong?
password is a string and %s is for string i guess
Reply
#4

Oh well, yeah that's correct. May I see the register dialog?

Try using if(fail == failvaluetokick) and not if(fail)
Reply
#5

Quote:
Originally Posted by Denying
Посмотреть сообщение
Oh well, yeah that's correct. May I see the register dialog?

Try using if(fail == failvaluetokick) and not if(fail)
here is the register dialog
Код:
	if(dialogid == dialog_register)
	{
	   	new Pname[MAX_PLAYER_NAME];
		new name[MAX_PLAYER_NAME + 4];
		new password[30];
		GetPlayerName(playerid,Pname,sizeof(Pname));
		format(name,sizeof(name),"%s.txt",Pname);
		format(password,sizeof(password),"Password:%s|",inputtext);
		fcreate(name);
		new File:input = fopen(name,io_write);
 		fwrite(input,password);
		fclose(input);
	}
Reply
#6

try to add a return 1 after spawnplayer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)