SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/03/2013, 02:17 PM   #1
David94
Little Clucker
 
Join Date: Nov 2012
Location: Hungary
Posts: 15
Reputation: 15
Default mysql query

aaaaaaaaaaaaaaaa

Last edited by David94; 12/02/2016 at 06:12 PM.
David94 is offline   Reply With Quote
Old 19/03/2013, 07:34 PM   #2
kamzaf
Huge Clucker
 
Join Date: Aug 2010
Location: Canada
Posts: 247
Reputation: 20
Default Re: mysql query

"SELECT * FROM `playerdata` ORDER BY `score` DESC LIMIT 5"

i expect you know how to do the rest.
kamzaf is offline   Reply With Quote
Old 20/03/2013, 03:01 PM   #3
David94
Little Clucker
 
Join Date: Nov 2012
Location: Hungary
Posts: 15
Reputation: 15
Default Re: mysql query

aaaaaaaaaaaaaaaaaaaa

Last edited by David94; 12/02/2016 at 06:12 PM.
David94 is offline   Reply With Quote
Old 20/03/2013, 03:10 PM   #4
PaulDinam
Gangsta
 
Join Date: Jun 2011
Posts: 887
Reputation: 45
Default Re: mysql query

ZCMD:
This is cache:
How would you code if you don't know english, you can't ask for each command from the forum users.
pawn Code:
CMD:ranks(playerid, params[])
{
    new query[256];
    format(query, sizeof(query), "SELECT * FROM `playerdata` ORDER BY `score` DESC LIMIT 5");
    mysql_function_query(DBHANDLE, query, true, "DisplayRanks", "i", playerid);
    return 1;
}

forward DisplayRanks(playerid);
public DisplayRanks(playerid)
{
    new rows, fields, row = 0, str[128];
    new kills, name[MAX_PLAYER_NAME];
    cache_get_data(rows, fields, DBHANDLE);
    if(rows)
    {
        while(row < rows)
        {
            cache_get_row(row, NameRowNumber, name, dbHandle, 128);
            kills = cache_get_row_int(row, KillsRowNumber);
            format(str, sizeof(str), "[Rank %d] %s, Kills: %d", row+1, name, kills);
            SendClientMessage(playerid, -1, str);
        }
    }
    else return SendClientMessage(playerid, -1, "No ranks to show up.");
    return 1;
}
PaulDinam is offline   Reply With Quote
Old 20/03/2013, 03:16 PM   #5
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: mysql query

I think more people need to ****** what cache exactly is, and why they shouldn't spam database with unnecessary queries. Think - if someone wants to take your server down, all he has to do is spam some function which calls database over and over again.

What you have to do to prevent it?
1. Load data earlier and store it in some array
2. Update data periodically with some timer (for example every 5 minutes)
3. When someone asks about that data, give him answer from your cache, DO NOT send another query
Misiur is offline   Reply With Quote
Old 20/03/2013, 03:29 PM   #6
PaulDinam
Gangsta
 
Join Date: Jun 2011
Posts: 887
Reputation: 45
Default Re: mysql query

Cache is not lagging, i'm using alot of times and no lags have been caused.
For example, in my server I have /backuphouses

and there is 600 houses, which is alot. it takes 2 minutes to save.
PaulDinam is offline   Reply With Quote
Old 20/03/2013, 03:30 PM   #7
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: mysql query

http://forum.sa-mp.com/showpost.php?...&postcount=172 some more insight
Misiur is offline   Reply With Quote
Old 29/03/2013, 03:59 PM   #8
David94
Little Clucker
 
Join Date: Nov 2012
Location: Hungary
Posts: 15
Reputation: 15
Default Re: mysql query

aaaaaaaaaaaaaaaaaaaaaaaa

Last edited by David94; 12/02/2016 at 06:13 PM.
David94 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
help with mysql query ajwar Scripting Help 3 19/02/2012 12:59 PM
[Help][MySQL]MySQL query unsuccessful. Timmi Scripting Help 14 01/01/2012 02:01 PM
mysql query Sascha Help Archive 1 06/06/2011 07:35 PM
Failed to exeute query. Lost connection to MySQL server during query. *IsBack Help Archive 10 06/01/2011 08:50 AM
[MySQL]Need help with a query lauri865 Help Archive 0 19/09/2009 05:36 PM


All times are GMT. The time now is 06:35 AM.


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