Saving System
#1

When a person registers on my server it says their character is saved in console until they leave and when they try to join back, it says incorrect password for them, why?


Saving :

Код:
forward SaveChar(playerid);
public SaveChar(playerid)
{
    if(!IsPlayerConnected(playerid)) return 1;
    GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Cash", GetPlayerMoney(playerid));
    INI_WriteFloat(File,"PosX",PlayerInfo[playerid][pX]);
	INI_WriteFloat(File,"PosY",PlayerInfo[playerid][pY]);
	INI_WriteFloat(File,"PosZ",PlayerInfo[playerid][pZ]);
    INI_WriteInt(File, "Admin", PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Helper", PlayerInfo[playerid][pHelper]);
    INI_WriteInt(File, "Prisoned", PlayerInfo[playerid][pPrisonReason]);
    INI_WriteInt(File, "Wanted", PlayerInfo[playerid][pWantedLevel]);
    INI_WriteInt(File, "Arrests", PlayerInfo[playerid][pArrests]);
    INI_WriteInt(File, "Crimes", PlayerInfo[playerid][pCrimes]);
    INI_WriteInt(File, "Jailed", PlayerInfo[playerid][pJailed]);
    INI_WriteInt(File, "Level", PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Warnings", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "CSR", PlayerInfo[playerid][pShopTech]);
    INI_WriteInt(File, "Order", PlayerInfo[playerid][pOrder]);
    INI_WriteInt(File, "Character", PlayerInfo[playerid][pChar]);
    INI_WriteInt(File, "Interior", PlayerInfo[playerid][pInt]);
    INI_WriteInt(File, "VirtualWorld", PlayerInfo[playerid][pVW]);
    INI_WriteInt(File, "Pot", PlayerInfo[playerid][pPot]);
    INI_WriteInt(File, "Heroin", PlayerInfo[playerid][pHeroin]);
    INI_WriteInt(File, "Crack", PlayerInfo[playerid][pCrack]);
    INI_WriteInt(File, "Meth", PlayerInfo[playerid][pMeth]);
    INI_WriteInt(File, "GiftTime", PlayerInfo[playerid][pGiftTime]);
    INI_WriteInt(File, "PlayingHours", PlayerInfo[playerid][pTime]);
    INI_WriteInt(File, "Exp", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Faction", PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File, "Rank", PlayerInfo[playerid][pRank]);
    INI_WriteInt(File, "Leader", PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File, "Member", PlayerInfo[playerid][pMember]);
    INI_WriteInt(File, "Accept", PlayerInfo[playerid][pAcceptID]);
    INI_WriteInt(File, "FMember", PlayerInfo[playerid][pFMember]);
    INI_WriteInt(File, "Division", PlayerInfo[playerid][pDivision]);
    INI_WriteInt(File, "Restricted", PlayerInfo[playerid][pWRestricted]);
    INI_WriteInt(File, "AGuns", PlayerInfo[playerid][pAGuns]);
    INI_WriteInt(File, "Guns", PlayerInfo[playerid][pGuns]);
    INI_WriteInt(File, "GunAmmo", PlayerInfo[playerid][pGunAmmo]);
    INI_WriteInt(File, "AMSSent", PlayerInfo[playerid][pAMSSent]);
    INI_WriteInt(File, "ReportsAccepted", PlayerInfo[playerid][pReportsAccepted]);
    INI_WriteInt(File, "BadgeNumber", PlayerInfo[playerid][pBadgeNum]);
    INI_Close(File);
    new str[128];
    format(str, sizeof(str), "%s Character has been saved", GetPlayerNameEx(playerid));
    print(str);
	return 1;
}
Reply
#2

I can't see it saving password anywhere.
Try CTRL+H or F and search for underneath
INI_WriteInt(File, "Password"

Or check the userfiles to see if their passwords are saved or any other clues why it wont work properly.
Reply
#3

I have looked in the user files and the passwords are there but when they relog everything in their files turn to 0


http://gyazo.com/6dd319cd10e63eed1d0c8e993a368cf7
Reply
#4

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
I can't see it saving password anywhere.
Try CTRL+H or F and search for underneath
INI_WriteInt(File, "Password"

Or check the userfiles to see if their passwords are saved or any other clues why it wont work properly.
The password shouldn't be saved every time the player disconnects, it should only save once and that is when the player registers.
Can you show me your function where you load the player's data?

EDIT: and your login dialog.
Reply
#5

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	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,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Helper",0);
                INI_WriteInt(File,"Prisoned",0);
                INI_WriteInt(File,"Wanted",0);
                INI_WriteInt(File,"Arrests",0);
                INI_WriteInt(File,"Crimes",0);
                INI_WriteInt(File,"Jailed",0);
                INI_WriteInt(File,"Level",1);
                INI_WriteInt(File,"Warnings",0);
                INI_WriteInt(File,"CSR",0);
                INI_WriteInt(File,"Order",0);
                INI_WriteInt(File,"Character",0);
                INI_WriteInt(File,"Interior",0);
                INI_WriteInt(File,"VirtualWorld",0);
                INI_WriteInt(File,"Pot",0);
                INI_WriteInt(File,"Heroin",0);
                INI_WriteInt(File,"Crack",0);
                INI_WriteInt(File,"Meth",0);
                INI_WriteInt(File,"GiftTime",0);
                INI_WriteInt(File,"PlayingHours",0);
                INI_WriteInt(File,"Exp",0);
                INI_WriteInt(File,"Faction",0);
                INI_WriteInt(File,"Rank",0);
                INI_WriteInt(File,"Leader",0);
                INI_WriteInt(File,"Member",0);
                INI_WriteInt(File,"Accept",0);
                INI_WriteInt(File,"FMember",0);
                INI_WriteInt(File,"Division",0);
                INI_WriteInt(File,"Restricted",0);
                INI_WriteInt(File,"AGuns",0);
                INI_WriteInt(File,"Guns",0);
                INI_WriteInt(File,"GunAmmo",0);
                INI_WriteInt(File,"AMSSent",0);
                INI_WriteInt(File,"ReportsAccepted",0);
                INI_WriteInt(File,"BadgeNumber",0);
                INI_Close(File);
				SetPlayerCameraPos(playerid,1520.2188,-1712.0742,40.5350);
				SetPlayerCameraLookAt(playerid,1478.4708,-1754.7579,16.7400);
				ShowPlayerDialog(playerid, DIALOG_RULES, DIALOG_STYLE_MSGBOX, "Server", " This is the Government HQ where the Mayor/ Governor makes all the financial decisions!\n Los Angeles Life Style Roleplay would like to welcome you to Los Angeles\n and hope you have a smashing time!", "OK","No");
				SetTimerEx("SaveChar", 100, true, "i", playerid);
				GivePlayerMoney(playerid, 10000);
            }
        }
		case DIALOG_LOGIN:
        {
            if(!response) return Kick (playerid);
            if(response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetSpawnInfo(playerid, 0, 299, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ],0, 0, 0, 0, 0, 0, 0);
	                SpawnPlayer(playerid);
	                SetCameraBehindPlayer(playerid);
	                SetTimerEx("SaveChar", 200000, true, "i", playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
            }
		}
 		case DIALOG_RULES:
    	{
			if(!response) return Kick(playerid);
			else
			{
				SetPlayerPos(playerid, 1478.4708,-1754.7579,-10.0);
                SetCameraBehindPlayer(playerid);
			    ShowPlayerDialog(playerid,DIALOG_SHOW_INFO,DIALOG_STYLE_MSGBOX, "{12C1ED}Rules", "{12C1ED}By registering at Los Angeles Life Style Roleplay, you have accepted our policies and rules.", "Okay", "");
			    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Hello, welcome to Los Angeles Life Style Roleplay, this is a new developed server by Callum Riley, if you find any bugs");
			    SendClientMessage(playerid, COLOR_LIGHTBLUE, "please report them to a high administrator, preferbly an Shift Manager +");
			    SendClientMessage(playerid, COLOR_YELLOW, "We hope you enjoy your time here at Los Angeles Life Style Roleplay! Remember: /rules");
			    PlayerInfo[playerid][pX] = 1780.1759;
			    PlayerInfo[playerid][pY] = -1933.6698;
			    PlayerInfo[playerid][pZ] = 13.3859;
			    PlayerInfo[playerid][pCash] = 10000;
				PlayerInfo[playerid][pPot] += 5;
				PlayerInfo[playerid][pCrack] += 6;
				PlayerInfo[playerid][pMeth] += 3;
				PlayerInfo[playerid][pHeroin] += 10;
				PlayerInfo[playerid][pExp] += 3;
				PlayerInfo[playerid][pTime] += 3;
				PlayerInfo[playerid][pChar] = 170;
    			SetSpawnInfo(playerid, 0, 299, 1780.1759,-1933.6698,13.3859,356.5534, 0, 0, 0, 0, 0, 0);
			}
		}
	}
	return 1;
}
That is my OnDialogResponse..
Reply
#6

About your DIALOG_REGISTER
Basically what you do is:
Write A in the file with value : 0
Write B in the file with value : 2

Then you call in the saving function that saves the player data. That function does this:
Write A in the file with value : [whatever value the variable has at that very moment]
Write B in the file with value : [whatever value the variable has at that very moment]

Since the player just registered, you overwrite the file twice with the exact same data. Not wrong, but a useless thing to do.

Can you show me the following function?:
pawn Код:
public LoadUser_data(playerid, name[], value[])
Reply
#7

I do not understand

Quote:

About your DIALOG_REGISTER
Basically what you do is:
Write A in the file with value : 0
Write B in the file with value : 2

Then you call in the saving function that saves the player data. That function does this:
Write A in the file with value : [whatever value the variable has at that very moment]
Write B in the file with value : [whatever value the variable has at that very moment]

Код:
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
	INI_Int("Password", PlayerInfo[playerid][pPass]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Float("PosX", PlayerInfo[playerid][pX]);
    INI_Float("PosY", PlayerInfo[playerid][pY]);
    INI_Float("PosZ", PlayerInfo[playerid][pZ]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Helper",PlayerInfo[playerid][pHelper]);
    INI_Int("Prisoned",PlayerInfo[playerid][pPrisonReason]);
    INI_Int("Wanted",PlayerInfo[playerid][pWantedLevel]);
    INI_Int("Arrests",PlayerInfo[playerid][pArrests]);
    INI_Int("Crimes",PlayerInfo[playerid][pCrimes]);
    INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Warnings",PlayerInfo[playerid][pWarns]);
    INI_Int("CSR",PlayerInfo[playerid][pShopTech]);
	INI_Int("Order",PlayerInfo[playerid][pOrder]);
	INI_Int("Character",PlayerInfo[playerid][pChar]);
	INI_Int("Interior",PlayerInfo[playerid][pInt]);
	INI_Int("VirtualWorld",PlayerInfo[playerid][pVW]);
	INI_Int("Pot",PlayerInfo[playerid][pPot]);
	INI_Int("Heroin",PlayerInfo[playerid][pHeroin]);
	INI_Int("Meth",PlayerInfo[playerid][pMeth]);
	INI_Int("GiftTime",PlayerInfo[playerid][pGiftTime]);
	INI_Int("PlayingHours",PlayerInfo[playerid][pTime]);
	INI_Int("Exp",PlayerInfo[playerid][pExp]);
	INI_Int("Faction",PlayerInfo[playerid][pTeam]);
	INI_Int("Rank",PlayerInfo[playerid][pRank]);
	INI_Int("Leader",PlayerInfo[playerid][pLeader]);
	INI_Int("Member",PlayerInfo[playerid][pMember]);
	INI_Int("Accept",PlayerInfo[playerid][pAcceptID]);
	INI_Int("FMember",PlayerInfo[playerid][pFMember]);
	INI_Int("Division",PlayerInfo[playerid][pDivision]);
	INI_Int("Restricted",PlayerInfo[playerid][pWRestricted]);
	INI_Int("AGuns",PlayerInfo[playerid][pAGuns]);
	INI_Int("Guns",PlayerInfo[playerid][pGuns]);
	INI_Int("GunAmmo",PlayerInfo[playerid][pGunAmmo]);
	INI_Int("AMSSent",PlayerInfo[playerid][pAMSSent]);
	INI_Int("ReportsAccepted",PlayerInfo[playerid][pReportsAccepted]);
	INI_Int("BadgeNumber",PlayerInfo[playerid][pBadgeNum]);
    return 1;
}
Reply
#8

This under the register dialog:
pawn Код:
SetTimerEx("SaveChar", 100, true, "i", playerid);
Is useless. It does the exact same thing as for example this:
pawn Код:
INI_WriteInt(File,"BadgeNumber",0);
Are you checking if the UserPath exists under OnPlayerRequestClass? If so, show me that code as well.
Reply
#9

This is my OnPLayerRequestClass
Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetSpawnInfo(playerid, 0, 120, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ], 0, 0, 0, 0, 0, 0, 0);
	SpawnPlayer(playerid);
	return 1;
}
Reply
#10

Do you have this somewhere:
pawn Код:
if(fexist(UserPath(playerid)))
{
    ShowPlayerDialog(/*Dialog*/);
}
else
{
    ShowPlayerDialog(/*Dialog*/);
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)