30.09.2012, 15:26
(
Последний раз редактировалось gnoomen2; 30.09.2012 в 18:26.
Причина: Extra Information
)
pawn Код:
forward OnPlayerSave(playerid);
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",pInfo[playerid][pSS]);fwrite(hFile, var);
fclose(hFile);
}
}
return 1;
}
forward OnPlayerLogin(playerid);
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 );
pInfo[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;
}
pawn Код:
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",pInfo[playerid][pSS]);fwrite(hFile, var);
fclose(hFile);
}
}
return 1;
}
A guy told me to use SetPVar int or something like that to make this save, because what's below makes it save, and it saves when a player logs in and out, but not on fs reload. Can anyone fix this so that it saves on fs reload, or give me a example to save
pawn Код:
pInfo[playerid][pSS]