Register error
#1

I am trying to make an register system (sure i take a look at others), but when i type /register 45621 for egzample, my server crashes. Here is the code:

Код:
dcmd_register(playerid, params[])
{
	new string[256];
	if(IsPlayerConnected(playerid))
	{
    new pname[MAX_PLAYER_NAME], ip[24];
	  	GetPlayerName(playerid, pname, sizeof(pname));
	  	GetPlayerIp(playerid, ip, sizeof(ip));
		if(!strlen(params))
		{
			SendClientMessage(playerid, COLOR_RED, "Pamirsai Yrasyti slaptazody pydare tu netikeli, pz asilas Xd");
		}
		else
		{
	  	format(string, sizeof(string), "/Vartotojai/%s.acc", pname);
	  	new File: file = fopen(string, io_read);
	  	if(file)
	  	{
				SendClientMessage(playerid, COLOR_RED, "Toks nikas jau uzregistruotas pydare");
				fclose(file);
			}
	  	new File: reg;
	  	reg = fopen(string, io_append);
	  	new pass1 = strlen(params);
	  	new var[32];
	  	format(var, sizeof(var), "Slapyvardis: %s\n\r", pname);
	  	{
				fwrite(file, var);
			}
	  	format(var, sizeof(var), "IP: %s\n\r", ip);
	  	{
				fwrite(file, var);
			}
	  	format(var, sizeof(var), "Slaptazodis: %s\n\r", pass1);
	  	{
				fwrite(file, var);
			}
			fclose(reg);
			SendClientMessage(playerid, COLOR_GREEN, "JUPY uzsireginai y serva :*");
		}
	}
	return 1;
}
Reply
#2

do you have a folder called Vartotojai in your scriptfiles folder?

- Draco
Reply
#3

yes, i have, and there is registration file which was created when i type /register (i gues), but its empty
Reply
#4

This:
new File: reg;
reg = fopen(string, io_append);

Should be just:
file = fopen(string, io_append);

- Draco

Reply
#5

Thanks a lot, now thats what i found in my file:
IP: 78.63.212.4
Slaptazodis: 878.63.212.4

"Slaptazodis" = "Password" , but there is my ip with some characters in front of it.
Reply
#6

pawn Код:
format(var, sizeof(var), "Slaptazodis: %s\n\r", pass1);
There you used %s for strings but you have an integer, just do

pawn Код:
format(var, sizeof(var), "Slaptazodis: %s\n\r", params);
Reply
#7

Quote:

SendClientMessage(playerid, COLOR_RED, "Pamirsai Yrasyti slaptazody pydare tu netikeli, pz asilas Xd");
SendClientMessage(playerid, COLOR_RED, "Toks nikas jau uzregistruotas pydare");

Lol..
Reply


Forum Jump:


Users browsing this thread: