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);
}
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.
for(new d,len = strlen(name); d != len; d++) name[d] = tolower(name[d]);
first remove this from disconect if(fexist(Path(playerid))) ..its vs logic lol
and then how you can get message if ur disconnecting the third would be problem this Код:
for(new d,len = strlen(name); d != len; d++) name[d] = tolower(name[d]); |
public OnPlayerDisconnect(playerid, reason)
{
if(playerid == INVALID_PLAYER_ID || !IsPlayerConnected(playerid)) return SCM(playerid, -1,"");
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);
}
cage[playerid] = DestroyObject(cage[playerid]);
cage2[playerid] = DestroyObject(cage2[playerid]);
cage3[playerid] = DestroyObject(cage3[playerid]);
cage4[playerid] = DestroyObject(cage4[playerid]);
caged[playerid] = 0;
LeaveGroup(playerid, 2);
if(pInfo[playerid][Adminlevel] > 1)
{
if(blockedfix == 1)
{
blockedfix =0;
SendClientMessageToAll(COLOR_HOTPINK, "/fix Has Been Unblocked.");
}
if(blockedsh == 1)
{
blockedsh =0;
SendClientMessageToAll(COLOR_HOTPINK, "/sh Has Been Unblocked.");
}
if(blockedsar == 1)
{
blockedsar =0;
SendClientMessageToAll(COLOR_HOTPINK, "/sar Has Been Unblocked.");
}
if(blockedgoto == 1)
{
blockedgoto =0;
SendClientMessageToAll(COLOR_HOTPINK, "/goto Has Been Unblocked.");
}
}
if(randomid == playerid)
{
randomid = -1;
//SetTimer("BonusPlayer", 60*1000, 0);
randmoney =0;
SendClientMessage(playerid, COLOR_SKYBLUE, "* {00B9FF}BONUS: {FF0000} Player {FFFFFF}Has Been Disconnected.");
}
//new pname1 = strtolower(name);
waved[playerid] =0;
foffed[playerid] =0;
farted[playerid] =0;
flashed[playerid] =0;
cried[playerid] =0;
wanked[playerid] =0;
rape[playerid] =0;
cried[playerid] =0;
givemoney[playerid] =0;
KillTimer(login_timer1[playerid]);
KillTimer(register_timer1[playerid]);
KillTimer(ban1[playerid]);
KillTimer(wave_timer1[playerid]);
KillTimer(foff_timer1[playerid]);
KillTimer(fart_timer1[playerid]);
KillTimer(flash_timer1[playerid]);
KillTimer(wank_timer1[playerid]);
KillTimer(RapeRecent1[playerid]);
KillTimer(cry_timer1[playerid]);
pInfo[playerid][Last] =-1;
pInfo[playerid][Adminlevel] =0;
pInfo[playerid][VIPlevel] =0;
pInfo[playerid][Money] =0;
pInfo[playerid][Scores] =0;
pInfo[playerid][Kills] =0;
pInfo[playerid][Deaths] =0;
pInfo[playerid][Pills] =0;
pInfo[playerid][Savedskin] =-1;
warns[playerid] =0;
pInfo[playerid][Last] = -1;
pInfo[playerid][NoPM] = 0;
pInfo[playerid][Drugs] = 0;
//pInfo[playerid][Adisable] =0;
failattemps[playerid] =0;
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(string, sizeof(string), "* %s has left the server. (Time Out)", pname);
case 1: format(string, sizeof(string), "* %s has left the server. (Quit)", pname);
case 2: format(string, sizeof(string), "* %s has left the server. (Kicked!)", pname);
}
//SendClientMessageToAll(COLOR_GREY, string);
print("called at OnPlayerDisconnect");
return 1;
}