command /register crashes server - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command /register crashes server (
/showthread.php?tid=169068)
command /register crashes server -
grabek4444 - 18.08.2010
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
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;
}
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
Re: command /register crashes server -
[HUN]Jaki - 18.08.2010
Samp usually crashes when it tries to open a file which does not exist.
You can see the error message in server_log.txt.
Try to replace
pawn Код:
format(fname,strlen(fname),"/accounts/%s.txt",pname);
with
pawn Код:
format(fname,strlen(fname),"accounts/%s.txt",pname);