Jump to content
  • 0

Problema LogIn


Punct.

Question

Nick: Punct.

Problema: Cand ma loghez pe server, orice parola as introduce in dialog ma logheaza.

Erori / warnings: -

Lini/script:

[pawn]

if(strcmp(inputtext, PlayerInfo[playerid][pPassword]) == 0)

//if(!strcmp(hpass, PlayerInfo[playerid][pPassword])) //remember we have loaded player's password into this variable, PlayerInfo[playerid][pPassword] earlier. Now let's use it to compare the hashed password with password that we load

{ //if the hashed password matches with the loaded password from database

mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);

mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);

}

else //if the hashed password didn't match with the loaded password(PlayerInfo[playerid][pPassword])

{

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Parola introdusa este incorecta.", "Login", "Kick");

}

[/pawn]

Ai incercat sa rezolvi singur ?: da..

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

In primul rand, [pawn]if(strcmp(inputtext, PlayerInfo[playerid][pPassword]) == 0)[/pawn] asta nu e bine aici. Tu inca nu ai luat datele din baza de date, asa-i? Deci de aici -> ca parola nu exista. Poti face in doua moduri:

1. Sa faci o functie care selecteaza din baza de date username-ul si parola, si in thread sa cheme alta functie care ii spune daca e bine sau nu.

2. Sa faci direct cu "SELECT * FROM `BAZADEDATE` WHERE `username`='%e' AND `password`='%e'" si sa vezi direct daca are randuri sau nu.

Link to comment
Share on other sites

Nu e bine asa?: [pawn]public OnAccountCheck(playerid)

{

    new rows, fields;

    cache_get_data(rows, fields, mysql);

    if(rows) //if there is row

    {

        cache_get_row(0, 2, PlayerInfo[playerid][pPassword]);

        //we will load their password into PlayerInfo[playerid][Password] to be used in logging in

        //0 is row, 2 is field. If you're wondering why row is 0; remember we used LIMIT 1 while checking player's account. LIMIT is a limitation of results to be shown. Since we used LIMIT 1, it'd be like;

        // ---> row>  ID | Username | Password | IP | Level | .... and so on

        //            ^      ^          ^    ^      ^

        //      fields 0      1          2    3      4

        //So we're getting row 0, field 2 which is password

        PlayerInfo[playerid][pID] = cache_get_row_int(0, 0); //now let's load player's ID into PlayerInfo[playerid][iD] so we can use it later

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Inainte de a putea juca pe server trebuie sa te loghezi.\n Introdu parola contului tau.", "Login", "Kick"); //And since we found a result from the database, which means, there is an account; we will show a login dialog

    }

    else //if we didn't find any rows from the database, that means, no accounts were found

    {

//So we show the a dialog register

        ShowPlayerDialog(playerid, D_Register, DIALOG_STYLE_INPUT, "Register", "Alege o parola si introdu-o in casuta de mai jos.", "Register", "Kick");

    }

    return 1;

}[/pawn]

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

[pawn]case D_Login:

{

if(!response) Kick(playerid); //if they clicked Quit, we will kick them

//new hpass[129]; //for password hashing

//WP_Hash(hpass, 129, inputtext); //hashing inputtext

if(strcmp(inputtext, PlayerInfo[playerid][pPassword]) == 0)

//if(!strcmp(hpass, PlayerInfo[playerid][pPassword])) //remember we have loaded player's password into this variable, PlayerInfo[playerid][pPassword] earlier. Now let's use it to compare the hashed password with password that we load

{ //if the hashed password matches with the loaded password from database

//mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);

mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' AND `Password` = '%e'", Name[playerid], inputtext);

mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);

}

else //if the hashed password didn't match with the loaded password(PlayerInfo[playerid][pPassword])

{

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Parola introdusa este incorecta.", "Login", "Kick");

}

}[/pawn]

La fel.. ma lasa sa ma conectez indiferent de ce parola as pune..

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Sterge [pawn]if(strcmp(inputtext, PlayerInfo[playerid][pPassword]) == 0)[/pawn] si inlocul lui pune [pawn]if(strlen(inputtext) > 0)[/pawn]. Apropo ce e cu case D_Login? Ce faci cu el?

