05.06.2011, 07:52
As far as I can see you're not actually checking if the account is in the database. Below is some code I have quickly typed up, hopefully it helps you, and hopefully you'll be able to work out the rest. If it isn't what you wanted, then sorry. I'm using BlueG's plugin for this code by the way.
I've done it by playerid, and then detecting their name in the actual function.
pawn Код:
CheckAccountExists(playerid){
new Query[128], Result[128], Name[24], EscName[24]; //the result variable size may have to change, depending on how many stats you load, and how big they are
GetPlayerName(playerid, Name, 24); //get the player's name
mysql_real_escape_string(Name, EscName); //you'll need to escape the string for the name to stop MySQL injection attacks
format(Query, sizeof(Query), "SELECT * FROM Saskaitos WHERE Vardas = '%s'", EscName);
mysql_query(Query); mysql_store_result();
if(mysql_fetch_row_format(Result)){
//load stats here
}
else {
//account doesn't exist, so maybe load up the register dialog with a message telling them to register
}
mysql_free_result(); //free the result you stored in the Query
}