PHP Code:
#include <sourcemod>
#include <store>
#define PLUGIN_NEV "Store top25 player"
#define PLUGIN_LERIAS "https://forums.alliedmods.net/showthread.php?t=316749"
#define PLUGIN_AUTHOR "Nexd"
#define PLUGIN_VERSION "1.0"
#pragma tabsize 0
Database g_DB;
ConVar g_adatbazis;
public Plugin myinfo =
{
name = PLUGIN_NEV,
author = PLUGIN_AUTHOR,
description = PLUGIN_LERIAS,
version = PLUGIN_VERSION
};
public void OnPluginStart()
{
g_adatbazis = CreateConVar("sm_store_db", "store", "Database for the plugin");
RegConsoleCmd("sm_storetop", Command_StoreTop);
}
public void OnConfigsExecuted() {
char error[255];
char database[32];
GetConVarString(g_adatbazis, database, sizeof(database));
g_DB = SQL_Connect(database, true, error, sizeof(error));
}
public Action Command_StoreTop(int client, int args)
{
GetStoreTopPlayers(client);
}
public Action GetStoreTopPlayers(int client) {
char Query[1024];
Format(Query, sizeof(Query), "SELECT name, credits FROM store_players ORDER BY credits DESC limit 25;");
SQL_TQuery(g_DB, CreateTopList, Query, client);
return Plugin_Handled;
}
public void CreateTopList(Handle owner, Handle hndl, const char[] error, any data) {
int client = data;
char name[128];
int credits;
Menu topcredits = CreateMenu(Nullmenuhandler);
SetMenuTitle(topcredits, "Top 25 credits");
while (SQL_FetchRow(hndl)) {
SQL_FetchString(hndl, 0, name, sizeof(name));
credits = SQL_FetchInt(hndl, 1);
Format(name, sizeof(name), "%s - %i", name, credits);
AddMenuItem(topcredits, "", name, ITEMDRAW_DISABLED);
}
DisplayMenu(topcredits, client, 60);
}
public int Nullmenuhandler(Handle menu, MenuAction action, int client, int item)
{
}