Vad ca tu ai un dialog acolo inauntru, de ce?

[pawn]ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Inainte de a putea juca pe server trebuie sa te loghezi.\n Introdu parola contului tau.", "Login", "Kick"); //And since we found a result from the database, which means, there is an account; we will show a login dialog[/pawn]

Poti sa verifici daca exista, dupa cum iti dadui eu.

Link to comment
Share on other sites

Avand in vedere ca la acest sistem de login/register m-am inspirat dintr-un tutorial si ca nu ma pricep prea bine la MySQL.. nu prea inteleg... Dar.. am functia de mai jos care ar trebui sa verifice daca existia..

[pawn]

public OnAccountCheck(playerid)

{

    new rows, fields;

    cache_get_data(rows, fields, mysql);

    if(rows) //if there is row

    {

        cache_get_row(0, 2, PlayerInfo[playerid][pPassword]);

        //we will load their password into PlayerInfo[playerid][Password] to be used in logging in

        //0 is row, 2 is field. If you're wondering why row is 0; remember we used LIMIT 1 while checking player's account. LIMIT is a limitation of results to be shown. Since we used LIMIT 1, it'd be like;

        // ---> row>  ID | Username | Password | IP | Level | .... and so on

        //            ^      ^          ^    ^      ^

        //      fields 0      1          2    3      4

        //So we're getting row 0, field 2 which is password

        PlayerInfo[playerid][pID] = cache_get_row_int(0, 0); //now let's load player's ID into PlayerInfo[playerid][iD] so we can use it later

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Inainte de a putea juca pe server trebuie sa te loghezi.\n Introdu parola contului tau.", "Login", "Kick"); //And since we found a result from the database, which means, there is an account; we will show a login dialog

    }

    else //if we didn't find any rows from the database, that means, no accounts were found

    {

//So we show the a dialog register

        ShowPlayerDialog(playerid, D_Register, DIALOG_STYLE_INPUT, "Register", "Alege o parola si introdu-o in casuta de mai jos.", "Register", "Kick");

    }

    return 1;

}[/pawn]

Si.. dialogul de care zici .. apare acel dialog daca gaseste contul in baza de date.. daca nu, apare dialogul D_Register..

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Sistem-ul nu il inteleg doar din cateva linii, dar acolo cand faci quer-ul, cand il executi mai exact. Daca nu ai rows o sa-ti dea direct ala cu register. Asa ca sterge-l (ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Inainte de a putea juca pe server trebuie sa te loghezi.\n Introdu parola contului tau.", "Login", "Kick"); //And since we found a result from the database, which means, there is an account; we will show a login dialog

    ) si pune [pawn]if(rows != 0)[/pawn] in locul lui if(rows), doar de siguranta :)

Deci, pe tine te logheaza sau nu. Asta nu am inteles ... Tu ai zis ca te logheaza de la login, ce vrei sa zici cu asta?

Link to comment
Share on other sites

Intru pe server, apare dialogul pentru login(D_Login) si indiferent de ce parola as scrie e corecta..

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Intru pe server, apare dialogul pentru login(D_Login) si indiferent de ce parola as scrie e corecta..

Ok, deci. Cand ai pus acolo "AND `Password`" trebuie sa ia exact user-ul cu parola aia, nu sa zica ca e corecta pentru ca nu o sa gaseasca un user valid daca o pui gresit. Ia spune-i sa iti afiseze parola, in printf sau SendClientMessage si spune-mi ce-ti arata.

Link to comment
Share on other sites

script:

[pawn] if(!response) Kick(playerid); //if they clicked Quit, we will kick them

//new hpass[129]; //for password hashing

//WP_Hash(hpass, 129, inputtext); //hashing inputtext

//if(strcmp(inputtext, PlayerInfo[playerid][pPassword]) == 0)

//if(strlen(inputtext) > 0)

