Dini won't save on player disconnect
#1

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

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 );
}
Reply
#3

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.
Reply
#4

Oh never mind, it was indeed related to my name enum. Many thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)