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

Registration & Login System [SQLite]
Description


Allows the ability for players to create an account and log in afterwards, by also saving their statistics for a meaningful and continuance gameplay.

Note


The database (database.db) is created in scriptfolders when the server is booted up (if the database doesn\'t already exist).

Download

https://github.com/KevinMarapao/Regi...System--SQLite
Reply
#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
#3

Good job buddy!
Reply
#4

Nice one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)