not sure why exactly, but initialize the loop like this:
Code:
for(int i = 1; i <= MaxClients; i++)
client indexes start from 1 and looping until MAXPLAYERS is bad because it's a constant value (i think of 55); looping up to MaxClients is better because that's the biggest number that could be an entity index with your maxplayer setting
not sure why exactly, but initialize the loop like this:
Code:
for(int i = 1; i <= MaxClients; i++)
client indexes start from 1 and looping until MAXPLAYERS is bad because it's a constant value (i think of 55); looping up to MaxClients is better because that's the biggest number that could be an entity index with your maxplayer setting
Hey shavit, thanks for your tips.
The usual game is only 5 vs. 5, i don't think that the size of loop is the problem. The problem is that only the first query is executed, the other 9 (in case of 5vs5) are ignored.
I'm not sure if I'm right about this but starting a query inside the for loop will break it (end the for loop) and wait for the query to respond.
You could try using transactions instead of doing each query individually - Transactions take several queries and execute them sequentially then pass results back to callbacks.
Transaction th_Queries = null;
th_Queries = SQL_CreateTransaction();
for(int i = 1; i < MaxClients; i++)
SQL_AddQuery(th_Queries, /*Put your query here*/, /*Put your query data (if any) here*/);
SQL_Execute(hDb, th_Queries, SQL_QuerySuccess_Callback, SQL_QueryFailed_Callback);
Also don't think you can do threaded transaction queries so you will need to lock your database I would assume since you have to for regular queries, I'm not very familiar with threaded queries so if someone wants to correct me if I'm wrong please feel free
Also if you plan on passing a client id through the transaction make sure you convert it to userid then convert it back to index when the callback is called.
Transactions are the best way to catch all players instead of doing one by one.
I have an example of using two different queries to get player settings etc in my build mod: