if(!response) return Kick(playerid);
public OnPlayerDisconnect(playerid,reason)
{
pInfo[playerid][pRStatus] = 0;
pInfo[playerid][pRDonator] = 0;
pInfo[playerid][pRCash] = 0;
pInfo[playerid][pRScores] = 0;
pInfo[playerid][pRKills] = 0;
pInfo[playerid][pRDeaths] = 0;
//... codes
return 1;
}
if(dialogid == dlogin) //If dialog id is a login dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
new hashpass[129]; //Will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
{//then
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
}
else //If they've entered an incorrect password
{//then
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteInt(file,"Status",pInfo[playerid][pRStatus]); INI_WriteInt(file,"Money",GetPlayerMoney(playerid)); INI_WriteInt(file,"Scores",GetPlayerScore(playerid)); INI_WriteInt(file,"Kills",pInfo[playerid][pRKills]); INI_WriteInt(file,"Deaths",pInfo[playerid][pRDeaths]); INI_WriteInt(file,"Donator",pInfo[playerid][pRDonator]); INI_Close(file);
Under OnPlayerDisconnect
Код:
new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteInt(file,"Status",pInfo[playerid][pRStatus]); INI_WriteInt(file,"Money",GetPlayerMoney(playerid)); INI_WriteInt(file,"Scores",GetPlayerScore(playerid)); INI_WriteInt(file,"Kills",pInfo[playerid][pRKills]); INI_WriteInt(file,"Deaths",pInfo[playerid][pRDeaths]); INI_WriteInt(file,"Donator",pInfo[playerid][pRDonator]); INI_Close(file); |
pInfo[playerid][pRStatus] = 0; ....
the lines like these^ should be at bottom of OnPlayerDisconnect not at top of it it should be after you save player's data and show the full OnPlayerDisconnect to us |
new bool: logged[MAX_PLAYERS]; // var
if(dialogid == dlogin) //If dialog id is a login dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
new hashpass[129]; //Will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
{//then
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
logged[playerid] = true; // set it here
}
else //If they've entered an incorrect password
{//then
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
return 1;
}
}
}
public OnPlayerDisconnect(playerid,reason)
{
if(logged[playerid])
{
pInfo[playerid][pRStatus] = 0;
pInfo[playerid][pRDonator] = 0;
pInfo[playerid][pRCash] = 0;
pInfo[playerid][pRScores] = 0;
pInfo[playerid][pRKills] = 0;
pInfo[playerid][pRDeaths] = 0;
//... codes
}
return 1;
}
// At top
new IsSpawned[MAX_PLAYERS];
// OnPlayerConnect
IsSpawned[playerid] = 0;
// OnPlayerSpawn
IsSpawned[playerid] = 1;
// OnPlayerDisconnect
if (IsSpawned[playerid] == 1)
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Status",pInfo[playerid][pRStatus]);
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
INI_WriteInt(file,"Kills",pInfo[playerid][pRKills]);
INI_WriteInt(file,"Deaths",pInfo[playerid][pRDeaths]);
INI_WriteInt(file,"Donator",pInfo[playerid][pRDonator]);
INI_Close(file);
return 1;
}