mysql query
#1

aaaaaaaaaaaaaaaa
Reply
#2

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

i expect you know how to do the rest.
Reply
#3

aaaaaaaaaaaaaaaaaaaa
Reply
#4

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 Код:
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;
}
Reply
#5

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
Reply
#6

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.
Reply
#7

http://forum.sa-mp.com/showpost.php?...&postcount=172 some more insight
Reply
#8

aaaaaaaaaaaaaaaaaaaaaaaa
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)