For some reason my FetchInt is throwing an error.
PHP Code:
public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
playerDeflects[client] = 0;
playerKills[attacker]++;
char query[1024], map[64], steamid[32];
GetCurrentMap(map, sizeof(map));
GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
Format(query, sizeof(query), "SELECT `top_kpl` FROM `dbstats_%s_season%d_%d` WHERE steamid = '%s'", map, GetConVarInt(cvarSeason), seasonYear, steamid);
db.Query(T_CheckTopKPL, query, GetClientUserId(client));
}
public void T_CheckTopKPL(Database hndl, DBResultSet results, const char[] error, any data)
{
int client = 0;
if ((client = GetClientOfUserId(data)) == 0)return;
if (results == null)
{
LogError("T_CheckTopKPL query failed: %s", error);
return;
}
if (results.RowCount == 0)
{
LogError("T_CheckTopKPL: For some reasons there are no rows");
return;
}
int top_kpl;
top_kpl = results.FetchInt(1);
if (playerKills[client] > top_kpl)
{
char query[1024], map[64], steamid[32];
GetCurrentMap(map, sizeof(map));
GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
Format(query, sizeof(query), "UPDATE `dbstats_%s_season%d_%d` SET `top_kpl` = '%s' WHERE steamid = '%s'", map, GetConVarInt(cvarSeason), seasonYear, playerKills[client], steamid);
db.Query(T_UpdateTopKPL, query, GetClientUserId(client));
}
}
Code:
L 02/11/2017 - 04:02:45: [SM] Exception reported: Current result set has no fetched rows
L 02/11/2017 - 04:02:45: [SM] Blaming: dbstats.smx
L 02/11/2017 - 04:02:45: [SM] Call stack trace:
L 02/11/2017 - 04:02:45: [SM] [0] DBResultSet.FetchInt
L 02/11/2017 - 04:02:45: [SM] [1] Line 271, C:\Users\xnano\Desktop\Stuff\Server Stuff\The Cube\Sourcemod Plugin Stuff\scripting\dbstats.sp::T_CheckTopKPL
Line 271 is top_kpl = results.FetchInt(1);
I've tried FetchInt(0) and that didn't work either.
And I know it is selecting rows because:
What am I doing wrong?
__________________