[FilterScript] Registration & Login System [SQLite]
#2

  1. How can this work if you don\'t specify the type of field your are going to make in the database\'s table:
    pawn Code:
    stock LoadDatabase()
    {
        new query[350];
        database = db_open(USER_DATABASE_PATH);

        format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `%s` (`%s`, `%s`, `%s`, `%s`, `%s`)",
        TABLE_USERS,
        USER_NAME,
        USER_PASSWORD,
        USER_SCORE,
        USER_CASH,
        USER_ADMIN_LEVEL);
        db_query(database, query);
    }
  2. You realize that format is very much slower than strcat. So why using format here if you can do that with strcat.


    This:
    pawn Code:
    new string[256];
    format(string, sizeof(string), "{FFFFFF}Welcome, {FF0000}%s{FFFFFF}!

    "
    , PlayerName(playerid));
    strcat(string, "You must register to play here.");


    Can be:
    pawn Code:
    strcat(string, "{FFFFFF}Welcome, {FF0000}");
    strcat(string, PlayerName(playerid));
    strcat(string, "{FFFFFF}!

    "
    );
    strcat(string, "You must register to play here.");
  3. If you are using latest SAMP version i.e. SAMP 0.3.7 R2-1, then you can directly get int and float fields without declaring arrays ad using strval/floatstr.


    This
    pawn Code:
    db_get_field_assoc(result, USER_CASH, field, sizeof(field));
    SetPlayerMoney(playerid, strval(field));


    Can be:
    pawn Code:
    SetPlayerMoney(playerid, db_get_field_assoc_int(return, USER_CASH));
  4. Also making your own DB_Escape isn\'t require, you can directly do that by the new specifier "%q" in format.
  5. And, you should always free the result when not required anymore, using db_free_result. You haven\'t done that at some parts of your script.
  6. No PRIMARY KEY, your queries check the rows according to username and password which is very very slow than checking for Row ids.
Reply


Messages In This Thread
Registration & Login System [SQLite] - by Kevln - 03.11.2015, 06:00
Re: Registration & Login System [SQLite] - by Gammix - 03.11.2015, 06:21
Re: Registration & Login System [SQLite] - by N0FeaR - 19.11.2015, 06:23
Re: Registration & Login System [SQLite] - by Karan007 - 19.11.2015, 06:30

Forum Jump:


Users browsing this thread: 1 Guest(s)