[FilterScript] Registration & Login System [SQLite] - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Registration & Login System [SQLite] (
/showthread.php?tid=593237)
Registration & Login System [SQLite] -
Kevln - 03.11.2015
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
Re: Registration & Login System [SQLite] -
Gammix - 03.11.2015
- 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);
}
- 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.");
- 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));
- Also making your own DB_Escape isn\'t require, you can directly do that by the new specifier "%q" in format.
- 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.
- No PRIMARY KEY, your queries check the rows according to username and password which is very very slow than checking for Row ids.
Re: Registration & Login System [SQLite] -
N0FeaR - 19.11.2015
Good job buddy!
Re: Registration & Login System [SQLite] -
Karan007 - 19.11.2015
Nice one.