help me with this code
#1

i have made a system where a person registers and the file with their name is created then opened and the password they entered is saved.
code:
Код:
	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:check = fopen(name,io_write);
		if (check)
		{
			fwrite(name,password);
			fclose(name);
		}
	}
the red ones are the errors.

error:
Код:
D:\san andreas\server\gamemodes\flixter_rp.pwn(304) : error 035: argument type mismatch (argument 1)
D:\san andreas\server\gamemodes\flixter_rp.pwn(305) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
please help me fix this
Reply
#2

when you open a file you should use the File: tag

pawn Код:
new File:myFile = fopen(name,io_append);
fwrite(myFile,"hello");
fclose(myFile);
instead of passing a file handle you pass a string, which is incorrect and can lead to undefined behaviour.

You can find more about files here.
Reply
#3

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
when you open a file you should use the File: tag

pawn Код:
new File:myFile = fopen(name,io_append);
fwrite(myFile,"hello");
fclose(myFile);
instead of passing a file handle you pass a string, which is incorrect and can lead to undefined behaviour.

You can find more about files here.
thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)