Raised This Month: $ Target: $400
 0% 

help mysql in amxx prob


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
moimel
Junior Member
Join Date: Mar 2009
Old 10-20-2009 , 16:15   help mysql in amxx prob
Reply With Quote #1

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?

Last edited by Exolent[jNr]; 10-20-2009 at 16:21. Reason: Use [CODE], [PHP], or [PAWN] tags next time.
moimel is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode