pawn Код:
new LoadDatabase[MAX_PLAYERS];
forward AccessDatabase(playerid);
public AccessDatabase(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(fexist(Path(playerid)))
{
new pRLoginMSG[750];
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
format(pRLoginMSG, sizeof(pRLoginMSG), "Welcome back %s, Please Login", pName);
ShowPlayerDialog(playerid, prlogin, DIALOG_STYLE_PASSWORD,"{FF0000}>> {00C8FF}Account Login{FFFFFF}:", pRLoginMSG, "Login", "Leave");
}
else
{
new pRRegMSG[750];
format(pRRegMSG, sizeof(pRRegMSG), "Welcome back %s, Please Register", pName);
ShowPlayerDialog(playerid, prregister, DIALOG_STYLE_PASSWORD, "{FF0000}>> {00C8FF}Account Registration{FFFFFF}:", pRRegMSG, "Register", "Leave");
}
return 1;
}
public OnPlayerConnect(playerid)
{
LoadDatabase[playerid] = 1;
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(LoadDatabase[playerid]==1)
{
SetPlayerSkin(playerid, pInfo[playerid][pRSkin]);
SetWeather(1);
SetWorldTime(0);
SetPlayerCameraPos(playerid, 1481.000, -1779.000, 157.000);
SetPlayerCameraLookAt(playerid,1481.000, -1788.000, 155.000);
AccessDatabase(playerid);
return 1;
}
return 1;
}
EDIT :-
OnPlayerDisconnect Callback -
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Status",pInfo[playerid][pRStatus]);
INI_WriteInt(file,"Donator",pInfo[playerid][pRDonator]);
INI_WriteInt(file,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][pRKills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][pRDeaths]);
INI_Close(file);
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
return 1;
}