SA-MP Forums Archive
Can't login after /q. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can't login after /q. (/showthread.php?tid=423822)



Can't login after /q. - Ceez - 19.03.2013

Hey, I am currently using Blueberry Prison Roleplay script.
I have uploaded it on VoltHost - players started joining and suddenly I seen playerbase is dropping.
I /q'ed for the night, woke up and tried to login and I just couldn't, I write in the password and nothing happens.

Here's my DIALOG_LOGIN - It's the dialog that opens once you connect to the server.
Код:
if(dialogid == DIALOG_LOGIN)
    {
        if(!response)
        {
            SendClientMessage(playerid, GREY, "You didn't log in.");
		    Kick(playerid);
		}
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Log In","You have entered an invalid password.\nPlease input this account password to log in.","Login","Quit");
            }
            if(INI_Open(Accounts(playerid)))
		    {
                INI_ReadString(PlayerStat[playerid][Password],"Password",20);
		        if(strcmp(inputtext,PlayerStat[playerid][Password],false))
				{
				   if(PlayerStat[playerid][WrongPw] == 1)
				   {
                       SendClientMessage(playerid, GREY, "You have been kicked for not entering the correct password.");
				       Kick(playerid);
				   }
				   else
				   {
					   ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Log In","You have entered an incorrect password.\nPlease input this account password to log in.","Login","Quit");
                       SendClientMessage(playerid, GREY, "You only have one last chance to enter this account password or you'll get kicked.");
                       PlayerStat[playerid][WrongPw] = 1;
                       TogglePlayerControllable(playerid, false);
				       SetPlayerInterior(playerid, 0);
                       SetPlayerVirtualWorld(playerid, playerid+0);
                       SetSpawnInfo(playerid, 0, 0, 19.4895,-331.0008,26.1236 , 0, 0, 0, 0, 0, 0, 0);
                       SpawnPlayer(playerid);
                       SetPlayerCameraPos(playerid, 1752.4188, -1527.8185, 20.2753);
                       SetPlayerCameraLookAt(playerid, 1753.0366, -1528.6036, 19.8853);
				   }
                }
                else
				{

				    new str[128];
				    format(str, sizeof(str), "Welcome Back %s, your last login was on %d/%d/%d at %d:%d:%d.", GetOOCName(playerid), PlayerStat[playerid][LastLoginYear], PlayerStat[playerid][LastLoginMonth], PlayerStat[playerid][LastLoginDay], PlayerStat[playerid][LastLoginHour], PlayerStat[playerid][LastLoginMinute], PlayerStat[playerid][LastLoginSecond]);
				    SendClientMessage(playerid, GREEN, str);
				    format(str, sizeof(str), "~w~Welcome Back ~n~~y~ %s", GetOOCName(playerid));
	                GameTextForPlayer(playerid, str, 3000, 1);
				    SendClientMessage(playerid, GREEN, SERVER_MOTD);

				    new Hour, Minute, Second;
	   	            new Day, Month, Year;
                    gettime(Hour, Minute, Second);
                    getdate(Year, Month, Day);
                    PlayerStat[playerid][LastLoginSecond] = Second;
                    PlayerStat[playerid][LastLoginMinute] = Minute;
                    PlayerStat[playerid][LastLoginHour] = Hour;
                    PlayerStat[playerid][LastLoginDay] = Day;
                    PlayerStat[playerid][LastLoginMonth] = Month;
	                PlayerStat[playerid][LastLoginYear] = Year;
                    INI_WriteInt("LastLoginSecond",PlayerStat[playerid][LastLoginSecond]);
                    INI_WriteInt("LastLoginMinute",PlayerStat[playerid][LastLoginMinute]);
                    INI_WriteInt("LastLoginHour",PlayerStat[playerid][LastLoginHour]);
                    INI_WriteInt("LastLoginDay",PlayerStat[playerid][LastLoginDay]);
                    INI_WriteInt("LastLoginMonth",PlayerStat[playerid][LastLoginMonth]);
                    INI_WriteInt("LastLoginYear",PlayerStat[playerid][LastLoginYear]);

                    if(PlayerStat[playerid][GangID] >= 1)
					{
                        format(str, sizeof(str), "Gang MOTD: %s", GangStat[PlayerStat[playerid][GangID]][MOTD]);
				        SendClientMessage(playerid, GangStat[PlayerStat[playerid][GangID]][Color], str);
				    }

				    PlayerStat[playerid][Logged] = 1;
				    LoadPlayerData(playerid);

				    INI_Save();
                    INI_Close();

				}
            }
        }
	}
