Jump to content
  • 0

Problema logare


muresan_emanuel2001

Question

De curand am inceput un gamemode de la 0, si am folosit tutorialul de login/register de la "Tutoriale" de pe acest forum.

Singura problema este ca, in momentul in care playerul greseste parola, toate datele se reseteaza, inafara de ID/PAROLA/LEVEL/IP;

respectiv, in momentul in care bag parola corecta dupa ce am bagat parola gresita, se reia procesul de inregistrare.

 

function OnLogin(playerid)
{
    new rows, fields, temporar[200];
	cache_get_data(rows, fields);
    if(rows)
    {
        cache_get_field_content(0, "Parola",temporar), format(playerData[playerid][pPassword], 25, temporar);
        playerData[playerid][pID] 			= cache_get_field_content_int(0, "id");
        playerData[playerid][pLevel]	 	= cache_get_field_content_int(0, "Level");
        playerData[playerid][pAdmin]        = cache_get_field_content_int(0, "Admin");
        playerData[playerid][pMember]       = cache_get_field_content_int(0, "Member");
        playerData[playerid][pLeader]       = cache_get_field_content_int(0, "Leader");
        playerData[playerid][pSkin]         = cache_get_field_content_int(0, "Skin");
        playerData[playerid][pRegistred]  	= cache_get_field_content_int(0, "Registred");
        playerData[playerid][pAge]          = cache_get_field_content_int(0, "Age");
        playerData[playerid][pSex]          = cache_get_field_content_int(0, "Sex");
        playerData[playerid][pCash]         = cache_get_field_content_int(0, "Cash");
        playerData[playerid][pAdmin]        = cache_get_field_content_int(0, "Admin");
		printf("%s s-a logat pe server.",GetName(playerid));
		
		SetPlayerScore(playerid, playerData[playerid][pLevel]);
		SetPlayerSkin(playerid, playerData[playerid][pSkin]);
		ResetPlayerMoney(playerid);
		GivePlayerMoney(playerid, playerData[playerid][pCash]);
		SpawnPlayer(playerid);
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");// ii va da dialogul cu mesajul specific.
    }
	//ClearChat(playerid);
    if(playerData[playerid][pRegistred] == 0)
    {
        playerData[playerid][pLevel] = 1;
        Update(playerid, pLevelu);
    }
    if(playerData[playerid][pAdmin] >= 1)
    {
        SendClientMessage(playerid, COLOR_GRAD2, "[SF:RPG] Te-ai logat pe server ca Administrator.");
    }
	if(playerData[playerid][pLeader] >= 1)
	{
		new string[256];
		format(string, sizeof(string), "[SF:RPG] Ai lider la factiunea %s.", StaticFaction[playerData[playerid][pLeader]][fName]);
		SendClientMessage(playerid, COLOR_GRAD2, string);
	}
    gLogged[playerid] = 1;
    return 1;

}
case DIALOG_REGISTER:
        {
            if(!response)
                    return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
                        return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Introdu-ti o parola pentru a te inregistra pe server! n", "Inregistreaza", "Exit");

                mysql_format(handle, query, sizeof(query), "INSERT INTO conturi (Nume, Parola) VALUES ('%s', '%e')", GetName(playerid), inputtext);
                mysql_query(handle, query);
                SpawnPlayer(playerid);
            }
            return 1;
        }
        case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext))
                        return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Parola incorecta!", "Te rog sa iti introduci parola corecta, pentru a te loga pe server.", "Logare", "Exit");
                mysql_format(handle, query, sizeof(query), "SELECT * FROM `conturi` WHERE `Nume`='%e' AND `Parola` = '%e'", GetName(playerid),inputtext);
				mysql_tquery(handle, query, "OnLogin", "i", playerid);
            }
            return 1;
        }

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.