18.04.2010, 13:09
Hello,
first of all this is my list of functions which i have:
Ok, what i am trying to do is, make a log in for my player. I have made a "onPlayerLogin" public and this is what it looks like:
you can see that i make sure account exist's first (just incase)...then i want to check for the password to check if it is correct (Not using encryption yet, just want to make system without then ill just add it afterwards...)
I know how to use mysql with php although this is my first time with pawno and its very different...In php i would use:
And then check my 'password[]' against $pass variable...although i do not know i do what i did in php, in pawno....any help?
first of all this is my list of functions which i have:
Код:
native samp_mysql_connect(server[], user[], password[]); native samp_mysql_select_db(db[]); native samp_mysql_query(query[]); native samp_mysql_store_result(); native samp_mysql_fetch_row(line[]); native samp_mysql_get_field(field[], value[]); native samp_mysql_num_rows(); native samp_mysql_num_fields(); native samp_mysql_ping(); native samp_mysql_real_escape_string(src[], dest[]); native samp_mysql_free_result(); native samp_mysql_strtok(dest[], separator[], src[]); native samp_mysql_close();
Код:
public onPlayerLogin(playerid, password[]){ new playerName[MAX_PLAYER_NAME]; new result[258]; new sqlPlayerName[258]; GetPlayerName(playerid,playerName,sizeof(playerName)); //Get Player Name samp_mysql_real_escape_string(playerName, sqlPlayerName); //String for mysql format(result,sizeof(result),"SELECT * FROM accounts WHERE user='%s'",sqlPlayerName); // Format my query samp_mysql_query(result); samp_mysql_store_result(); if(samp_mysql_num_rows() != 0){ SendClientMessage(playerid,COLOR_GREEN,"**You have successfully Logged in!!"); //Creating if statement here SendClientMessage(playerid,COLOR_RED,"**Sorry, that password is incorrect!!"); //Creating if statement here return 1; }else{ SendClientMessage(playerid,COLOR_RED,"Sorry, That accoint does not exist!"); } return 1; }
I know how to use mysql with php although this is my first time with pawno and its very different...In php i would use:
Код:
$blah = mysql_fetch_assoc($query); // or mysql_fetch_array $pass = $blah['pass'];