Early thanks!

EDIT - Even if I put a wrong password, it closes the Dialog and wont do anything, no error,nothing.
Thanks!



Re: Can't login after /q. - Jstylezzz - 19.03.2013

Can you check if the data is still correct in the database?
If not, there has to be a problem in the saving when the player disconnects.


Re: Can't login after /q. - Ceez - 19.03.2013

It's all valid in scriptfiles/accounts/accountname.txt
I guess it is actually something with the OnPlayerDisconnect

Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(!IsPlayerNPC(playerid))
	{
        SavePlayerData(playerid);
		new str[128];
        switch(reason)
	    {
		    case 0:
			{
			    format(str, sizeof(str), "%s has left the server (timeout).", GetOOCName(playerid));
			    SendNearByMessage(playerid, WHITE, str, 4);
			}
            case 1:
			{
				format(str, sizeof(str), "%s has left the server (leaving).", GetOOCName(playerid));
				SendNearByMessage(playerid, WHITE, str, 4);
			}
            case 2:
            {
				format(str, sizeof(str), "%s has left the server (kicked/banned).", GetOOCName(playerid));
				SendNearByMessage(playerid, WHITE, str, 4);
            }
		}
		if(PlayerStat[playerid][Logged] == 1)
		{
			for(new d = 0; d < MAX_ATTACHED_OBJECTS; d++)
            {
                if(IsPlayerAttachedObjectSlotUsed(playerid, d))
	            {
	                RemovePlayerAttachedObject(playerid, d);
	            }
	        }
	        for(new i = 0; i<MAX_PLAYERS; i++)
	        {
		        if(PlayerStat[playerid][FightTimer] >= 1)
		        {
		            PlayerStat[i][FightTimer] = 0;
		            format(str, sizeof(str), "Boxing Match is over (%s (ID: %d) Disconnected)", GetOOCName(playerid), playerid);
			        SendClientMessage(playerid, GREEN, str);
		        }
		        if(PlayerStat[i][HandShakeTarget] == playerid)
		        {
		            PlayerStat[i][HandShakeTarget] = -1;
		        }
	        }
	        if(PlayerStat[playerid][Cuffed] == 1)
		    {
				PlayerStat[playerid][AdminPrisoned] = 1;
				PlayerStat[playerid][AdminPrisonedTime] = 1080;
			}
			if(PlayerStat[playerid][BeingSpeced] == 1)
            {
                TogglePlayerSpectating(PlayerStat[playerid][BeingSpecedBy], false);
            }
			PlayerStat[playerid][Logged] = 0;
	    }
	}
    return 1;
}
Any ideas?


Re: Can't login after /q. - Jstylezzz - 19.03.2013

Try to recreate the problem. When you're not able to log in, check your playerfile. If all data is still like it should be, like cash and stuff, and the password is not empty, it's something strange in the OnPlayerConnect I think..
((Make sure to hash the passwords, just saying to prevent trouble.))


Re: Can't login after /q. - Ceez - 19.03.2013

I now realised that it happens after a while, not immidiately after /q
And it happens to the whole server, not just one player
Ideas anybody? Please?


Re: Can't login after /q. - Jstylezzz - 19.03.2013

Do you have any auto save timer or something? If yes, the values might be reset to 0 because of faulty code.
Above your saving code make sure to add if(!IsPlayerConnected(playerid)) return 1;, replace playerid with the variable used for playerid if needed.


Re: Can't login after /q. - Ceez - 19.03.2013

There's no auto saving timer man.. you have any idea about other possible causes?


Re: Can't login after /q. - Jstylezzz - 19.03.2013

Can you show me your SavePlayerData callback?


Re: Can't login after /q. - Ceez - 19.03.2013

