command /register crashes server
#1

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
Reply
#2

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


Forum Jump:


Users browsing this thread: 1 Guest(s)