29.07.2013, 14:00
Hello i have these codes ...
under OnPlayerDisconnect
Stocks
the problem is.. that stats are not saving on disconnect and i don't get message in console
under OnPlayerDisconnect
pawn Код:
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
if(fexist(Path(playerid)))
{// then
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Players_Data");//We will set a tag inside of user's account called "Players_Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
INI_WriteInt(file,"Adisable",pInfo[playerid][Adisable]);
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_WriteInt(file,"Pills",pInfo[playerid][Pills]);
INI_WriteInt(file,"Savedskin",pInfo[playerid][Savedskin]);
INI_WriteInt(file,"Last",pInfo[playerid][Last]);
INI_WriteInt(file,"NoPM",pInfo[playerid][NoPM]);
INI_WriteInt(file,"Drugs",pInfo[playerid][Drugs]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,24);
new str[120];
format(str,sizeof(str),"<SAVED> Stats for account: %s(%d) has been saved successfully.", playername, playerid);
print(str);
}
Stocks
pawn Код:
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new d,len = strlen(name); d != len; d++)
name[d] = tolower(name[d]);
format(str,sizeof(str),UserPath,name);
return str;
}
Код:
<SAVED> Stats for account: XYZ(x) has been saved successfully.