SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 09/07/2013, 04:41 PM   #11
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: How to use SQLite

Quote:
Originally Posted by Red_Dragon. View Post
Pretty awesome!
Quote:
Originally Posted by Zeyo View Post
Yay, its awesome. Thank you Zeus_
Thank you!
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 09/07/2013, 05:56 PM   #12
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,423
Reputation: 138
Default Re: How to use SQLite

Quote:
Originally Posted by _Zeus View Post
You should. I will give you an example of what SQL Injection is.

Let's say your mode has a dialog (input) and someone insert a "name" to check something for a user. He can input:
Code:
"Zeus';DROP TABLE users;"
And it will just delete your table "users". DB_Escape is used for this reason. To prevent someone from doing something bad to your database. You can also read more about DB_Escape/SQL Injection to the wiki (http://wiki.sa-mp.com/wiki/Escaping_Strings_SQLite) or wikipedia (http://en.wikipedia.org/wiki/SQL_injection)

You just need to check any string you insert in a query with:
Code:
// An example:
"SELECT username FROM users WHERE ip = '%s'", DB_Escape( ip ) // etc..

Glad to hear that you use SQLite, it's great and I can confirm it because I know that a very popular server in the past used SQLite and had over 500,000 registered users and everything worked fine!

Thanks for your kind words.

AW MAN thanks this answered everything! i never knw about sql injection i considered it as memory leak or whatever :3
anyways i too had a server it ran for 20 days and i was quite happy with it , i also made many other dynamic scripts in SQLite , its very nice + had SQLITEi from - Slice added too
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 09/07/2013, 06:37 PM   #13
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: How to use SQLite

Glad to see you understood SQL Injection. Memory leaks are caused by the results, if you do not free the memory.

I tried to use Slice's include but found it "too heavy" for me and to be honest, if someone is careful with their mode, then they will never have problems. I've been using SQLite for 1 year and it never crashed due to that or anything else related to SQLite. Absolutely nothing!
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 09/07/2013, 07:09 PM   #14
IPrototypeI
Banned
 
Join Date: Jan 2013
Posts: 113
Reputation: 48
Default AW: How to use SQLite

Good Tutorial but you can add LIMIT 1 to your SELECT-query, because if the server found one result in his database he stopped and don`t go one with searching after results. With your query it is that the mysql-server go one with the searching after he found a result. With this you can optimize your SELECT-query a little bit.

A other point is that you can reset the values from your acc-array with a for-loop.

Example:
Code:
for(new i; i < _:USER_DATA; ++i)User[playerid][USER_DATA:i]= 0;
or

Code:
for(new i; USER_DATA:i < USER_DATA; i++) User[playerid][USER_DATA:i] = 0;
IPrototypeI is offline   Reply With Quote
Old 09/07/2013, 07:47 PM   #15
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: How to use SQLite

That's a good suggestion about the LIMIT 0, 1 and I'm going to add it to the tutorial! Thank you.

To be honest, I didn't know that method to reset variables. However, does it reset only integers? What if I have in an enumeration with strings, integers, floats, booleans?

EDIT: I tested it and it reset everything inside the enumeration. Thanks a lot man, that was something I had no idea and it's great!

Added both.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System

Last edited by Konstantinos; 09/07/2013 at 08:29 PM.
Konstantinos is offline   Reply With Quote
Old 09/07/2013, 10:36 PM   #16
NoahF
Gangsta
 
NoahF's Avatar
 
Join Date: Jul 2012
Location: USA
Posts: 881
Reputation: 38
Default Re: How to use SQLite

Awesome TUT!
__________________
http://www.eoagaming.com/
https://discord.gg/QVyvHjK
Looking for a unique CoD server with an apocalyptic theme, regular updates, fantastic custom maps and a stable staff team? Look no further!! Feel free to check out our website or join our Discord! Oh, and did I mention we also have Hosted Tab?!
NoahF is offline   Reply With Quote
Old 10/07/2013, 08:49 AM   #17
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: How to use SQLite

Thanks, NoahF!
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 10/07/2013, 09:26 PM   #18
RedFusion
High-roller
 
RedFusion's Avatar
 
Join Date: Nov 2009
Location: Sweden
Posts: 1,079
Reputation: 300
Default Re: How to use SQLite

Nice tutorial!
__________________
Also known as fusez
RedFusion is offline   Reply With Quote
Old 12/07/2013, 02:04 AM   #19
Darnell
Gangsta
 
Darnell's Avatar
 
Join Date: Jul 2010
Posts: 852
Reputation: 34
Default Re: How to use SQLite

The 'ShowDialog', where are we supposed to get that?
Darnell is offline   Reply With Quote
Old 12/07/2013, 10:50 AM   #20
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,982
Reputation: 1392
Default Re: How to use SQLite

Thank you, RedFusion.

@Darnell, I mentioned that I use "easydialog" include (http://forum.sa-mp.com/showthread.php?t=377140). Though, if you don't want to use it and you want the default way instead you can tell me that! I don't mind to post it.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLite help CreativityLacker Scripting Help 2 12/05/2013 10:37 AM
SQLITE help Ryan_Obeles Scripting Help 9 28/04/2013 01:55 AM
Little help on sqlite FireCat Help Archive 4 20/08/2011 01:45 PM


All times are GMT. The time now is 09:39 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.