mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Base rankings
This commit is contained in:
parent
4904685bed
commit
12f5a3926f
10
README.md
10
README.md
@ -97,9 +97,12 @@ a bhop server should be simple
|
||||
- [ ] Add strafe sync to the WR menu where available.
|
||||
- [ ] Add `sm_bwr` `sm_bonuswr` `sm_bonusworldrecord`.
|
||||
- [ ] Use unix timestamps for future record dates.
|
||||
- [ ] [rankings] Calculate points per scored time once it's added to the database.
|
||||
- [ ] [rankings] Show points in WR menu.
|
||||
|
||||
~ shavit-stats
|
||||
- [x] Make style names editable from shavit.inc (like I did to the rest of modules) (dynamic!)
|
||||
- [ ] Points implementation
|
||||
|
||||
~ shavit-misc
|
||||
- [x] Allow changing the prespeed limitation.
|
||||
@ -111,9 +114,10 @@ a bhop server should be simple
|
||||
- [x] On map finish.
|
||||
|
||||
~ [NEW PLUGIN] shavit-rankings:
|
||||
- [ ] Create tables. (`mappoints`, `playerpoints`)
|
||||
- [ ] Allow RCON admins to set ideal points for map and time for the default style.
|
||||
- [ ] Implement an algorithm that will calculate points for the map, will also take the time and style into account. Add a +25% bonus if the time is equal or better than the ideal one.
|
||||
- [x] Create tables. (`mappoints`, `playerpoints`)
|
||||
- [x] Allow ROOT admins to set ideal points for map and time for the default style.
|
||||
- [ ] Add `sm_points`.
|
||||
- [ ] Implement an algorithm that will calculate points for the current map, will also take the time and style into account. Add a +25% bonus if the time is equal or better than the ideal one.
|
||||
- [ ] Use a weighting system for points calculation. The highest ranked time will be weighted 100% and worse times will be weighted as 5% less each time.
|
||||
- [ ] Calculate points and rank for players once they connect to the server.
|
||||
- [ ] Add `sm_top` that will show the top X players, sort by points.
|
||||
|
||||
@ -141,6 +141,19 @@ char gS_ShortBhopStyles[MAX_STYLES][] =
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined USES_STYLE_MULTIPLIERS
|
||||
// ranking system
|
||||
float gI_RankingMultipliers[MAX_STYLES] =
|
||||
{
|
||||
1.00, // Forwards
|
||||
1.30, // Sideways
|
||||
1.33, // W-Only
|
||||
1.30, // Scroll
|
||||
1.50, // 400 Velocity
|
||||
1.20 // HSW
|
||||
};
|
||||
#endif
|
||||
|
||||
// map zones
|
||||
#define MULTIPLEZONES_LIMIT 32
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ bool gB_HUD = false;
|
||||
|
||||
// cvars
|
||||
ConVar gCV_Autobhop = null;
|
||||
ConVar gCV_Leftright = null;
|
||||
ConVar gCV_LeftRight = null;
|
||||
ConVar gCV_Restart = null;
|
||||
ConVar gCV_Pause = null;
|
||||
ConVar gCV_NoStaminaReset = null;
|
||||
@ -88,7 +88,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "The core for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
@ -210,7 +210,7 @@ public void OnPluginStart()
|
||||
CreateConVar("shavit_version", SHAVIT_VERSION, "Plugin version.", FCVAR_NOTIFY|FCVAR_DONTRECORD);
|
||||
|
||||
gCV_Autobhop = CreateConVar("shavit_core_autobhop", "1", "Enable autobhop?\nWill be forced to not work if STYLE_AUTOBHOP is not defined for a style!", FCVAR_NOTIFY, true, 0.0, true, 1.0);
|
||||
gCV_Leftright = CreateConVar("shavit_core_blockleftright", "1", "Block +left/right?", 0, true, 0.0, true, 1.0);
|
||||
gCV_LeftRight = CreateConVar("shavit_core_blockleftright", "1", "Block +left/right?", 0, true, 0.0, true, 1.0);
|
||||
gCV_Restart = CreateConVar("shavit_core_restart", "1", "Allow commands that restart the timer?", 0, true, 0.0, true, 1.0);
|
||||
gCV_Pause = CreateConVar("shavit_core_pause", "1", "Allow pausing?", 0, true, 0.0, true, 1.0);
|
||||
gCV_NoStaminaReset = CreateConVar("shavit_core_nostaminareset", "1", "Disables the built-in stamina reset.\nAlso known as 'easybhop'.\nWill be forced to not work if STYLE_EASYBHOP is not defined for a style!", 0, true, 0.0, true, 1.0);
|
||||
@ -769,7 +769,7 @@ public void OnClientPutInServer(int client)
|
||||
char[] sCountry = new char[45];
|
||||
GeoipCountry(sIP, sCountry, 45);
|
||||
|
||||
if(StrEqual(sCountry, ""))
|
||||
if(strlen(sCountry) == 0)
|
||||
{
|
||||
strcopy(sCountry, 45, "Local Area Network");
|
||||
}
|
||||
@ -819,7 +819,6 @@ public void SQL_SetPrefix()
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
@ -898,7 +897,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
|
||||
bool bOnLadder = (GetEntityMoveType(client) == MOVETYPE_LADDER);
|
||||
|
||||
if(gCV_Leftright.BoolValue && gB_TimerEnabled[client] && (!gB_Zones || !Shavit_InsideZone(client, Zone_Start) && (buttons & IN_LEFT || buttons & IN_RIGHT)))
|
||||
if(gCV_LeftRight.BoolValue && gB_TimerEnabled[client] && (!gB_Zones || !Shavit_InsideZone(client, Zone_Start) && (buttons & IN_LEFT || buttons & IN_RIGHT)))
|
||||
{
|
||||
Shavit_StopTimer(client);
|
||||
Shavit_PrintToChat(client, "I've stopped your timer for using +left/+right. No cheating!");
|
||||
|
||||
@ -69,7 +69,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "HUD for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
|
||||
@ -58,7 +58,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "Miscellaneous stuff for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
|
||||
212
scripting/shavit-rankings.sp
Normal file
212
scripting/shavit-rankings.sp
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* shavit's Timer - Rankings
|
||||
* by: shavit
|
||||
*
|
||||
* This file is part of shavit's Timer.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
// #define USES_STYLE_MULTIPLIERS
|
||||
#include <shavit>
|
||||
|
||||
#pragma newdecls required
|
||||
#pragma semicolon 1
|
||||
#pragma dynamic 131072
|
||||
|
||||
// cache
|
||||
char gS_Map[256];
|
||||
float gF_IdealTime = 0.0;
|
||||
float gF_Points = 0.0;
|
||||
|
||||
// database handle
|
||||
Database gH_SQL = null;
|
||||
|
||||
// table prefix
|
||||
char gS_MySQLPrefix[32];
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[shavit] Rankings",
|
||||
author = "shavit",
|
||||
description = "Rankings system for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
RegPluginLibrary("shavit-rankings");
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
{
|
||||
if(!LibraryExists("shavit-wr"))
|
||||
{
|
||||
SetFailState("shavit-wr is required for the plugin to work.");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
// database connections
|
||||
Shavit_GetDB(gH_SQL);
|
||||
SQL_SetPrefix();
|
||||
SetSQLInfo();
|
||||
|
||||
// player commands
|
||||
// sm_points
|
||||
// sm_rank
|
||||
|
||||
// admin commands
|
||||
RegAdminCmd("sm_setpoints", Command_SetPoints, ADMFLAG_ROOT, "Set points for a defined ideal time. sm_setpoints <time in seconds> <points>");
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
GetCurrentMap(gS_Map, 256);
|
||||
}
|
||||
|
||||
public Action Command_SetPoints(int client, int args)
|
||||
{
|
||||
if(args != 2)
|
||||
{
|
||||
char sArg0[32];
|
||||
GetCmdArg(0, sArg0, 32);
|
||||
|
||||
ReplyToCommand(client, "Usage: %s <time in seconds> <points>", sArg0);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sArg1[32];
|
||||
GetCmdArg(1, sArg1, 32);
|
||||
float fTime = gF_IdealTime = StringToFloat(sArg1);
|
||||
FormatSeconds(fTime, sArg1, 32, false);
|
||||
|
||||
char sArg2[32];
|
||||
GetCmdArg(2, sArg2, 32);
|
||||
float fPoints = gF_Points = StringToFloat(sArg1);
|
||||
|
||||
ReplyToCommand(client, "Set \x03%.02f\x01 points for \x05%s\x01.", fPoints, sArg1);
|
||||
|
||||
SetMapPoints(fTime, fPoints);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void SetMapPoints(float time, float points)
|
||||
{
|
||||
char[] sQuery = new char[256];
|
||||
FormatEx(sQuery, 256, "REPLACE INTO %smappoints (map, time, points) VALUES ('%s', '%.02f', '%.02f');", gS_MySQLPrefix, gS_Map, time, points);
|
||||
|
||||
gH_SQL.Query(SQL_SetPoints_Callback, sQuery, 0, DBPrio_High);
|
||||
}
|
||||
|
||||
public void SQL_SetPoints_Callback(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if(results == null)
|
||||
{
|
||||
LogError("Timer (rankings module) error! Failed to insert map data to the table. Reason: %s", error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public Action CheckForSQLInfo(Handle Timer)
|
||||
{
|
||||
return SetSQLInfo();
|
||||
}
|
||||
|
||||
public Action SetSQLInfo()
|
||||
{
|
||||
if(gH_SQL == null)
|
||||
{
|
||||
Shavit_GetDB(gH_SQL);
|
||||
|
||||
CreateTimer(0.5, CheckForSQLInfo);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SQL_DBConnect();
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public void SQL_SetPrefix()
|
||||
{
|
||||
char[] sFile = new char[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, sFile, PLATFORM_MAX_PATH, "configs/shavit-prefix.txt");
|
||||
|
||||
File fFile = OpenFile(sFile, "r");
|
||||
|
||||
if(fFile == null)
|
||||
{
|
||||
SetFailState("Cannot open \"configs/shavit-prefix.txt\". Make sure this file exists and that the server has read permissions to it.");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char[] sLine = new char[PLATFORM_MAX_PATH * 2];
|
||||
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete fFile;
|
||||
}
|
||||
|
||||
public void SQL_DBConnect()
|
||||
{
|
||||
if(SQL_CheckConfig("shavit"))
|
||||
{
|
||||
if(gH_SQL != null)
|
||||
{
|
||||
char[] sQuery = new char[256];
|
||||
FormatEx(sQuery, 256, "CREATE TABLE IF NOT EXISTS `%smappoints` (`map` VARCHAR(192), `time` FLOAT, `points` FLOAT, PRIMARY KEY (`map`));", gS_MySQLPrefix);
|
||||
gH_SQL.Query(SQL_CreateTable_Callback, sQuery);
|
||||
|
||||
FormatEx(sQuery, 256, "CREATE TABLE IF NOT EXISTS `%splayerpoints` (`recordid` INT NOT NULL, `points` FLOAT, PRIMARY KEY (`recordid`));", gS_MySQLPrefix);
|
||||
gH_SQL.Query(SQL_CreateTable_Callback, sQuery);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetFailState("Timer (rankings module) startup failed. Reason: %s", "\"shavit\" is not a specified entry in databases.cfg.");
|
||||
}
|
||||
}
|
||||
|
||||
public void SQL_CreateTable_Callback(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if(results == null)
|
||||
{
|
||||
LogError("Timer (rankings module) error! Table creation failed. Reason: %s", error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -58,7 +58,7 @@ public Plugin myinfo =
|
||||
author = "shavit, ofir",
|
||||
description = "A replay bot for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
|
||||
@ -41,7 +41,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "Play custom sounds when timer-related events happen.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
|
||||
@ -50,7 +50,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "Player stats for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
@ -114,7 +114,6 @@ public void SQL_SetPrefix()
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
|
||||
@ -52,7 +52,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "Sets a dynamic value of mp_timelimit and mp_roundtime, based on average map times on the server.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
@ -125,7 +125,6 @@ public void SQL_SetPrefix()
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
|
||||
@ -70,7 +70,7 @@ public Plugin myinfo =
|
||||
author = "shavit",
|
||||
description = "World records for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
@ -1020,7 +1020,6 @@ public void SQL_SetPrefix()
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
|
||||
@ -114,7 +114,7 @@ public Plugin myinfo =
|
||||
author = "shavit", // reminder: add ~big big big~ HUGE thanks to blacky < done
|
||||
description = "Map zones for shavit's bhop timer.",
|
||||
version = SHAVIT_VERSION,
|
||||
url = "http://forums.alliedmods.net/member.php?u=163134"
|
||||
url = "https://github.com/shavitush/bhoptimer"
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
@ -1733,7 +1733,6 @@ public void SQL_SetPrefix()
|
||||
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH * 2))
|
||||
{
|
||||
TrimString(sLine);
|
||||
|
||||
strcopy(gS_MySQLPrefix, 32, sLine);
|
||||
|
||||
break;
|
||||
|
||||
3
smbuild
3
smbuild
@ -7,9 +7,10 @@ Plugin(source='scripting/shavit-stats.sp')
|
||||
Plugin(source='scripting/shavit-timelimit.sp')
|
||||
Plugin(source='scripting/shavit-wr.sp')
|
||||
Plugin(source='scripting/shavit-zones.sp')
|
||||
Plugin(source='scripting/shavit-rankings.sp')
|
||||
|
||||
Package(name='bhoptimer',
|
||||
plugins=['shavit-core', 'shavit-hud', 'shavit-misc', 'shavit-replay', 'shavit-sounds', 'shavit-stats', 'shavit-timelimit', 'shavit-wr', 'shavit-zones'],
|
||||
plugins=['shavit-core', 'shavit-hud', 'shavit-misc', 'shavit-replay', 'shavit-sounds', 'shavit-stats', 'shavit-timelimit', 'shavit-wr', 'shavit-zones', 'shavit-rankings'],
|
||||
filegroups={
|
||||
'.': ['README.md'],
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user