SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 06/01/2014, 10:34 AM   #11
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,863
Reputation: 1399
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

The better option would be to select all the data once and assign them if there are rows. In the login, you already got the password so compare it and you're done.

Few notes:
- Reset variables on connect.
- Instead of cache_get_data and storing the rows and fields to 2 variables, you could use directly cache_num_rows function:
pawn Code:
if (cache_num_rows()) // if (rows)

Also keep in mind about race condition attacks with threaded queries.

Quote:
Originally Posted by Lordz™ View Post
Nice, well explained. But in case if there's too much fields, it's better to use functions like cache_get_field_content, cache_get_field_content_int, cache_get_field_content_float, etc. So that the user who uses won't get confused in knowing the field ID.
Using the field's index instead of the name is faster, but yes - it depends on the user!
__________________
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 06/01/2014, 04:33 PM   #12
maddinat0r
Banned
 
Join Date: Jun 2010
Location: Germany
Posts: 848
Reputation: 482
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Good tutorial! I only noticed two things (apart of these others mentioned already):
1. "mysql_debug" is only available in R34 or higher. You can write "mysql_log(LOG_DEBUG | LOG_ERROR | LOG_WARNING);" instead (phew, what a long line, I'll probably add 'LOG_ALL' in R35)
2. Like Konstantinos already said, the best option would be to select all the data once. But instead of changing your whole callback structure and assigning the data before actually logging in, you can use "cache_save" and "cache_set_active" (you can find a further explanation about these natives in the SA-MP wiki).
maddinat0r is offline   Reply With Quote
Old 06/01/2014, 07:19 PM   #13
anou1
Huge Clucker
 
Join Date: Dec 2013
Location: To infinity... and beyond
Posts: 417
Reputation: 31
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Hello,

I tried to follow your tutorial but I encounter some errors:

Beta.pwn(69) : warning 217: loose indentation
Beta.pwn(119) : error 017: undefined symbol "Name"
Beta.pwn(119) : warning 215: expression has no effect
Beta.pwn(119) : error 001: expected token: ";", but found "]"
Beta.pwn(119) : error 029: invalid expression, assumed zero
Beta.pwn(119) : fatal error 107: too many error messages on one line

Pastbin: http://pastebin.com/JksS6uE9




How can I fix this ?


Thank you =)
Line 119: GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
anou1 is offline   Reply With Quote
Old 06/01/2014, 07:40 PM   #14
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,863
Reputation: 1399
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

I didn't read the entire tutorial and I saw that now by the above user's post. You've used char in the Name and IP arrays but you used them incorrect. You're supposed to use strpack/strunpack for it and it's good if you want to make less size but really not recommended into a tutorial.
Quote:
Originally Posted by anou1 View Post
Hello,

I tried to follow your tutorial but I encounter some errors:

Beta.pwn(69) : warning 217: loose indentation
Beta.pwn(119) : error 017: undefined symbol "Name"
Beta.pwn(119) : warning 215: expression has no effect
Beta.pwn(119) : error 001: expected token: ";", but found "]"
Beta.pwn(119) : error 029: invalid expression, assumed zero
Beta.pwn(119) : fatal error 107: too many error messages on one line

Pastbin: http://pastebin.com/JksS6uE9



How can I fix this ?


Thank you =)
Line 119: GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
http://pastebin.com/yA3LU9pu
__________________
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 06/01/2014, 07:44 PM   #15
anou1
Huge Clucker
 
Join Date: Dec 2013
Location: To infinity... and beyond
Posts: 417
Reputation: 31
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Thank you, I changed something now it work for my pastbin but I have those errors:


Beta.pwn(352) : warning 225: unreachable code
Beta.pwn(352) : error 029: invalid expression, assumed zero
Beta.pwn(352) : error 004: function "OnAccountCheck" is not implemented
Beta.pwn(353) : warning 217: loose indentation
Beta.pwn(379) : warning 225: unreachable code
Beta.pwn(379) : error 029: invalid expression, assumed zero
Beta.pwn(379) : error 004: function "OnAccountLoad" is not implemented
Beta.pwn(401) : error 030: compound statement not closed at the end of file (started at line 34

I did a 2 forward for OnAccountCheck and OnAccountLoad but what I have done wrong ?
Could u please explain me why ? And how can I solve this ?

Thank you

New Pastbin:http://pastebin.com/71Jz3VB7



EDIT: Sorry I forget a "}"
anou1 is offline   Reply With Quote
Old 07/01/2014, 03:04 AM   #16
newbienoob
High-roller
 
newbienoob's Avatar
 
Join Date: Jan 2012
Location: Follow the moaning coming from your parents' bedroom
Posts: 1,533
Reputation: 265
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Thank you guys. I'll keep in mind to update this later.
__________________
Help me, please /a chat
newbienoob is offline   Reply With Quote
Old 07/01/2014, 06:26 PM   #17
anou1
Huge Clucker
 
Join Date: Dec 2013
Location: To infinity... and beyond
Posts: 417
Reputation: 31
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

I dont know for you, but for me it doesnt save users data.

Every time I have to register again.
anou1 is offline   Reply With Quote
Old 07/01/2014, 06:59 PM   #18
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,397
Reputation: 569
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Quote:
Originally Posted by anou1 View Post
I dont know for you, but for me it doesnt save users data.

Every time I have to register again.
Check if it is even querying data to the database. Also enable mysql_log and check the mysql debug.
__________________
iZN is offline   Reply With Quote
Old 07/01/2014, 07:05 PM   #19
anou1
Huge Clucker
 
Join Date: Dec 2013
Location: To infinity... and beyond
Posts: 417
Reputation: 31
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

I found this error in mysql_log:

Code:
[20:02:42] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[20:02:49] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `joueurs` SET `Admin`=%d, `VIP`=%d, `Argent`=%d, `posX`=%f, `posY`=%f, `posZ`=%f WHERE `ID`=%d"
[20:02:49] [ERROR] mysql_format - destination size is too small
anou1 is offline   Reply With Quote
Old 25/01/2014, 11:40 AM   #20
anou1
Huge Clucker
 
Join Date: Dec 2013
Location: To infinity... and beyond
Posts: 417
Reputation: 31
Default Re : MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

I'm using this tutorial for my first GM, and it's really usefull !!
anou1 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
Baffled - mySQL Vehicle Loading (threaded queries) Moglizorz. Server Support 0 18/05/2013 01:14 AM
Comparing password [MySQL Threaded queries] emokidx Scripting Help 3 02/04/2013 12:07 PM
MySQL Threaded Queries CONTROLA Scripting Help 4 25/11/2012 03:02 PM
Threaded Queries - BlueG's MYSQL Plugin R7 Ballu Miaa Scripting Help 3 05/11/2012 05:36 PM
[Help] BlueG's MySQL Plugin R7 - Threaded Queries Maxips2 Scripting Help 4 19/10/2012 09:35 AM


All times are GMT. The time now is 12:06 PM.


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