mysql query - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql query (
/showthread.php?tid=423810)
mysql query -
David94 - 19.03.2013
aaaaaaaaaaaaaaaa
Re: mysql query -
kamzaf - 19.03.2013
"SELECT * FROM `playerdata` ORDER BY `score` DESC LIMIT 5"
i expect you know how to do the rest.
Re: mysql query -
David94 - 20.03.2013
aaaaaaaaaaaaaaaaaaaa
Re: mysql query -
PaulDinam - 20.03.2013
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;
}
Re: mysql query -
Misiur - 20.03.2013
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
Re: mysql query -
PaulDinam - 20.03.2013
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.
Re: mysql query -
Misiur - 20.03.2013
http://forum.sa-mp.com/showpost.php?...&postcount=172 some more insight
Re: mysql query -
David94 - 29.03.2013
aaaaaaaaaaaaaaaaaaaaaaaa