You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

67 lines
2.5 KiB

/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <adminmenu>
#define REQUIRE_PLUGIN
#define MR_VERSION "1.0"
new Handle:g_hDatabase;
new String:cv_db[32];
new Handle:g_cvars[];
public Plugin:myinfo =
{
name = "Maprate Reloaded",
author = "Chefe",
description = "Allow players to rate the current map and view the map's average rating.",
version = MR_VERSION,
url = ""
}
public OnPluginStart()
{
LoadTranslations("maprate_rld.phrases");
RegConsoleCmd("sm_maprate", Command_Maprate);
RegConsoleCmd("sm_maprating", Command_Maprating);
RegAdminCmd("sm_maprate_clear", Command_ResetRatings, FLAG_RESET_RATINGS);
g_cvars[CVAR_DB_CONFIG] = CreateConVar("sm_maprate_db", "default", "Database configuration to use for Map Rate plugin", FCVAR_PLUGIN);
g_cvars[CVAR_VERSION] = CreateConVar("sm_maprate_version", MR_VERSION, "Map Rate Version", FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_NOTIFY);
g_cvars[CVAR_AUTORATE_TIME] = CreateConVar("sm_maprate_autorate_time", "0", "If non-zero, automatically asks dead players to rate map after they have played the map for this number of seconds", FCVAR_PLUGIN);
g_cvars[CVAR_ALLOW_REVOTE] = CreateConVar("sm_maprate_allow_revote", "1", "If non-zero, allow a user to override his/her previous vote on a map", FCVAR_PLUGIN);
g_cvars[CVAR_AUTORATE_DELAY] = CreateConVar("sm_maprate_autorate_delay", "5", "After a player dies, wait this number of seconds before asking to rate if maprate_autorate_time is non-zero", FCVAR_PLUGIN);
g_cvars[CVAR_DISMISS] = CreateConVar("sm_maprate_dismiss", "0", "If non-zero, the first voting option will be \"Dismiss\"", FCVAR_PLUGIN);
g_cvars[CVAR_RESULTS] = CreateConVar("sm_maprate_autoresults", "1", "If non-zero, the results graph will automatically be displayed when a player rates a map", FCVAR_PLUGIN);
HookEvent("player_death", Event_PlayerDeath);
AutoExecConfig(true, "maprate");
g_dismiss = GetConVarBool(g_cvars[CVAR_DISMISS]);
GetConVarString(g_cvars[CVAR_DB_CONFIG], cv_db, sizeof(cv_db));
new Handle:top_menu;
if (LibraryExists("adminmenu") && ((top_menu = GetAdminTopMenu()) != INVALID_HANDLE))
{
OnAdminMenuReady(top_menu);
}
}
InitialiseDatabase() {
if (!SQL_TConnect(g_hDatabase, cv_db)) {
LogError("Couldn't connect to database.");
}
if (g_hDatabase != INVALID_HANDLE) {
decl String:path[256];
BuildPath(Path_SM, path, sizeof(path), "configs/maprate/initialise.sql");
if (!SQLH_FastQueriesFromFile(g_hDatabase, path, true)) {
CloseHandle(g_hDatabase);
LogError("Couldn't execute initialisation queries.");
}
}
}