Saves when a player logs in and out but not on FS reload
#1

this is my code :

Код:
public OnPlayerSave(playerid)
{
        if(IsPlayerConnected(playerid))
        {
                new string3[32];
                new playername3[MAX_PLAYER_NAME];
                GetPlayerName(playerid, playername3, sizeof(playername3));
                format(string3, sizeof(string3), "SS_%s.ini", playername3);
                new File: hFile = fopen(string3, io_write);
                if(hFile)
                {
                        new var[128];
                        format(var, 32, "SS=%d\n",PlayerInfo[playerid][pSS]);fwrite(hFile, var);
                        fclose(hFile);
                }
        }
        return 1;
}
public OnPlayerLogin(playerid)
{
    new string2[128];
    new playername[64];
    new val[ 256 ];
    new Data[ 256 ];
    new key[ 256 ];
	GetPlayerName(playerid, playername, sizeof(playername));
 	format(string2, sizeof(string2), "SS%s.ini", PlayerName(playerid));
  	new File: UserFile = fopen(string2, io_read);
  	if ( UserFile )
    {
        key = ini_GetKey( Data );
        if( strcmp( key , "SS" , true ) == 0 )
        {
        	val = ini_GetValue( Data );
         	PlayerInfo[playerid][pSS] = strvalEx( val );
        }
    }
    fclose(UserFile);
}
stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
stock ini_GetValue( line[] )
{
        new valRes[256];
        valRes[0]=0;
        if( strfind( line , "=" , true ) == -1 ) return valRes;
        strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
        return valRes;
}
stock strvalEx( str[ ] )
{
    if( strlen( str ) >= 50 ) return -1;
    return strval( str );
}
stock ini_GetKey( line[] )
{
	new keyRes[256];
 	keyRes[0] = 0;
    if( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
}
And i got:

Код:
OnPlayerSave(targetid1);
on the /makessleader command and on OnPlayerDisconnect

Please help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)