Hey im using amx to communicate with mysql server to do some checkings.
how ever it causes some stacks and lags , it's a while that loops all players in the server and query the sql for each player . this loop might cause this stacks. i wonder if there is any function that can delay or sleep the code for 100ms or somthing like this to depress the lags.
code:
Code:
g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
if(SqlConnection == Empty_Handle)
{
return PLUGIN_HANDLED;
}
new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT * FROM blah WHERE blah ='%s' LIMIT 1", blah)
if(!SQL_Execute(Query))
{
SQL_QueryError(Query,g_Error,511)
return PLUGIN_HANDLED;
}
new numRows = SQL_AffectedRows ( Query );
if (numRows == 1)
{
new currentValue;
while(SQL_MoreResults(Query))
{
currentValue = SQL_ReadResult(Query, 7);
SQL_NextRow(Query);
}
currentValue+=1;
new Handle:Query_Update = SQL_PrepareQuery(SqlConnection,"UPDATE blah SET blah='%d' WHERE blah='%s'", blah , blah );
SQL_Execute(Query_Update);
SQL_FreeHandle(Query_Update);
}
SQL_FreeHandle(Query)
* dont mind the blah's (:
any suggestions to solve the lags?