Dini won't save on player disconnect -
Born2die - 21.01.2012
Hi guys,
I can't get an integer to save to an ini file when a player disconnects. The value of the field in the file I'm trying to edit simply won't change.
pawn Код:
dini_IntSet(CurrentFile,"Registered",gPlayerInformation[playerid][PLAYER_REGISTERED]);
with CurrentFile being a string:
pawn Код:
format(CurrentFile,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]); // PlayerFile: #define PlayerFile "Administration/Users/%s.ini"
I tested whether PLAYER_REGISTERED was holding the right value, and it appeared to be the case. So I can only think of something going wrong in the opening file/writing part. Don't know what, though.
The funny thing is that when a player connects, it actually does write a value...
pawn Код:
dini_IntSet(file,"Registered",-1);
I would appreciate it if you could help me out here!
Thanks!
Re: Dini won't save on player disconnect -
Konstantinos - 21.01.2012
If you want to set 1 = registered and 0 = not registered use
pawn Код:
new
file[ 50 ];
format( CurrentFile, sizeof( CurrentFile ), PlayerFile, gPlayerInfo[ playerid ][ /* your_enum_here */ ] );
if( dini_Exists( CurrentFile )
{
dini_IntSet( file, "Registered", 1 );
}
Else, if you want to save Player's name as I saw here "PLAYER_NAME". That is string, not integer.
Like
pawn Код:
enum pInfo
{
PLAYER_NAME[ MAX_PLAYER_NAME ],
Rest
}
// ---
new
Name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, Name, sizeof( Name ) );
format( CurrentFile, sizeof( CurrentFile ), PlayerFile, gPlayerInfo[ playerid ][ /* your_enum_here */ ] );
if( dini_Exists( CurrentFile )
{
dini_Set( file, "Name", Name );
}
Re: Dini won't save on player disconnect -
Born2die - 21.01.2012
Quote:
Originally Posted by Dwane
If you want to set 1 = registered and 0 = not registered use
pawn Код:
new file[ 50 ];
format( CurrentFile, sizeof( CurrentFile ), PlayerFile, gPlayerInfo[ playerid ][ /* your_enum_here */ ] ); if( dini_Exists( CurrentFile ) { dini_IntSet( file, "Registered", 1 ); }
Else, if you want to save Player's name as I saw here "PLAYER_NAME". That is string, not integer.
|
I'm actually trying to change the value of my IsRegistered enumeration PLAYER_REGISTERED (which is an integer and is set to -1) with -1 and 0 being not registered and 1 being registered.
Re: Dini won't save on player disconnect -
Born2die - 21.01.2012
Oh never mind, it was indeed related to my name enum. Many thanks!