[MSQL]How could i check if player is registered?
#2

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.

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
}
I've done it by playerid, and then detecting their name in the actual function.
Reply


Messages In This Thread
[MSQL]How could i check if player is registered? - by Type-R - 05.06.2011, 02:47
Re: [MSQL]How could i check if player is registered? - by Burridge - 05.06.2011, 07:52
Re: [MSQL]How could i check if player is registered? - by PrawkC - 05.06.2011, 09:58
Re: [MSQL]How could i check if player is registered? - by Calgon - 05.06.2011, 11:38
Re: [MSQL]How could i check if player is registered? - by Type-R - 05.06.2011, 15:48

Forum Jump:


Users browsing this thread: 1 Guest(s)