SA-MP Forums Archive
need help something wrong with this code - 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)
+--- Thread: need help something wrong with this code (/showthread.php?tid=422747)



need help something wrong with this code - akki - 15.03.2013

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


Re: need help something wrong with this code - Denying - 15.03.2013

Password should be %d, or am I wrong?


Re: need help something wrong with this code - akki - 15.03.2013

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


Re: need help something wrong with this code - Denying - 15.03.2013

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

Try using if(fail == failvaluetokick) and not if(fail)


Re: need help something wrong with this code - akki - 15.03.2013

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);
	}



Re: need help something wrong with this code - P3DRO - 15.03.2013

try to add a return 1 after spawnplayer.