[Tutorial] How to use SQLite
#21

Nice tutorial, extremely helpful; good luck with everything!
Reply
#22

Quote:
Originally Posted by xkirill
View Post
Will be nice if you'll write a tutorial for SQLitei as well.
Anyway,nice tutorial !
I might do! Thanks anyway.

Quote:
Originally Posted by jozzuia
View Post
Nice tutorial, extremely helpful; good luck with everything!
Thank you.
Reply
#23

Awesome Man.
Would be useful for me in Next scripts.
Repped+
Reply
#24

This tutorial have a little bug I guess.

If you use this:
Code:
public OnPlayerDisconnect( playerid, reason )
{
    for( new i; i < _: USER_DATA; ++i ) User[ playerid ][ USER_DATA: i ] = 0;
    // ...
    return 1;
}
To reset the player variables, stats will not save. Use that code just in "OnPlayerConnect".
Reply
#25

Thanks.

Quote:
Originally Posted by CrossOv3r
View Post
This tutorial have a little bug I guess.

If you use this:
Code:
public OnPlayerDisconnect( playerid, reason )
{
    for( new i; i < _: USER_DATA; ++i ) User[ playerid ][ USER_DATA: i ] = 0;
    // ...
    return 1;
}
To reset the player variables, stats will not save. Use that code just in "OnPlayerConnect".
Take a look again in my post, I first save and then reset. Everything is fine.
Reply
#26

I havent tried it yet, but how would you make a command that sets a player admin level?
Reply
#27

That is in the tutorial look at the OnPlayerDisconnect()
Reply
#28

Quote:
Originally Posted by Konstantinos
View Post
Before we start again, I want to tell you that I use an include "easydialog" for my dialogs because I used to have few problems with just 3 dialogs and the dialogids differ from each other. If you don't want to use it, then you can simply switch to the old method.
So what is the "old method"?? Heck, I would settle for the new and improved method or an old and lousy method. Assuming any method that works.

Code:
error 017: undefined symbol "ShowDialog"
I have dug through this tutorial for the answer and I have Emmt's easydialog but apparently it is not in there. I do appreciate that you took a lot of time making a SQLite tutorial, but now even your link to Emmt's easydialog is dead.

Meanwhile I am experimenting with the code in the vain hope I will stumble on something. Is there no coding bible for this script?

---update---

I am back, here is how I got your code to compile.

I added the constants at the top of the script;

Code:
#define DIALOG_LOGIN 1
#define DIALOG_REGISTER 2
Then I changed 5 the lines that used ShowDialog to this;
Code:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Type in your password below to log in.", "Login", "Leave");
//or this
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Type in a password below to register an account.", "Register", "Leave");
I am only guessing that is correct. If my code above is in error please show me.

The code compiled and when I run this on my server, I get the "File or Function not found" error. I assume this is the "server.db" since that is the only external file. I have no problem making the table and fields but what folder is it reading this from?
Reply
#29

Emmet_ requested for his threads to be deleted few months ago and I haven't edited the tutorial for a long time.

Your way is correct, just make sure that other scripts do not use dialogid 1 and 2 because they will conflict.

About the run time error 19, load nativechecker plugin (it must be last) and run the server. Functions are not registered means that either you forgot to load some required plugins or they failed to load. There is a possibility, the version of a_samp.inc file to be for latest version and the samp-server.exe/samp03svr to be for older versions. That would give the run time for the new functions added.
Reply
#30

How odd of him to make that request. Anyway... I am running 100% Linux here, whatever I have came from the downloads section of the main site. I am a tad confused on which nativechecker I should download.

I am force to use VM for pawno, which seems to work so far. I am still looking for a Linux version of the pawn compiler. I assume Windows since that is the compiler used and since there is a nativechecker.so ...

I will try all this again after work. The boss man is looking as if he is about to explode again.
Thanks for the help!
Reply
#31

This is awesome, thanks.
Reply
#32

Everything seems to work as expected. I had a stupid typo on my part in my server.cfg and was no fault of this fine tutorial. The server.db was created in the scripts folder I had some friends test my work and I couldn't get them to stop playing. lol

Now I am off to study about NPCs... wish me luck!
Reputation point 731 that is mine.
Reply
#33

Good for Copy And Paste but am taking my time and do this i wanna learn it,nice Tut
Reply
#34

Great tutorial, would be great if you could explain what a query does/send in depth aswell, plus how do you know the parameters for the queries?

For example

Code:
 db_query( Database, "CREATE TABLE IF NOT EXISTS users (userid INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR(24) COLLATE NOCASE, password VARCHAR(129), admin INTEGER DEFAULT 0 NOT NULL)" );
    return 1;
and

Code:
ormat( Query, sizeof( Query ), "SELECT password FROM users WHERE username = '%s' LIMIT 0, 1", DB_Escape( User[ playerid ][ USER_NAME ] ) );// SELECT field FROM table WHERE field = something. Take a look at the DB_Escape
	Result = db_query( Database, Query );
The first one doesn't use the same format as the second (SELECT field FROM table WHERE field = something)

Thanks tho!
Reply
#35

Helped me. Thanks.
Reply
#36

Quote:
Originally Posted by Black Axe
View Post
[..]plus how do you know the parameters for the queries?[..]The first one doesn't use the same format as the second (SELECT field FROM table WHERE field = something)
Are you referring to the syntax of a query?

pawn Code:
SELECT column1, column2, columnN FROM table_name;
&
pawn Code:
CREATE TABLE database_name.table_name(
   column1 datatype  PRIMARY KEY(one or more columns),
   column2 datatype,
   column3 datatype,
   .....
   columnN datatype,
);
One selects data from our database and the other creates a table (if not exists already).

In case I misunderstood what you initially meant, please rephrase.

@everyone: thanks by the way for your kind words.
Reply
#37

Nice Work + REP.
Reply
#38

How to save hex value (color codes) in sqllite ?(gud tut by the way )
Reply
#39

Quote:
Originally Posted by GhostHacker
View Post
How to save hex value (color codes) in sqllite ?(gud tut by the way )
Colors are numbers so save/load them as integer.

PS: Thanks.
Reply
#40

I have a few concerns though, Can SQLite handle more than 9 tables in one server?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)