I tried the formatting and couldn't get it to line up. It added spacing, but was still off. Maybe someone else can help. Below is what I added to mine. This was the first code I have ever tried so it probably looks bad. I just looked at other codes (specifically msleepers) and did trial and error to get to work.
Compile the below as a separate plugin. The stats show automatically after the player is in the server for 100 seconds. They can also type !pounce in chat.
Code:
#include <sourcemod>
#define PLUGIN_VERSION "1.0"
//globals
#define MAX_LINE_WIDTH 150
new Handle:hDb;
public Plugin:myinfo =
{
name = "Top10Pounces",
author = "Guinn",
description = "Shows Hunter Pounce Records. Works aside pouncerecord.",
version = PLUGIN_VERSION,
url = ""
}
public OnPluginStart()
{
ConnectToDB("PounceDB");
if(hDb == INVALID_HANDLE)
return; //Don't setup the system if the DB is non responsive.
RegConsoleCmd("sm_pounce", cmd_Top10Pounce);
}
public ConnectToDB(const String:configName[])
{
new String:errorMsg[256];
if(SQL_CheckConfig(configName))
{ //config section exists
hDb = SQL_Connect(configName,true,errorMsg,sizeof(errorMsg));
if(hDb == INVALID_HANDLE)
LogError("Unable to connect to the specified host for the database configuration named %s.",configName);
else
SendSQLUpdate("SET NAMES 'utf8'");
}
else
LogError("The database configuration name %s was not present in the databases.cfg file.",configName);
}
public SendSQLUpdate(String:query[])
{
if (hDb == INVALID_HANDLE)
return;
SQL_TQuery(hDb, SQLErrorCheckCallback, query);
}
public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], any:data)
{
if (hDb == INVALID_HANDLE)
return;
if(!StrEqual("", error))
LogError("SQL Error: %s", error);
}
public OnClientPutInServer(client)
{
if (IsFakeClient(client))
return;
if (client)
CreateTimer(100.0, JustJoined, client);
}
public Action:JustJoined(Handle:timer, any:client)
{
if (IsFakeClient(client))
return;
if (client)
FakeClientCommand(client, "sm_pounce");
}
// Generate the TOP 10 Pounce Records display panel.
public Action:cmd_Top10Pounce(client, args)
{
decl String:query[256];
Format(query, sizeof(query), "SELECT pouncer, damage, distance FROM pounces ORDER BY damage DESC LIMIT 10");
SQL_TQuery(hDb, Top10pounces, query, client);
return Plugin_Handled;
}
// Send the TOP 10 Pounce Records to the client's display.
public Top10pounces(Handle:owner, Handle:hndl, const String:error[], any:data)
{
new client = data;
if (!client || hndl == INVALID_HANDLE)
return;
new String:pouncer[MAX_NAME_LENGTH];
new damage,distance
new Handle:Top10PouncePanel = CreatePanel();
SetPanelTitle(Top10PouncePanel, "---------------------Top 10 Pounces---------------------");
DrawPanelText(Top10PouncePanel, " ");
while (SQL_FetchRow(hndl))
{
SQL_FetchString(hndl, 0, pouncer, sizeof(pouncer));
ReplaceString(pouncer, sizeof(pouncer), "<", "<");
ReplaceString(pouncer, sizeof(pouncer), ">", ">");
ReplaceString(pouncer, sizeof(pouncer), "%", "%");
ReplaceString(pouncer, sizeof(pouncer), "=", "=");
ReplaceString(pouncer, sizeof(pouncer), "*", "*");
damage = SQL_FetchInt(hndl, 1);
distance = SQL_FetchInt(hndl, 2);
new String:Value[MAX_LINE_WIDTH];
Format(Value, sizeof(Value), "%s %s %s %i %s %i %s", "-", pouncer, "gave", damage, "damage at", distance /16, "ft");
DrawPanelText(Top10PouncePanel, Value);
}
SendPanelToClient(Top10PouncePanel, client, Top10PanelHandler, 5);
CloseHandle(Top10PouncePanel);
}
// Handler for Top 10 Pounce panel.
public Top10PanelHandler(Handle:menu, MenuAction:action, param1, param2)
{
}