31.10.2012, 21:44
Hey Guys,
today i tried to update my script, what was bases on the g-styleezz's mysql plugin R6, to R7.
After i did this, i have some bugs.
1. When i create a account, when my account doesnt excists, in the mysql table is the wrong password. ( The Entry of the password is always '0'
2. After that, he doesn't recognize, if the player is already registrated and creates the hole shit again.
Here is some Code:
And here are the threaded queries:
Would be very pleased about an answer!
Thanks in advance!
Greetz!
today i tried to update my script, what was bases on the g-styleezz's mysql plugin R6, to R7.
After i did this, i have some bugs.
1. When i create a account, when my account doesnt excists, in the mysql table is the wrong password. ( The Entry of the password is always '0'
2. After that, he doesn't recognize, if the player is already registrated and creates the hole shit again.
Here is some Code:
Код:
case DIALOG_REGISTER: { if(strlen(inputtext) < 6) { SendClientMessage(playerid,ROT,"Fehler: Dein Passwort darf nicht kьrzer als 6 Zeichen sein. Bitte wдhle ein anderes Passwort!"); ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Registrierung",""WEISS_HTML"Bitte gebe hier dein Passwort ein,das du festlegen willst.\nWichtig: Merke es dir gut und beachte GroЯ- bzw. Kleinschreibung:","OK",""); } else { new buffer[130]; WP_Hash(buffer,130,inputtext); CreateAccount(playerid,buffer); SetPVarInt(playerid,"eingeloggt",1); SpawnPlayer(playerid); } } case DIALOG_LOGIN: { new buf[130]; WP_Hash(buf,130,inputtext); if(strlen(inputtext) < 6) { SendClientMessage(playerid,ROT,"Hoppla, bei der Registrierung konnte dein Passwort gar nicht kьrzer als 6 Zeichen sein."); SendClientMessage(playerid,ROT,"Gebe bitte nun dein richtiges Passwort ein!"); new str[200]; format(str,sizeof str,""WEISS_HTML"Herzlich Willkommen zurьck "GOLD_HTML"%s"WEISS_HTML".\nBitte geb unten zum Login dein Passwort ein:",SpielerName(playerid)); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",str,"OK",""); } if(!strcmp(buf,SpielerInfo[playerid][pPasswort], false)) { SetPVarInt(playerid,"eingeloggt",1); LoadPlayer(playerid); SpawnPlayer(playerid); } else { SendClientMessage(playerid,ROT,"Fehler: Dein eingegebenes Passwort stimmt nicht mit dem ьberein, das in der Datenbank steht."); SendClientMessage(playerid,ROT,"Prьfe, ob du dich nicht verschrieben hast, oder Caps Lock an ist, und gebe das Passwort erneut unten ein!"); new str[200]; format(str,sizeof str,""WEISS_HTML"Herzlich Willkommen zurьck "GOLD_HTML"%s"WEISS_HTML".\nBitte geb unten zum Login dein Passwort ein:",SpielerName(playerid)); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",str,"OK",""); } }
Код:
stock mysql_CheckAccount(playerid) { new Query[128],Name[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, Name, MAX_PLAYER_NAME+1); mysql_real_escape_string(Name, Name); format(Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", Name); mysql_function_query(mysql_connectionhandle,Query,true,"",""); SpielerInfo[playerid][pExists] = mysql_num_rows(); return 1; } stock CreateAccount(playerid,pass[]) { new query[256],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, MAX_PLAYER_NAME); mysql_real_escape_string(Name,Name); mysql_real_escape_string(pass,pass); format(query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Passwort`) VALUES ('%s', '%s')", Name, pass); mysql_function_query(mysql_connectionhandle,query,false,"",""); return true; } stock mysql_ReturnPassword(playerid, Name[]) { new query[130],Get[130]; mysql_real_escape_string(Name, Name); format(query, 128, "SELECT `Passwort` FROM `accounts` WHERE `Name` = '%s'", Name); mysql_query(mysql_connectionhandle,query,true,"OnPlayerGotReturnedHisPassword","i",playerid); return 1; }
Код:
function OnPlayerGotReturnedHisPassword(playerid) { new rows,fields; cache_get_data(rows,fields); if(rows) { cache_get_row(0,2,SpielerInfo[playerid][pPasswort]); } return 1; } function OnPlayerLoaded(playerid) { new rows,fields,level[12],geld[12],kills[12],tode[12],banned[12]; cache_get_data(rows,fields); if(rows) { cache_get_row(0,1,SpielerInfo[playerid][pName]); cache_get_row(0,3,level); SpielerInfo[playerid][pLevel] = strval(level); cache_get_row(0,4,geld); SpielerInfo[playerid][pGeld] = strval(geld); cache_get_row(0,5,kills); SpielerInfo[playerid][pKills] = strval(kills); cache_get_row(0,6,tode); SpielerInfo[playerid][pTode] = strval(tode); cache_get_row(0,7,banned); SpielerInfo[playerid][pBanned] = strval(banned); } return 1; }
Thanks in advance!
Greetz!