opening file closes the server
#1

hey there, I'm working on something but I'm really sleepy (god bless coffee):

pawn Код:
CMD:asetname( playerid, params[] )
{
    new iVictim, newName[24];
    if( sscanf( params, "ds[24]", iVictim, newName ) )
        return ShowSyntaxMessage( playerid, "/asetname [playerid] [new name]" );

    if( !NameIsRP( newName ) )
        return ShowErrorMessage( playerid, "That name does not have a correct Firstname_Lastname format." );

    if( strlen( newName ) > 24 )
        return ShowErrorMessage( playerid, "That name is over 24 characters long." );

    new fileChk[32], oldName[32], pwBuff[256];
    format( oldName, 32, "SFRP/Accounts/%s.ini", GetName( iVictim ) );
    format( fileChk, 32, "SFRP/Accounts/%s.ini", newName );
    if( fexist( fileChk ) )
        return ShowErrorMessage( playerid, "That account already exists in the database." );

    printf("*debug 1");
    fremove( oldName );
    printf("*debug 2");
    format( oldName, 24, GetPName( iVictim ) );
    printf("*debug 3");
    INI_Open( UserPath( iVictim ) );
    printf("*debug 4");
    format( pwBuff, 256, "%s", INI_ReadString( "Password" ) );
    printf("*debug 5");
    INI_Close( );
    printf("*debug 6");

    SetPlayerName( iVictim, newName );
    printf("*debug 7");
    SaveUserData( iVictim, pwBuff );
    printf("*debug 8");
//blabalbalbalbalb
my server closes after debug 3 is printed. anyone could tell me why?
regards
Reply
#2

UserPath is not defined or formatted as string. only used in the crashing line (INI_Open)
Reply
#3

How about this:
pawn Код:
format( oldName, 24, "%s", GetPName( iVictim ) );
Misread, I thought your server crashes before debug 3.
Reply
#4

Make sure the directory exists.


Quote:
Originally Posted by Babul
Посмотреть сообщение
UserPath is not defined or formatted as string. only used in the crashing line (INI_Open)
It's a function, I am 99% certain it's function is to return the string of the file path.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Make sure the directory exists.
thank you , silly me i removed the file before opening it but didn't really notice.

Quote:
Originally Posted by Babul
Посмотреть сообщение
UserPath is not defined or formatted as string. only used in the crashing line (INI_Open)
oh well that gave me a tip...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)