18.08.2010, 05:37
I made a register command using raw file functions. But the problem is it crashes server. Code seems fine and i run out of ideas why it may cause server crahs (like shutdown). Here is the code
Sometimes it prints messages but then server crashes and there is no file in scriptfiles. Anyone have idea what may cause crash in this command? i'm using windows xp and newest version of samp server. Thanks in advance
pawn Код:
if (!strcmp("/register",cmdtext,true,9))
{
if (strlen(cmdtext)>34) {return SendClientMessage(playerid,red,"Too long password.");}
new str[24],pname[24],fname[40]; //declaring strings
strmid(str,cmdtext,10,strlen(cmdtext),strlen(str)); //cut out the password and save it to string
GetPlayerName(playerid,pname,strlen(pname)); //GetPlayerName to string pname
format(fname,strlen(fname),"/accounts/%s.txt",pname); //format string fname into file name
SendClientMessage(playerid,red,"creating file"); //information
new File:ufile=fopen(fname,io_readwrite); //opening or creating file
fwrite(ufile,str); //saving string
SendClientMessage(playerid,green,"Succesfully created a file account!"); //succes message
fclose(ufile); //closing file
return 1;
}