28.08.2012, 17:19
(
Последний раз редактировалось ikkentim; 28.08.2012 в 18:13.
)
pawn Код:
PUBLIC:bankResponseCallback(index, query[], callback[], extraid, connectionHandle)
{
mysql_store_result();
if(mysql_retrieve_row())
{
new result[64];
mysql_get_field("money",result);
printf("index=%d", index);
/* more code... */
}
mysql_free_result();
}
GetPlayerBankMoney(playerid, const callback[], extraid1 = -1, extraid2 = -1)
{
if(!IsPlayerLoggedIn(playerid))
return 0;
new query[256];
format(query, 256, "SOME QUERY", Something(playerid));
new rid = bankFreeRequest();
printf("rid=%d", rid);
mysql_query_callback(rid, query, "bankResponseCallback");
bankRequest[rid][trUsed] = 1;
format(bankRequest[rid][trCallback], 32, "%s", callback);
bankRequest[rid][trPlayerid] = playerid;
bankRequest[rid][trExtra1] = extraid1;
bankRequest[rid][trExtra2] = extraid2;
return 0;
}
rid=0
index=6281400
Script[gamemodes\rcr-ikt-cleanup.amx]: During execution of bankResponseCallback(
):
Script[gamemodes\rcr-ikt-cleanup.amx]: Run time error 4: "Array index out of bou
nds"
Additional information:
Array max index is 99 but accessing an element at 6281400
Call stack (most recent call first):
public bankResponseCallback()
Basically, I am using mysql_query_callback, set the index to rid (which is 0), than let it respond to callback PUBLIC:bankResponseCallback. Here the index is suddenly 6281400.
I am using
> MySQL plugin R6-2 .
Does anyone know why this happens?
Thanks!
EDIT:
I looked at the Debug.txt, it says:
Код:
[19:53:15] CMySQLHandler::Query("bankResponseCallback") - Custom callback query with index 0 started (ExtraID: -1) [19:53:15] CMySQLHandler::ProcessQueryThread(Some query) - Data is getting passed to bankResponseCallback() - (Threadsafe: Yes) [19:53:15] bankResponseCallback(0,"Some query") - Called.
I found the bloody error:
Код:
forward MySqlCallback(query[], index, extraid, connectionHandle); public OnPlayerConnect(playerid) { mysql_query_callback(playerid,"SELECT * FROM `mybuildings`","MySqlCallback"); } public MySqlCallback(query[], index, extraid, connectionHandle) { //Query processed, you can execute your code now }