while(SOMETHING) {
SendClientMessage(FACTIONS)
}
CMD:faclist(playerid, params[])
{
if(!AdminOnDuty(playerid) && pInfo[playerid][pAdmin] >= 6) return SendClientMessage(playerid, -1, NODUTY);
SendClientMessage(playerid, ORANGE_ADMIN, "Factions:");
new ccount;
new sql[80], row;
format(sql, sizeof(sql), "SELECT * FROM factions ORDER BY fID DESC");
mysql_query(g_SQL, sql);
cache_get_row_count(row);
ccount = row;
for(new x = 1; x <= ccount; x++)
{
mysql_format(g_SQL, sql, sizeof(sql), "SELECT * FROM `factions` WHERE `fID` = %d", x);
mysql_query(g_SQL, sql);
cache_get_value_int(0, "ID", fInfo[x][fID]);
cache_get_value_name(0, "Name", fInfo[x][fName]);
new string[50];
format(string, sizeof(string), "ID %d: %s", fInfo[x][fID], fInfo[x][fName]);
SendClientMessage(playerid, ORANGE_ADMIN, string);
}
return 1;
}
[02:47:46] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0') [02:47:46] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
LoadFaccs()
{
new Query[180];
new sql[80];
format(sql, sizeof(sql), "SELECT * FROM facciones ORDER BY fID DESC");
mysql_query(g_SQL, sql);
new rows = cache_get_row_count(rows);
for(new x = 0, j = rows ; x < j; x++)
{
mysql_format(g_SQL, Query, sizeof(Query), "SELECT * FROM `facciones` WHERE `fID` = %d", x);
mysql_query(g_SQL, Query);
cache_get_value_int(0, "fID", fInfo[x][fID]);
cache_get_value_name(0, "fNombre", fInfo[x][fNombre]);
cache_get_value_name(0, "fRango1", fInfo[x][fRango1]);
cache_get_value_name(0, "fRango2", fInfo[x][fRango2]);
cache_get_value_name(0, "fRango3", fInfo[x][fRango3]);
cache_get_value_name(0, "fRango4", fInfo[x][fRango4]);
cache_get_value_name(0, "fRango5", fInfo[x][fRango5]);
cache_get_value_name(0, "fRango6", fInfo[x][fRango6]);
cache_get_value_name(0, "fRango7", fInfo[x][fRango7]);
cache_get_value_int(0, "fTipo", fInfo[x][fTipo]);
if(TotalFaccs < x) TotalFaccs = x;
}
printf("Facciones cargadas: %d (MAX: %d)", TotalFaccs, MAX_FACTIONS);
}
I don't know why I'm getting this invalid row index. I know It has something to do with deleted rows, but I need to be able to delete them.
|
You do NOT need the second query. At all. You already have the entire result set from the first query. Remove the second query and replace 0 with x in the cache_get_value statements.
|
ID | NAME -------------- 0 No // I don't need a ID 0 1 Goverment 2 LSPD 4 LSMD
CMD:factlist(playerid, params[])
{
if(!AdminOnDuty(playerid) && pInfo[playerid][pAdmin] >= 6) return SendClientMessage(playerid, -1, NODUTY);
SendClientMessage(playerid, ORANGE_ADMIN, "Factions:");
for(new x=1; x<=TotalFaccs; x++)
{
new string[500];
format(string, sizeof(string), "ID %d: %s", x, fInfo[x][fName]);
SendClientMessage(playerid, ORANGE_ADMIN, string);
}
return 1;
}