24.09.2012, 17:44
Try this on OnPlayerDisconnect
Fixed your small mistake
Make sure.. there is Money in your enumerator.
Try it ..it must work.
by chance it doesn't worked please have a look at this tutorial : https://sampforum.blast.hk/showthread.php?tid=267808
I learned SII from there..
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(PInfo[playerid][Logged] == 1)
{
PInfo[playerid][Logged] = 0;
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME], file[64];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "** %s has left United Kingdom TDM", name);
SendClientMessageToAll(-1, string);
format(file, sizeof file, "Admin/%s.ini", name);
new scores = GetPlayerScore(playerid), //Created extra var to check it.
new money = GetPlayerMoney(playerid);
INI_Open(file);
INI_WriteInt("Level", PInfo[playerid][Level]);
INI_WriteInt("Score", scores);
INI_WriteInt("Money",money);
INI_Save();
INI_Close();
}
return 1;
}
pawn Код:
CMD:login(playerid,params[])
{
if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,-4,"You are already logged in!");//Checking if the player is logged in, if he is, it won't allow him to login
new password[23],password2[23];//Creating a variable to store the password, and another one to store the password from the user's file.
if(sscanf(params,"s[23]",password)) return SendClientMessage(playerid,-1,"USAGE: /login <password>");//Here we're checking if the player inputs any password, if not, it will return to him a message saying the proper usage.
new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
GetPlayerName(playerid,PlayerName,sizeof PlayerName);
format(file,sizeof file,"Admin/%s.ini",PlayerName);
if(!fexist(file)) return SendClientMessage(playerid,-4,"Please use /register");//Checking if the player is not registered, again....
INI_Open(file);//Opening the file with SII include
INI_ReadString(password2,"Password");
if(strcmp(password,password2) != 0) return SendClientMessage(playerid,-4,"Wrong password!"),INI_Close();//Checking if he inputted the correct password, if not, retrieve him a message and closing the file;
PInfo[playerid][Level] = INI_ReadInt("Level");//Setting the admin level variable, to the one thats in his file.
PInfo[playerid][Score] = INI_ReadInt("Score"); // Setting the score of player
PInfo[playerid][Money] = INI_ReadInt("Money"); // Setting the score of player
INI_Close();//"Closing the file", that means that we're not using it anymore :P
SetPlayerScore(playerid, PInfo[playerid][Score]);
SendClientMessage(playerid,-1,"You have been successfully logged in!");
PInfo[playerid][Logged] = 1;//Setting the logged in variable to 1
return 1;
}
Try it ..it must work.
by chance it doesn't worked please have a look at this tutorial : https://sampforum.blast.hk/showthread.php?tid=267808
I learned SII from there..