Код:
public SavePlayerData(playerid)
{
    if(INI_Open(Accounts(playerid)))
    {
		if(PlayerStat[playerid][FullyRegistered] == 1)
		{
            INI_WriteInt("Age",PlayerStat[playerid][Age]);
            INI_WriteInt("Gender",PlayerStat[playerid][Gender]);
            INI_WriteInt("PlayingHours",PlayerStat[playerid][PlayingHours]);
            INI_WriteString("LastIP",PlayerStat[playerid][LastIP]);
            
            INI_WriteInt("Money",PlayerStat[playerid][Money]);
            INI_WriteInt("Paycheck",PlayerStat[playerid][Paycheck]);
            INI_WriteInt("LockerMoney",PlayerStat[playerid][LockerMoney]);
            INI_WriteInt("LastSkin",PlayerStat[playerid][LastSkin]);
            INI_WriteString("Reason",PlayerStat[playerid][Reason]);
            INI_WriteString("Accent",PlayerStat[playerid][Accent]);
            
            GetPlayerPos(playerid, PlayerStat[playerid][LastX], PlayerStat[playerid][LastY], PlayerStat[playerid][LastZ]);
		    GetPlayerFacingAngle(playerid, PlayerStat[playerid][LastA]);
		    PlayerStat[playerid][LastInt] = GetPlayerInterior(playerid);
		    PlayerStat[playerid][LastVW] = GetPlayerVirtualWorld(playerid);
		    
            INI_WriteFloat("LastX",PlayerStat[playerid][LastX]);
            INI_WriteFloat("LastY",PlayerStat[playerid][LastY]);
            INI_WriteFloat("LastZ",PlayerStat[playerid][LastZ]);
            INI_WriteFloat("LastA",PlayerStat[playerid][LastA]);
            INI_WriteInt("LastInt",PlayerStat[playerid][LastInt]);
            INI_WriteInt("LastVW",PlayerStat[playerid][LastVW]);
            
            INI_WriteInt("FullyRegistered",PlayerStat[playerid][FullyRegistered]);
            INI_WriteInt("TogOOC",PlayerStat[playerid][TogOOC]);
            INI_WriteInt("TogPM",PlayerStat[playerid][TogPM]);
            
            INI_WriteInt("JobID",PlayerStat[playerid][JobID]);
            INI_WriteInt("HoursInJob",PlayerStat[playerid][HoursInJob]);
            INI_WriteInt("AbleToCollectGarbage",PlayerStat[playerid][AbleToCollectGarbage]);
            INI_WriteInt("AbleToCleanTables",PlayerStat[playerid][AbleToCleanTables]);
            INI_WriteInt("AbleToCollectFood",PlayerStat[playerid][AbleToCollectFood]);
            INI_WriteInt("JobID1ReloadTime",PlayerStat[playerid][JobID1ReloadTime]);
            INI_WriteInt("JobID2ReloadTime",PlayerStat[playerid][JobID2ReloadTime]);
            INI_WriteInt("JobID3ReloadTime",PlayerStat[playerid][JobID3ReloadTime]);
            
            INI_WriteInt("AdminLevel",PlayerStat[playerid][AdminLevel]);
            INI_WriteInt("Muted",PlayerStat[playerid][Muted]);
            INI_WriteInt("MuteTime",PlayerStat[playerid][MuteTime]);
            INI_WriteInt("AdminPrisoned",PlayerStat[playerid][AdminPrisoned]);
		    INI_WriteInt("AdminPrisonedTime",PlayerStat[playerid][AdminPrisonedTime]);
			INI_WriteInt("Banned",PlayerStat[playerid][Banned]);
			INI_WriteInt("TimesKicked",PlayerStat[playerid][TimesKicked]);
		    INI_WriteInt("TimesBanned",PlayerStat[playerid][TimesBanned]);
            INI_WriteInt("Warnings",PlayerStat[playerid][Warnings]);
            INI_WriteString("Warn1",PlayerStat[playerid][Warn1]);
            INI_WriteString("Warn2",PlayerStat[playerid][Warn2]);
            
            INI_WriteInt("HelperLevel",PlayerStat[playerid][HelperLevel]);
            INI_WriteInt("hMuted",PlayerStat[playerid][hMuted]);
            INI_WriteInt("HelpmeReloadTime", PlayerStat[playerid][HelpmeReloadTime]);
            
            INI_WriteInt("LastLoginSecond",PlayerStat[playerid][LastLoginSecond]);
            INI_WriteInt("LastLoginMinute",PlayerStat[playerid][LastLoginMinute]);
            INI_WriteInt("LastLoginHour",PlayerStat[playerid][LastLoginHour]);
            INI_WriteInt("LastLoginDay",PlayerStat[playerid][LastLoginDay]);
            INI_WriteInt("LastLoginMonth",PlayerStat[playerid][LastLoginMonth]);
            INI_WriteInt("LastLoginYear",PlayerStat[playerid][LastLoginYear]);
            
            INI_WriteInt("GangID",PlayerStat[playerid][GangID]);
            INI_WriteInt("GangRank",PlayerStat[playerid][GangRank]);
            INI_WriteInt("GetWeapReloadTime", PlayerStat[playerid][GetWeapReloadTime]);
            INI_WriteInt("GetDrugsReloadTime", PlayerStat[playerid][GetDrugsReloadTime]);
            INI_WriteInt("Pot", PlayerStat[playerid][Pot]);
            INI_WriteInt("Crack", PlayerStat[playerid][Crack]);
            INI_WriteInt("Slot0", PlayerStat[playerid][Slot0]);
            INI_WriteInt("Slot1", PlayerStat[playerid][Slot1]);
            INI_WriteInt("Slot2", PlayerStat[playerid][Slot2]);
            INI_WriteInt("Slot3", PlayerStat[playerid][Slot3]);
		    INI_WriteInt("Slot4", PlayerStat[playerid][Slot4]);
		    INI_WriteInt("Slot5", PlayerStat[playerid][Slot5]);
		    INI_WriteInt("Slot6", PlayerStat[playerid][Slot6]);
	    	INI_WriteInt("Slot7", PlayerStat[playerid][Slot7]);
    		INI_WriteInt("Slot8", PlayerStat[playerid][Slot8]);
     		INI_WriteInt("Slot9", PlayerStat[playerid][Slot9]);
    		INI_WriteInt("Slot10", PlayerStat[playerid][Slot10]);
    		INI_WriteInt("Slot11", PlayerStat[playerid][Slot11]);
    		INI_WriteInt("UsingCrackReloadTime",PlayerStat[playerid][UsingCrackReloadTime]);
	     	INI_WriteInt("UsingPotReloadTime",PlayerStat[playerid][UsingPotReloadTime]);
    		
    		
            INI_WriteInt("FactionID",PlayerStat[playerid][FactionID]);
	     	INI_WriteInt("FactionRank",PlayerStat[playerid][FactionRank]);
	     	INI_WriteInt("Tased",PlayerStat[playerid][Tased]);
		    INI_WriteInt("InIsolatedCell",PlayerStat[playerid][InIsolatedCell]);
		    INI_WriteInt("InIsolatedCellTime",PlayerStat[playerid][InIsolatedCellTime]);
		    INI_WriteInt("Cuffed",PlayerStat[playerid][Cuffed]);
		    
	     	INI_WriteFloat("Health",PlayerStat[playerid][Health]);
		    INI_WriteFloat("Armour",PlayerStat[playerid][Armour]);
		    INI_WriteFloat("DeathPosX",PlayerStat[playerid][DeathPosX]);
		    INI_WriteFloat("DeathPosY",PlayerStat[playerid][DeathPosY]);
		    INI_WriteFloat("DeathPosZ",PlayerStat[playerid][DeathPosZ]);
		    INI_WriteInt("Dead",PlayerStat[playerid][Dead]);
		    INI_WriteInt("InHospital",PlayerStat[playerid][InHospital]);
		    INI_WriteInt("Deaths",PlayerStat[playerid][Deaths]);
		    INI_WriteInt("Kills",PlayerStat[playerid][Kills]);
		    
		    INI_WriteInt("Lighter",PlayerStat[playerid][Lighter]);
	     	INI_WriteInt("Cigars",PlayerStat[playerid][Cigars]);
	     	
	     	INI_WriteInt("HasCell", PlayerStat[playerid][HasCell]);
	     	INI_WriteInt("Cell",PlayerStat[playerid][Cell]);
        
            INI_Save();
            INI_Close();
        }
        else return 1;
    }
	return 1;
}
Thanks ALOT for helping and that you keep on replying to my questions man, real appriciated.


Re: Can't login after /q. - Jstylezzz - 19.03.2013

Just so I don't give any faulty solutions.. This happens randomly, or everytime someone exits the server?
Check where SavePlayerData is used, and check if it's used in a loop somewhere (this can cause it for all players to screw up).