if(!strcmp(inputtext, PlayerInfo[playerid][pPassword])) //remember we have loaded player's password into this variable, PlayerInfo[playerid][pPassword] earlier. Now let's use it to compare the hashed password with password that we load

{ //if the hashed password matches with the loaded password from database

//mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);

mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' AND `Password` = '%e'", Name[playerid], inputtext);

mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);

printf("s | User: %s | Pass: %s", Name[playerid], inputtext);

printf("s | User: %s | Pass: %s", Name[playerid], PlayerInfo[playerid][pPassword]);

printf("e | User: %e | Pass: %e", Name[playerid], inputtext);

printf("e | User: %e | Pass: %e", Name[playerid], PlayerInfo[playerid][pPassword]);

printf("inputtext: %s", inputtext);

}

else //if the hashed password didn't match with the loaded password(PlayerInfo[playerid][pPassword])

{

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Parola introdusa este incorecta.", "Login", "Kick");

}

}[/pawn]

server_log

[10:10:13] [part] Account has left the server (0:2)
[10:10:13] s | User: Account | Pass: 
[10:10:13] s | User: Account | Pass: NULL
[10:10:13] e | User: e | Pass: e
[10:10:13] e | User: e | Pass: e
[10:10:13] inputtext: 

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

[pawn]public OnAccountLoad(playerid)

{

    PlayerInfo[playerid][pLevel] = cache_get_row_int(0, 4);

    PlayerInfo[playerid][pCash] = cache_get_row_int(0, 5);

    PlayerInfo[playerid][pAdmin] = cache_get_row_int(0, 6);

    PlayerInfo[playerid][pKills] = cache_get_row_int(0, 7);

    PlayerInfo[playerid][pDeaths] = cache_get_row_int(0, 8);

    PlayerInfo[playerid][pHouseKey] = cache_get_row_int(0, 9);

    PlayerInfo[playerid][pSpawn] = cache_get_row_int(0, 10);

    PlayerInfo[playerid][pTutorial] = cache_get_row_int(0, 11);

    PlayerInfo[playerid][pSkin] = cache_get_row_int(0, 12);

    PlayerInfo[playerid][pJob] = cache_get_row_int(0, 13);

    PlayerInfo[playerid][pCurse] = cache_get_row_int(0, 14);

    PlayerInfo[playerid][pFactiune] = cache_get_row_int(0, 15);

PlayerInfo[playerid][pRank] = cache_get_row_int(0, 16);

PlayerInfo[playerid][pLider] = cache_get_row_int(0, 17);

PlayerInfo[playerid][pCar] = cache_get_row_int(0, 18);

PlayerInfo[playerid][pBank]    =  cache_get_row_int(0, 19);

    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);

SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);

SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);

if(PlayerInfo[playerid][pTutorial] == 0)

{

    TogglePlayerControllable(playerid, 0); // This will Make player freeze.

SetPlayerCameraPos(playerid, 1626.66, 820.16, 21.77); // This will set the Camera Pos for the playerid.

SetPlayerCameraLookAt(playerid, 1599.65, 848.15, 11.50); // This will set where the camera should look.

SetTimerEx("Tutorial_Pas1", 8000, false, "i", playerid);

}

SCM(playerid, c_alb, "{FFFFFF}[{67BDFC}System{FFFFFF}] {F48651}Te-ai logat cu succes. Apasa {FFFFFF}'{67BDFC}SHIFT{FFFFFF}' {F48651}pentru a continua{FFFFFF}.");

    SetPlayerSpawn(playerid);

return 1;

}

[/pawn]

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Pune [pawn] new rows, fields;

    cache_get_data(rows, fields, mysql);

    if(rows != 0) //if there is row

    {

// cod

}else

ShowPlayerDialog(playerid, D_Login, DIALOG_STYLE_INPUT, "Login", "Inainte de a putea juca pe server trebuie sa te loghezi.\n Introdu parola contului tau.", "Login", "Kick"); //And since we found a result from the database, which means, there is an account; we will show a login dialog

[/pawn]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.