CMD:bejelentkezes(playerid,params[]){if(IsPlayerConnected(playerid)){new query[300]; //Creates our variables. GetPlayerName(playerid, nev, sizeof(nev)); //Gets the players name format(query, sizeof(query), \"SELECT IP FROM `felhasznalok` WHERE nev = \'%s\' LIMIT 1\", nev); //Formats the query, view above the code for a explanation mysql_query(query); //This is our query function to query the string mysql_store_result(); //We store the result. new rows = mysql_num_rows(); //We get how many rows the query returned. if(rows == 1) { new jelszo[128]; if(sscanf(params,\"s[128]\",jelszo)) return SendClientMessage(playerid,-1,\"Használat: /bejelentkezes [Jelszó]\"); new escapepass[100]; // mysql_real_escape_string(jelszo, escapepass); //We escape the inputtext to avoid SQL injections. format(query, sizeof(query), \"SELECT `nev` FROM felhasznalok WHERE nev = \'%s\' AND jelszo = SHA1(\'%s\')\", nev, escapepass); mysql_query(query); mysql_store_result(); new numrows = mysql_num_rows(); if(!numrows) { //This means that the password that the player //typed was incorrect and we will resend the dialog. new string[64]; if(JelszoLehetosegek[playerid] > 1) { JelszoLehetosegek[playerid] --; format(string,sizeof(string),\"Rossz jelszó,még ennyi lehetõséged van: %d\",JelszoLehetosegek[playerid]); SendClientMessage(playerid,-1,string); printf(\"%s elrontotta a jelszavát.\",nev); return 1; } else if(JelszoLehetosegek[playerid] == 1) { SendClientMessage(playerid,-1,\"Minden lehetõségedet elrontottad,ezért ki lettél rúgva!\"); printf(\"%s ki lett rúgva mert háromszor rossz jelszót írt be.\",nev); Kick(playerid); return 1; } } else { new savingstring[20]; GetPlayerName(playerid, nev, sizeof(nev)); format(query, sizeof(query), \"SELECT * FROM felhasznalok WHERE nev = \'%s\'\", nev); //We only select the variables that we want to use. //We don\'t need things like the password string or the user string. mysql_query(query); //Queries the result mysql_store_result(); //Store a result because it\'s a SELECT statement. while(mysql_fetch_row_format(query,\"|\")) { //We use while so that it does a single query, not multiple //Especially when we have more variables. If there is more //Variables, you should just split the line with sscanf. To //Make it easier. mysql_fetch_field_row(savingstring, \"szint\"); Szint[playerid] = strval(savingstring); mysql_fetch_field_row(savingstring, \"xp\"); XP[playerid] = strval(savingstring); mysql_fetch_field_row(savingstring, \"perc\"); Perc[playerid] = strval(savingstring); mysql_fetch_field_row(savingstring, \"ora\"); Ora[playerid] = strval(savingstring); mysql_fetch_field_row(savingstring, \"penz\"); Penz[playerid] = strval(savingstring); //If you are wondering why I\'m using savingstring instead //Of a variable like using MoneyGiven right away, it\'s because //mysql_fetch_field_row requires a string. } mysql_free_result(); //We must always free a stored result SendClientMessage(playerid, -1, \"Sikeresen bejelentkeztél!\"); //Sends the client a message. Belepve[playerid] = 1; //Sets our logged in variable to one printf(\"%s bejelentkezett.\",nev); return 1; } //This means that there is a user in the database with the same //password that we typed, we now proceed by using the login function. mysql_free_result();}else SendClientMessage(playerid,-1,\"Még nem regisztráltál a szerverre!\");}return 1;}
if(!numrows) { //This means that the password that the player //typed was incorrect and we will resend the dialog. new string[64]; if(JelszoLehetosegek[playerid] > 1) { JelszoLehetosegek[playerid] --; format(string,sizeof(string),\"Rossz jelszó,még ennyi lehetõséged van: %d\",JelszoLehetosegek[playerid]); SendClientMessage(playerid,-1,string); printf(\"%s elrontotta a jelszavát.\",nev); return 1; } else if(JelszoLehetosegek[playerid] == 1) { SendClientMessage(playerid,-1,\"Minden lehetõségedet elrontottad,ezért ki lettél rúgva!\"); printf(\"%s ki lett rúgva mert háromszor rossz jelszót írt be.\",nev); Kick(playerid); return 1; } }
INSERT INTO felhasznalok(id, nev, jelszo, szint, penz, IP, xp, perc, ora, ban ) VALUES( 0,\'%s\', SHA1(\'%s\'), 1, 0, \'%s\', 0, 0, 0, false)[/quote]
new bool:IsRegistered[MAX_PLAYERS];