27.04.2014, 06:37
So I'm trying to get a players wanted level and cash to load upon logging in successfully. I'd just like to clarify that it does WRITE properly in the players file, but it doesn't load when they actually log in which is a bit strange. It seems whenever a player spawns, there money gets resetted for some awkward reason. I don't have any money variables or anything at all under OnPlayerSpawn.
Here's the relevant code you'll need to try to help. This is when they successfully register OR login. Thanks for any help.
Here's the relevant code you'll need to try to help. This is when they successfully register OR login. Thanks for any help.
pawn Код:
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
{
if(!strlen(inputtext))
{
SCM(playerid, -1, "Please enter a password.");
ShowPlayerDialog(playerid,DIALOG_REGISTER, DIALOG_STYLE_INPUT, "You're not registered.", "Enter a password to register at A-CnR.", "Enter", "Exit");
return 1;
}
new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file, "Player Data");
INI_WriteInt(file, "Password", udb_hash(inputtext));
INI_WriteInt(file, "Admin", 0);
INI_WriteInt(file, "Score", 0);
INI_WriteInt(file, "Money", 0);
INI_WriteInt(file, "Vip", 0);
INI_WriteInt(file, "Team", 0); //temp
INI_WriteInt(file, "Skin", 0);
INI_WriteInt(file, "Kills", 0);
INI_WriteInt(file, "Deaths", 0);
INI_WriteInt(file, "Wanted", 0); //not wanted upon register.
INI_WriteInt(file, "HitAmount", 0); //Doesn't have a bounty
INI_Close(file);
new string[128];
format(string,sizeof(string), "You've registered with the password %s. You have recieved 25$ for starting cash.",inputtext);
SCM(playerid, -1, string);
GivePlayerMoney(playerid, 25);
SaveAccount(playerid);
PlayerSpawned[playerid] = true;
ShowPlayerDialog(playerid, DIALOG_TEAM, DIALOG_STYLE_LIST, "Select a team.", "Army\nBandit", "Select", "");
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
{
if(!strlen(inputtext))
{
SCM(playerid, -1, "Enter your password to login.");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Welcome to A-CnR.", "{00BB00}Enter password", "Enter", "Quit");
return 1;
}
if(udb_hash(inputtext) == pInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadAccount_data", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, pInfo[playerid][pScore]);
SetPlayerSkin(playerid, pInfo[playerid][pSkin]);
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
PlayerSpawned[playerid] = true;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{AE0000}Incorrect password.", "Enter password", "Enter", "Quit");
}