07.09.2012, 11:08
(
Last edited by Guitar; 07/09/2012 at 12:00 PM.
Reason: Added the codes
)
Hey guys,
My saving system (Using Y_INI and tutorial from Kush), the problem started lately, it wasn't there .. I don't know how to fix it. The password saves as 0 if a player disconnects/quits the server. I need somebody to help me over TeamViewer.
This is when the player registers:
This is when the player quits(The problem happens when the player quits/leaves the server:
Another "SavePlayerStats" for for example commands like /setlevel etc.. to save the level.
My saving system (Using Y_INI and tutorial from Kush), the problem started lately, it wasn't there .. I don't know how to fix it. The password saves as 0 if a player disconnects/quits the server. I need somebody to help me over TeamViewer.
This is when the player registers:
pawn Code:
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"PlayerData");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",-1);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Zombie",0);
INI_WriteInt(File,"Score",1);
INI_WriteInt(File,"Team",-1);
INI_WriteInt(File,"Registered",1);
INI_WriteInt(File,"Logged",1);
PlayerInfo[playerid][pTeam] = -1;
PlayerInfo[playerid][pAdmin] = -1;
//PlayerInfo[playerid][pPass] = (inputtext);
INI_Close(File);
//SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
//SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
}
}
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][pLogged] = 0;
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"PlayerData");
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Registered",PlayerInfo[playerid][pReg]);
INI_WriteInt(File,"Logged",PlayerInfo[playerid][pLogged]);
INI_Close(File);
return 1;
}
pawn Code:
forward SavePlayerStats(playerid);
public SavePlayerStats(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"PlayerData");
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Registered",PlayerInfo[playerid][pReg]);
INI_WriteInt(File,"Logged",PlayerInfo[playerid][pLogged]);
INI_Close(File);
print("\n----------------------------------");
print(" Players' accounts saved! On SavePlayerStats");
print("----------------------------------\n");
return 1;
}