PDA

View Full Version : [ERROR] cache_get_row_count: no active cache


AlfaSufaIndo
02/07/2018, 04:44 PM
Hi guys, i got this error in my mysql.log
[23:24:09] [ERROR] cache_get_row_count: no active cache (D:\SAMPSERVER\Roleplay\pawno\include\a_mysql.inc: 182 -> Stock/stock.pwn:48 -> Publics/ODR/registerlogin.pwn:21)

And this is my code

AssignPlayerData(playerid); // LINE: 21 (This code is only for calling AssignPlayerData)
stock AssignPlayerData(playerid)
{
new rows = cache_num_rows(); //Error line: 48
if(rows)
{
new loaded;
while(loaded < rows)
{
cache_get_value_int(loaded, "id", pInfo[playerid][ID]);
cache_get_value_int(loaded, "kills", pInfo[playerid][pKills]);
cache_get_value_int(loaded, "deaths", pInfo[playerid][pDeaths]);
cache_get_value_int(loaded, "admin", pInfo[playerid][pAdmin]);
cache_get_value_int(loaded, "vip", pInfo[playerid][pVIP]);
cache_get_value_int(loaded, "money", pInfo[playerid][pMoney]);
cache_get_value_float(loaded, "x", pInfo[playerid][X_Pos]);
cache_get_value_float(loaded, "y", pInfo[playerid][Y_Pos]);
cache_get_value_float(loaded, "z", pInfo[playerid][Z_Pos]);
cache_get_value_float(loaded, "angle", pInfo[playerid][A_Pos]);
cache_get_value_int(loaded, "interior", pInfo[playerid][pInterior]);
loaded++;
}
}
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
return 1;
}

Can you guys help me? :) Thankss!

DerickClark
02/07/2018, 04:47 PM
Don't use stock.

new rows;
cache_get_row_count(rows);

Calisthenics
02/07/2018, 04:49 PM
You call a function and then expect it to retrieve data when there is no active cache (no query executed).
You have to select the data for the player and then call the function. Take a look at example script:
https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn#L182
https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn#L312

It however stores cache in memory and sets active for later use instead of executing another query.

AlfaSufaIndo
02/07/2018, 04:49 PM
Don't use stock.

new rows;
cache_get_row_count(rows);

Okayy i'll try that!

AlfaSufaIndo
02/07/2018, 04:52 PM
So is it going to be like this?
AssignPlayerData(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows)
{
new loaded;
while(loaded < rows)
{
cache_get_value_int(loaded, "id", pInfo[playerid][ID]);
cache_get_value_int(loaded, "kills", pInfo[playerid][pKills]);
cache_get_value_int(loaded, "deaths", pInfo[playerid][pDeaths]);
cache_get_value_int(loaded, "admin", pInfo[playerid][pAdmin]);
cache_get_value_int(loaded, "vip", pInfo[playerid][pVIP]);
cache_get_value_int(loaded, "money", pInfo[playerid][pMoney]);
cache_get_value_float(loaded, "x", pInfo[playerid][X_Pos]);
cache_get_value_float(loaded, "y", pInfo[playerid][Y_Pos]);
cache_get_value_float(loaded, "z", pInfo[playerid][Z_Pos]);
cache_get_value_float(loaded, "angle", pInfo[playerid][A_Pos]);
cache_get_value_int(loaded, "interior", pInfo[playerid][pInterior]);
loaded++;
}
}
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
return 1;
}

AlfaSufaIndo
02/07/2018, 04:54 PM
You call a function and then expect it to retrieve data when there is no active cache (no query executed).
You have to select the data for the player and then call the function. Take a look at example script:
https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn#L182
https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn#L312

It however stores cache in memory and sets active for later use instead of executing another query.

Ohh I got it! Thank you for your help :D