hello, i pulled this code from here to one of my plugins:
https://forums.alliedmods.net/showthread.php?t=220916
code:
PHP Code:
char SteamID[64];
GetClientAuthId(itarget, AuthId_Steam2, SteamID, sizeof(SteamID));
g_SteamID = SteamID;
new String:Query[255];
Format(Query, sizeof(Query), "SELECT * FROM ctban_log WHERE perp_steamid = '%s'", SteamID);
// Send our Query to the Function
if( client != 0)
SQL_TQuery(gH_BanDatabase, SQL_ReadAll, Query, GetClientUserId(client));
public SQL_ReadAll(Handle:owner, Handle:hndl, const String:error[], any:data)
{
new client = GetClientOfUserId(data);
if (!SQL_FetchRow(hndl))
{
PrintToConsole(client, " ");
PrintToConsole(client, "No history.");
return;
}
new iresults;
// We need to know the rowcount, in this case 2-1 because field begins at 0
new RowCount = SQL_GetFieldCount(hndl);
// Temp, just for debugging or so
new field;
field++;
// Buffer for our result
new String:Buffer[255];
PrintToConsole(client, " ");
PrintToConsole(client, " ");
PrintToConsole(client, "All SteamID results:");
while(SQL_FetchRow(hndl))
{
iresults++;
if(field <= 7)
PrintToConsole(client, "------------------Ban #%d------------------", field);
for(new i = 0; i< RowCount; i++)
{
if(field > 7)
{
PrintToConsole(client, " ");
PrintToConsole(client, "Listing 1 - 7");
PrintToConsole(client, "%T", "ct_banlist_more_8", LANG_SERVER);
return;
}
SQL_FetchString(hndl, i, Buffer, sizeof(Buffer));
if (StrContains(Buffer, "-1", false) == 0)
Buffer = "No timeleft";
if (StrContains(Buffer, "0", false) == 0)
Buffer = "Perm";
if(i == 1)
PrintToConsole(client, "Field %d | Row: %d | SteamID: %s", field, i, Buffer);
if(i == 2) {
PrintToConsole(client, "Field %d | Row: %d | Nick: %s", field, i, Buffer);
PrintToConsole(client, " ");
PrintToConsole(client, "Banned by:");
}
if(i == 3) {
if (StrEqual(Buffer, "STEAM_0:1:1"))
PrintToConsole(client, "Field %d | Row: %d | Admin SteamID: Console", field, i);
else
PrintToConsole(client, "Field %d | Row: %d | Admin SteamID: %s", field, i, Buffer);
}
if(i == 4) {
PrintToConsole(client, "Field %d | Row: %d | Admin nick: %s", field, i, Buffer);
PrintToConsole(client, " ");
}
if(i == 5)
PrintToConsole(client, "Field %d | Row: %d | Time: %s", field, i, Buffer);
if(i == 6)
PrintToConsole(client, "Field %d | Row: %d | Timeleft: %s", field, i, Buffer);
if(i == 7)
PrintToConsole(client, "Field %d | Row: %d | Reason: %s", field, i, Buffer);
}
PrintToConsole(client, "------------------------------------------");
PrintToConsole(client, " ");
field++;
}
PrintToConsole(client, " ");
PrintToConsole(client, "Listing 1 - 7");
PrintToConsole(client, " ");
}
its getting all results found for target's steamid from a mysql table.
but its basically skipping the very first result and doesn't print it.
it starts printing from the second result.
is there any fix for this?
to clarify, its skipping the first result that i marked with a red line: