file functions /register crashes server
#1

I made my own /register command using raw file functions but when I use it server crashes.
pawn Код:
if (!strcmp(cmdtext,"/register",true,6))
    {
            new f_name[64],p_name[24],str[32],File:accfile;
        GetPlayerName(playerid,p_name,strlen(p_name));
        format(f_name,strlen(f_name),"accounts/%s.ini",p_name);
        accfile=fopen(f_name,io_write);
        format(str,strlen(str),"%s",cmdtext[10]);
        fwrite(accfile,str);
        fclose(accfile);
        return SendClientMessage(playerid,green,"Succesfully created account.");
    }
crashinfo:

Код:
--------------------------

SA-MP Server: 0.3b R2



Exception At Address: 0x004A233B



Registers:

EAX: 0x0012F65C	EBX: 0x00F972D4	ECX: 0x00000000	EDX: 0x00405910

ESI: 0x00000000	EDI: 0x00F95A48	EBP: 0x0012F66C	ESP: 0x0012F644

EFLAGS: 0x00010286



Stack:

+0000: 0x00F95A48   0x00F95A48   0x00F972D4   0xFFFFFFFF

+0010: 0x0012F644   0x0012F268   0x0012F84C   0x004A5FA4

+0020: 0x004C11C8   0xFFFFFFFF   0x00F97D34   0x0040591D

+0030: 0x00000000   0x00401096   0x00F95A48   0x00F9E67C

+0040: 0x00F994A0   0x00402BB3   0x00F95A48   0x00000012

+0050: 0x0012F6AC   0x00F9E67C   0x00000000   0x00F95A48

+0060: 0x00000000   0x01000001   0x00000001   0x000051D4

+0070: 0x000051DC   0x000053DC   0x0000141C   0x000053C8

+0080: 0x0000141C   0x00F972D4   0x00F994A0   0x00000000

+0090: 0x00F96BD0   0x000021CC   0x00486CFB   0x00F95A48

+00A0: 0x0012F714   0x00000005   0x00F95A48   0x00000000

+00B0: 0x00F95A48   0x0012F724   0x0012F718   0x003ECDC0

+00C0: 0x00F9A880   0x00000000   0x00000000   0x003ECDC0

+00D0: 0x00000000   0x00F9A880   0x0049C5C5   0x00000005

+00E0: 0x000013E0   0x0012F860   0x003E6AD8   0x0012FC8C

+00F0: 0x0000000E   0x00000098   0x00000098   0x00000090

+0100: 0x0012F860   0x00000000   0x0012F751   0x002C9D01

+0110: 0x00FF0101   0xFD000000   0x44B5072A   0xC50EF01F

+0120: 0x4158BFB1   0x42B468A7   0x00000000   0x00000000

+0130: 0x00000000   0x00000000   0x00000002   0x003E0000
thanks in advance for help
Reply
#2

change yours with "/accounts/%s.ini"
Reply
#3

Thank you for fast response but it didn't helped. I'm using windows xp so there shouldn't be any problems with file creating rights like in vista/7. Any other ideas?
Reply
#4

I have found out that files can't be readed/writed in callback OnPlayerCommandText in rest callbacks there is no problem with that. Why?
Reply
#5

Make sure the folder accounts exists. Also, I'd recommend using something like ZCMD and DUDB.
Reply
#6

Folder exists. Raw file functions are the fastest so I'm not intrested in any other propositions.
Reply
#7

Uhm.. Remove the 'cmdtext[10]' and change it to 'cmdtext[9]' (not sure)
and change the 'true, 6' to 'true, 9'
Reply
#8

That was good notice Claude but still it crashes server. I added if (accfile) {send message,save file,close file} so this construction showed me that somehow fopen fails. And still question is why?
Reply
#9

Add at the register command
pawn Код:
new filecheck[8];
format(filecheck, sizeof filecheck,"accounts");
if(!fexists(filecheck)) return printf("[server] Missing folder \"%s\"", filecheck);
And add below fclose
pawn Код:
printf("Player %s registered", p_name);
Also remove the return, its not needed at all
And make the "strlen" to "sizeof(..)", the '..' are supposed to be the string name
Re-check your folder name and make it as you entered in the command, there must be NO spelling mistakes
If it gives all the time the error "[server] Missing folder "accounts" then remove the line (including the new filecheck[8] and format(filecheck, ...);)
Reply
#10

1- Make sure that you have the file in the correct location
2- Make sure you dont have any warnings in the script (warnings or errors)
3- Make sure you open the script with the pawno of the server (hard to xplain this part xD)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)