17.07.2013, 19:56
First of all, you should be using threaded queries- you're severely limiting your performance with non-threaded queries. Secondly, your queries are being told to fetch everything from the users table so you're already going to be causing some strain on your MySQL server.
Let me give you a better example:
Obviously that's using threaded queries. I won't enable people to use non-threaded queries, so I won't give you the code for that. However, there's a better query for you to use if you prefer not to use threaded queries.
Let me give you a better example:
pawn Код:
mysql_function_query(connectionHandle, "SELECT `AccountName` FROM `users` ORDER BY `Score` DESC LIMIT 5", true, "thread_GetHighestScore", ""); // this would need to go somewhere where you want to load the highest scores (under a command or something)
forward thread_GetHighestScore();
public thread_GetHighestScore()
{
new
rows,
fields;
if(rows > 0)
{
new
szUsername[MAX_PLAYER_NAME];
for(new i = 0; i < rows; i++)
{
cache_get_row(i, 0, szUsername);
// update your TD- szUsername is the username of the player
}
}
return 1;
}