SA-MP Forums Archive
opening file closes the 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)
+--- Thread: opening file closes the server (/showthread.php?tid=328160)



opening file closes the server - admantis - 23.03.2012

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


Re: opening file closes the server - Babul - 23.03.2012

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


Re: opening file closes the server - antonio112 - 23.03.2012

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


Re: opening file closes the server - MP2 - 23.03.2012

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.


Respuesta: Re: opening file closes the server - admantis - 23.03.2012

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...