Help sql_threadquery
I have somthing like this:
PHP Code:
public getValue_Frags(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) { if(FailState == TQUERY_CONNECT_FAILED) return set_fail_state("Could not connect to SQL database.") else if(FailState == TQUERY_QUERY_FAILED) return log_amx("Query failed.") if(Errcode) return log_amx("Query failed.",Error) new Steam[64], msg[1024]; get_user_authid(currIncreaseID_Frags, Steam, 63); new numRows = SQL_AffectedRows ( Query ); if (numRows == 1) { new currentValue; while(SQL_MoreResults(Query)) { currentValue = SQL_ReadResult(Query, currIncreaseRowIndex_Frags); SQL_NextRow(Query); } currentValue+=currIncreaseValue_Frags; format(msg, 1023, "UPDATE %s SET %s='%d' WHERE steam='%s'", currIncreaseTableName_Frags, currIncreaseRowName_Frags, currentValue, Steam); SQL_ThreadQuery(g_SqlTuple,"QueryHandle",msg); } return PLUGIN_CONTINUE; } public Frags ( id, row, val, tbl[64], rowname[64] ) { new Steam[64]; get_user_authid(id, Steam, 63); new msg[1024]; currIncreaseID_Frags = id; currIncreaseRowIndex_Frags = row; currIncreaseValue_Frags = val; format (currIncreaseTableName_Frags, 63, "%s", tbl); format (currIncreaseRowName_Frags, 63, "%s", rowname); format(msg, 1023, "SELECT * FROM fs_stats WHERE steam='%s' LIMIT 1", Steam) SQL_ThreadQuery(g_SqlTuple,"getValue_Frags",msg) }
Frags() is being called when client_death event is occuring. because I cannot pass arguments directly to the getValue_Frags function through SQL_ThreadQuery() I am using global variables like currIncreaseID_Frags, currIncreaseRowIndex_Frags ... which I don't really like this method but lack of other ideas I am using it. anyway when the Frags() function is called many times (i. e someone is killing three players simultaneously)
than the global vars are being mixed , the first kill vars are overwriten by the second and the first kill getValue_Frags() is getting the second kill vars and so on!!!
any idea to solve it? I tried everything in my knowledge.
|