SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 15/05/2014, 05:00 AM   #1
Deal-or-die
Huge Clucker
 
Deal-or-die's Avatar
 
Join Date: Oct 2010
Location: An Island 1000's of miles away
Posts: 366
Reputation: 22
Default GetNextSQL Conversion/update Gstyle to BlueG?

G'day!

I am just trying to make something simlilar to this.

pawn Code:
stock GetNextSQL(id[],table[])
{
    format(query,sizeof(query), "SELECT `%s` FROM `%s` ORDER BY `id` ASC", id,table);
    mysql_query(query);
    mysql_store_result();
    new str[256];
    new index = 0;
    new tmp;
    new firstresult;
    new tmpnum;
    if(mysql_num_rows() >= 1)
    {
        while(mysql_fetch_row(str) && !firstresult)
        {
            sscanf(str, "d", tmp);
            tmpnum = index+1;
            if(tmp == 0 && mysql_num_rows() == 1) firstresult = 1;
            else if(tmp == index && tmpnum == mysql_num_rows())
            {
                firstresult = tmpnum;
            }
            else if(tmp == index)
            {
                index++;
            }
            else
            {
                firstresult = index;
            }
        }
    }
    else firstresult = 0;
    return firstresult;
}

However as I believe this is from gstyyllllez Plugin with store_result ect, would someone please be able to show me a conversion or maybe something that does the same as this stock for BlueG's Pluggin and preferably threaded if possible!

Explanations on why or why not it can or can't be made would be great as well as an explanation as to how and what you converted would be great if it's not asking too much :P (Saves me from having to ask a similar question in a few days when I need something converted again :P)

Cheers!
__________________
/////////////////////////// | Mini Moot | \\\\\\\\\\\\\\\\\\\\\\\\\\\

"I'm in the country that basically invented the Internet, and your getting faster speeds on an island 1,000miles away"
Deal-or-die is offline   Reply With Quote
Old 15/05/2014, 09:49 AM   #2
S4t3K
Gangsta
 
S4t3K's Avatar
 
Join Date: Jan 2013
Posts: 864
Reputation: 165
Default Re : GetNextSQL Conversion/update Gstyle to BlueG?

****** : Of course posting help request here about SQL isn't very clever, because as you've said, it's a forum about the PAWN language, but I don't see like 100 help request per day about SQL for samp elsewhere than here. Lemme explain myself : about %90 of the SQL help posted here are about SAMP, so it's not really the best place to ask, but it's not the worst place anyway.

And, as you said, "SQL Language" is redundant because SQL means "Structured Query Language".

I've made a tutorial in French on "how to optimize your queries", and it's usually a "*" problem. '*' means "all" in MySQL, selecting all the data in the table/database only to use the password (maybe the salt), and the username, it's a little bit idiot, because it's performance wasting.

Author : You're using a very old release of BlueG's plugin. Get the cache functions, it would be better for the performances.
__________________
S4t3K is offline   Reply With Quote
Old 15/05/2014, 10:03 AM   #3
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,828
Reputation: 1401
Default Re: Re : GetNextSQL Conversion/update Gstyle to BlueG?

Quote:
Originally Posted by S4t3K View Post
'*' means "all" in MySQL, selecting all the data in the table/database only to use the password (maybe the salt), and the username, it's a little bit idiot, because it's performance wasting.
It isn't! You can do the same thing with 1 query instead with 2 your way would use. A query with SELECT clause for all the data for that player, assign them to variables and then comparing the password than selecting the password and if they do match to execute another query with all the data and assign them to variables.
__________________
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 15/05/2014, 03:07 PM   #4
Deal-or-die
Huge Clucker
 
Deal-or-die's Avatar
 
Join Date: Oct 2010
Location: An Island 1000's of miles away
Posts: 366
Reputation: 22
Default Re: GetNextSQL Conversion/update Gstyle to BlueG?

-.- thank you all! You've all helped greatly! Telling me what type of forum this is, what sql means and that it's completely separate from samp! This all helped heaps!

Okay, on all seriousness, I apologise for the attitude, it's late, I'm tired and clearly I am asking on the wrong forums. Just to me thought that knowledge, is knowledge where ever it is, where ever you source it. Just thought someone with a better understanding of what I am trying to achieve would be able to 'help' me. But again, seems like I am in the wrong forums for 'help'.
__________________
/////////////////////////// | Mini Moot | \\\\\\\\\\\\\\\\\\\\\\\\\\\

"I'm in the country that basically invented the Internet, and your getting faster speeds on an island 1,000miles away"
Deal-or-die is offline   Reply With Quote
Old 15/05/2014, 04:51 PM   #5
Campbell-
Big Clucker
 
Join Date: Jan 2012
Location: Germany
Posts: 140
Reputation: 12
Default Re: GetNextSQL Conversion/update Gstyle to BlueG?

Code:
SELECT `%s` FROM `%s` ORDER BY `id` ASC
This and the whole function you posted in general is -bad practice-! Don't use it. Not every table has an 'id' field. Aswell, only a small portion of your SELECT-queries will actually look like this query.

pawn Code:
return firstresult;
Returning results like that won't work with BlueG's plugin in combinantion with threaded queries as the plugin will call a callback once the query is completed successfully. You'll have to think about another way to process your presented wish.
Campbell- 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
cmd conversion Tomix Scripting Help 6 07/11/2013 03:29 PM
BlueG mysql update problem PaulDinam Scripting Help 3 08/06/2013 11:43 AM
conversion the_zohan Scripting Help 19 28/05/2012 04:25 PM
Conversion Rokzlive Help Archive 1 24/03/2011 07:18 PM
0.3c Conversion kvsolga Help Archive 7 30/11/2010 02:53 AM


All times are GMT. The time now is 03:37 AM.


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