Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo H authored and Riccardo H committed Nov 20, 2019
2 parents b20dc7e + 3c17851 commit d1c0cfb
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 194 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

[Version 280 - current work in progress]
[2019-11-20 - Version 280pre]
---
* **[UTIL]** Updated GeoIP.dat
* **[UTIL]** More code cleanup (WIP)
Expand All @@ -26,7 +26,6 @@
* **[REQUEST/FIX]** Fixed VIP chat spam bug
* **[UTIL]** Changed VIP system


[2019-08-13 - Version 271]
---
* **[REQUEST/FIX]** Fixed `sv_maxvelocity` bug
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# z4lab-SurfTimer 280 for CS:GO

## Installation and requirements
[SourceMod 1.9](https://www.sourcemod.net/downloads.php?branch=stable), [MetaMod 1.10](https://www.sourcemm.net/downloads.php/?branch=stable) and a working MySQL instance is required for this plugin
[SourceMod 1.11](https://www.sourcemod.net/downloads.php?branch=dev), [MetaMod 1.10](https://www.sourcemm.net/downloads.php/?branch=stable) and a working MySQL instance is required for this plugin

<sup>(This version also supports SourceMod 1.10 and MetaMod 1.11)</sup>
<sup>(This version also supports ~~SourceMod 1.10~~ and MetaMod 1.11)</sup>

~ 4GB of RAM

## Changelog

Expand Down
24 changes: 16 additions & 8 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*=======================================================
= z4lab CS:GO Surftimer =
= z4lab CS:GO SurfTimer =
modified version of "SurfTimer" from fluffy for z4lab
The original version of this timer was by jonitaikaponi
= https://forums.alliedmods.net/showthread.php?t=264498 =
Expand Down Expand Up @@ -771,6 +771,10 @@ bool g_iHasEnforcedTitle[MAXPLAYERS + 1];

// disable noclip triggers toggle
bool g_iDisableTriggers[MAXPLAYERS + 1];

// auto reset
bool g_iAutoReset[MAXPLAYERS + 1];

/*---------- Run Variables ----------*/

// Clients personal record in map
Expand Down Expand Up @@ -1590,7 +1594,6 @@ char RadioCMDS[][] = // Disable radio commands
#include "surftimer/commands.sp"
#include "surftimer/hooks.sp"
#include "surftimer/buttonpress.sp"
//#include "surftimer/sql2.sp"
#include "surftimer/sqltime.sp"
#include "surftimer/timer.sp"
#include "surftimer/replay.sp"
Expand Down Expand Up @@ -1701,7 +1704,6 @@ public void OnMapStart()
// Debug Logging
if (!DirExists("addons/sourcemod/logs/surftimer"))
CreateDirectory("addons/sourcemod/logs/surftimer", 511);

BuildPath(Path_SM, g_szLogFile, sizeof(g_szLogFile), "logs/surftimer/%s.log", g_szMapName);

// Get map maxvelocity
Expand Down Expand Up @@ -1846,12 +1848,10 @@ public void OnMapStart()

// Save Locs
ResetSaveLocs();

if (!LoadColorsConfig())
{
SetFailState("Failed load \"configs/trails-colors.cfg\". File missing or invalid.");
}

SetFailState("Failed load \"configs/trails-colors.cfg\". File missing or invalid.");

gI_BeamSprite = PrecacheModel("materials/trails/beam_01.vmt", true);

AddFileToDownloadsTable("materials/trails/beam_01.vmt");
Expand Down Expand Up @@ -2768,6 +2768,14 @@ public void OnPluginStart()
gCV_BeamWidth.AddChangeHook(OnConVarChanged);
gCV_RespawnDisable.AddChangeHook(OnConVarChanged);

//Update Fix

g_TextMsg = GetUserMessageId("TextMsg");
g_HintText = GetUserMessageId("HintText");
HookUserMessage(g_TextMsg, TextMsgHintTextHook, true);
HookUserMessage(g_HintText, TextMsgHintTextHook, true);


gH_TrailChoiceCookie = RegClientCookie("trail_choice", "Trail Choice Cookie", CookieAccess_Protected);
gH_TrailHidingCookie = RegClientCookie("trail_hiding", "Trail Hiding Cookie", CookieAccess_Protected);

Expand Down
14 changes: 13 additions & 1 deletion addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Surftimer Commands
SurfTimer Commands
TODO: Cleanup and sort commands
*/
void CreateCommands()
Expand Down Expand Up @@ -203,6 +203,7 @@ void CreateCommands()
RegConsoleCmd("sm_speedmode", Command_ChangeSpeedMode, "[SurfTimer] [settings] xy/xyz/z - change speed mode");
RegConsoleCmd("sm_centerspeed", Command_CenterSpeed, "[SurfTimer] [settings] on/off - toggle center speed display");
RegConsoleCmd("sm_nctriggers", Command_ToggleNcTriggers, "[SurfTimer] [settings] on/off - toggle triggers while noclipping");
RegConsoleCmd("sm_autoreset", Command_ToggleAutoReset, "[SurfTimer] [settings] on/off - toggle auto reset for your current map/bonus run if your above your pb");

// Trails
RegConsoleCmd("sm_trail", Command_Trail, "Opens the 'Trail Selection' menu.");
Expand All @@ -212,6 +213,17 @@ void CreateCommands()

}

public Action Command_ToggleAutoReset(int client, int args) {
if (g_iAutoReset[client]) {
g_iAutoReset[client] = false;
CPrintToChat(client, "%t", "AutoResetDisabled", g_szChatPrefix);
} else {
g_iAutoReset[client] = true;
CPrintToChat(client, "%t", "AutoResetEnabled", g_szChatPrefix);
}
return Plugin_Handled;
}

public Action Command_ToggleNcTriggers(int client, int args) {
if (g_iDisableTriggers[client]) {
g_iDisableTriggers[client] = false;
Expand Down
8 changes: 4 additions & 4 deletions addons/sourcemod/scripting/surftimer/convars.sp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void CreateConVars()
g_hAnnounceRecord = CreateConVar("ck_chat_record_type", "0", "0: Announce all times to chat, 1: Only announce PB's to chat, 2: Only announce SR's to chat", FCVAR_NOTIFY, true, 0.0, true, 2.0);
g_hForceCT = CreateConVar("ck_force_players_ct", "0", "Forces all players to join the CT team.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_hChatSpamFilter = CreateConVar("ck_chat_spamprotection_time", "1.0", "The frequency in seconds that players are allowed to send chat messages. 0.0 = No chat cap.", FCVAR_NOTIFY, true, 0.0);
g_henableChatProcessing = CreateConVar("ck_chat_enable", "1", "(1 / 0) Enable or disable Surftimers chat processing.", FCVAR_NOTIFY);
g_henableChatProcessing = CreateConVar("ck_chat_enable", "1", "(1 / 0) Enable or disable SurfTimers chat processing.", FCVAR_NOTIFY);
g_hMultiServerMapcycle = CreateConVar("ck_multi_server_mapcycle", "0", "0 = Use mapcycle.txt to load servers maps, 1 = use configs/surftimer/multi_server_mapcycle.txt to load maps", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_hDBMapcycle = CreateConVar("ck_db_mapcycle", "1", "0 = use non-db map cycles, 1 use maps from ck_maptier", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_hTriggerPushFixEnable = CreateConVar("ck_triggerpushfix_enable", "1", "Enables trigger push fix.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
Expand Down Expand Up @@ -291,7 +291,7 @@ void CreateConVars()
validFlag = FindFlagByChar(szFlag[0], bufferFlag);
if (!validFlag)
{
PrintToServer("Surftimer | Invalid flag for ck_adminmenu_flag.");
PrintToServer("SurfTimer | Invalid flag for ck_adminmenu_flag.");
g_AdminMenuFlag = ADMFLAG_ROOT;
}
else
Expand All @@ -303,7 +303,7 @@ void CreateConVars()
validFlag = FindFlagByChar(szFlag[0], bufferFlag);
if (!validFlag)
{
LogError("Surftimer | Invalid flag for ck_zoner_flag, using ADMFLAG_ROOT");
LogError("SurfTimer | Invalid flag for ck_zoner_flag, using ADMFLAG_ROOT");
g_ZonerFlag = ADMFLAG_ROOT;
}
else
Expand All @@ -319,7 +319,7 @@ void CreateConVars()
validFlag = FindFlagByChar(szFlag[0], bufferFlag);
if (!validFlag)
{
LogError("Surftimer | Invalid flag for ck_vip_flag");
LogError("SurfTimer | Invalid flag for ck_vip_flag");
g_VipFlag = ADMFLAG_RESERVATION;
}
else
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/db/queries.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ char sql_insertmaptier[] = "INSERT INTO ck_maptier (mapname, tier) VALUES ('%s',
char sql_updatemaptier[] = "UPDATE ck_maptier SET tier = %i WHERE mapname ='%s'";

// ck_playeroptions2
char sql_createPlayerOptions[] = "CREATE TABLE `ck_playeroptions2` (`steamid` varchar(32) NOT NULL DEFAULT '', `timer` int(11) NOT NULL DEFAULT '1', `hide` int(11) NOT NULL DEFAULT '0', `sounds` int(11) NOT NULL DEFAULT '1', `chat` int(11) NOT NULL DEFAULT '0', `viewmodel` int(11) NOT NULL DEFAULT '1', `autobhop` int(11) NOT NULL DEFAULT '1', `checkpoints` int(11) NOT NULL DEFAULT '1', `gradient` int(11) NOT NULL DEFAULT '3', `speedmode` int(11) NOT NULL DEFAULT '0', `centrespeed` int(11) NOT NULL DEFAULT '0', `centrehud` int(11) NOT NULL DEFAULT '1', teleside int(11) NOT NULL DEFAULT '0', `module1c` int(11) NOT NULL DEFAULT '1', `module2c` int(11) NOT NULL DEFAULT '2', `module3c` int(11) NOT NULL DEFAULT '3', `module4c` int(11) NOT NULL DEFAULT '4', `module5c` int(11) NOT NULL DEFAULT '5', `module6c` int(11) NOT NULL DEFAULT '6', `sidehud` int(11) NOT NULL DEFAULT '1', `module1s` int(11) NOT NULL DEFAULT '5', `module2s` int(11) NOT NULL DEFAULT '0', `module3s` int(11) NOT NULL DEFAULT '0', `module4s` int(11) NOT NULL DEFAULT '0', `module5s` int(11) NOT NULL DEFAULT '0', prestrafe int(11) NOT NULL DEFAULT '0', cpmessages int(11) NOT NULL DEFAULT '1', wrcpmessages int(11) NOT NULL DEFAULT '1' PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;";
char sql_createPlayerOptions[] = "CREATE TABLE `ck_playeroptions2` (`steamid` varchar(32) NOT NULL DEFAULT '', `timer` int(11) NOT NULL DEFAULT '1', `hide` int(11) NOT NULL DEFAULT '0', `sounds` int(11) NOT NULL DEFAULT '1', `chat` int(11) NOT NULL DEFAULT '0', `viewmodel` int(11) NOT NULL DEFAULT '1', `autobhop` int(11) NOT NULL DEFAULT '1', `checkpoints` int(11) NOT NULL DEFAULT '1', `gradient` int(11) NOT NULL DEFAULT '3', `speedmode` int(11) NOT NULL DEFAULT '0', `centrespeed` int(11) NOT NULL DEFAULT '0', `centrehud` int(11) NOT NULL DEFAULT '1', teleside int(11) NOT NULL DEFAULT '0', `module1c` int(11) NOT NULL DEFAULT '1', `module2c` int(11) NOT NULL DEFAULT '2', `module3c` int(11) NOT NULL DEFAULT '3', `module4c` int(11) NOT NULL DEFAULT '4', `module5c` int(11) NOT NULL DEFAULT '5', `module6c` int(11) NOT NULL DEFAULT '6', `sidehud` int(11) NOT NULL DEFAULT '1', `module1s` int(11) NOT NULL DEFAULT '5', `module2s` int(11) NOT NULL DEFAULT '0', `module3s` int(11) NOT NULL DEFAULT '0', `module4s` int(11) NOT NULL DEFAULT '0', `module5s` int(11) NOT NULL DEFAULT '0', prestrafe int(11) NOT NULL DEFAULT '0', cpmessages int(11) NOT NULL DEFAULT '1', wrcpmessages int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;";
char sql_insertPlayerOptions[] = "INSERT INTO ck_playeroptions2 (steamid) VALUES ('%s');";
char sql_selectPlayerOptions[] = "SELECT timer, hide, sounds, chat, viewmodel, autobhop, checkpoints, gradient, speedmode, centrespeed, centrehud, teleside, module1c, module2c, module3c, module4c, module5c, module6c, sidehud, module1s, module2s, module3s, module4s, module5s, prestrafe, cpmessages, wrcpmessages FROM ck_playeroptions2 where steamid = '%s';";
char sql_updatePlayerOptions[] = "UPDATE ck_playeroptions2 SET timer = %i, hide = %i, sounds = %i, chat = %i, viewmodel = %i, autobhop = %i, checkpoints = %i, gradient = %i, speedmode = %i, centrespeed = %i, centrehud = %i, teleside = %i, module1c = %i, module2c = %i, module3c = %i, module4c = %i, module5c = %i, module6c = %i, sidehud = %i, module1s = %i, module2s = %i, module3s = %i, module4s = %i, module5s = %i, prestrafe = %i, cpmessages = %i, wrcpmessages = %i where steamid = '%s'";
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/hooks.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Surftimer Hooks
SurfTimer Hooks
TODO: Cleanup, si si
*/

Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/mapsettings.sp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public void SQL_UnlimitAllStagesCallback(Handle owner, Handle hndl, const char[]
{
if (hndl == null)
{
LogError("[Surftimer] SQL Error (SQL_UnlimitAllStagesCallback): %s", error);
LogError("[SurfTimer] SQL Error (SQL_UnlimitAllStagesCallback): %s", error);
return;
}

Expand Down
27 changes: 22 additions & 5 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2752,8 +2752,17 @@ public void CheckRun(int client)
if (g_fCurrentRunTime[client] > g_fPersonalRecord[client] && !g_bMissedMapBest[client] && !g_bPause[client] && g_iClientInZone[client][2] == 0)
{
g_bMissedMapBest[client] = true;
if (g_fPersonalRecord[client] > 0.0)
if (g_fPersonalRecord[client] > 0.0) {
CPrintToChat(client, "%t", "MissedMapBest", g_szChatPrefix, g_szPersonalRecord[client]);
if (g_iAutoReset[client] && g_iCurrentStyle[client] == 0) {
Command_Restart(client, 1);
CPrintToChat(client, "%t", "AutoResetMessage1", g_szChatPrefix);
CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix);
} else if (g_iAutoReset[client] && g_iCurrentStyle[client] != 0) {
CPrintToChat(client, "%t", "AutoResetMessageStyle", g_szChatPrefix, g_szStyleMenuPrint[g_iCurrentStyle[client]]);
CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix);
}
}
EmitSoundToClient(client, "buttons/button18.wav", client);
}
else
Expand All @@ -2764,6 +2773,14 @@ public void CheckRun(int client)
{
g_bMissedBonusBest[client] = true;
CPrintToChat(client, "%t", "Misc29", g_szChatPrefix, g_szPersonalRecordBonus[g_iClientInZone[client][2]][client]);
if (g_iAutoReset[client] && g_iCurrentStyle[client] == 0) {
Command_Teleport(client, 0);
CPrintToChat(client, "%t", "AutoResetMessage1", g_szChatPrefix);
CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix);
} else if (g_iAutoReset[client] && g_iCurrentStyle[client] != 0) {
CPrintToChat(client, "%t", "AutoResetMessageStyle", g_szChatPrefix, g_szStyleMenuPrint[g_iCurrentStyle[client]]);
CPrintToChat(client, "%t", "AutoResetMessage2", g_szChatPrefix);
}
EmitSoundToClient(client, "buttons/button18.wav", client);
}
}
Expand Down Expand Up @@ -3060,7 +3077,7 @@ public void CreateNavFile()
Format(szSource, sizeof(szSource), "maps/replay_bot.nav");
if (!FileExists(szSource))
{
LogError("[Surftimer] Failed to create .nav files. %s doesn't exist!", szSource);
LogError("[SurfTimer] Failed to create .nav files. %s doesn't exist!", szSource);
return;
}

Expand Down Expand Up @@ -4331,7 +4348,7 @@ bool IsPlayerVip(int client, bool admin = true, bool reply = false)
if (reply)
{
CPrintToChat(client, "%t", "Misc43", g_szChatPrefix);
PrintToConsole(client, "surftimer | This is a VIP feature");
PrintToConsole(client, "SurfTimer | This is a VIP feature");
}
return false;
}
Expand Down Expand Up @@ -4470,7 +4487,7 @@ public void ReadDefaultTitlesWhitelist()
CloseHandle(whitelist);
}
else
LogError("[Surftimer] %s not found", DEFAULT_TITLES_WHITELIST_PATH);
LogError("[SurfTimer] %s not found", DEFAULT_TITLES_WHITELIST_PATH);
}

public void LoadDefaultTitle(int client)
Expand Down Expand Up @@ -4540,7 +4557,7 @@ public void LoadDefaultTitle(int client)
delete kv;
}
else
LogError("[Surftimer] %s not found", DEFAULT_TITLES_PATH);
LogError("[SurfTimer] %s not found", DEFAULT_TITLES_PATH);
}

public void SetDefaultTitle(int client, const char szTitle[256])
Expand Down
102 changes: 102 additions & 0 deletions addons/sourcemod/scripting/surftimer/newmaps.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
void CreateCommandsNewMap()
{
RegConsoleCmd("sm_newmap", Client_NewMap, "[surftimer] shows new maps");
RegConsoleCmd("sm_nm", Client_NewMap, "[surftimer] shows new maps");
RegAdminCmd("sm_addnewmap", Client_AddNewMap, ADMFLAG_ROOT, "[surftimer] add a new map");
RegAdminCmd("sm_anm", Client_AddNewMap, ADMFLAG_ROOT, "[surftimer] add a new map");

db_present();
}

public Action Client_NewMap(int client, int args)
{
db_ViewNewestMaps(client);
return Plugin_Handled;
}

public Action Client_AddNewMap(int client, int args)
{
db_InsertNewestMaps();
return Plugin_Handled;
}

public int NewMapMenuHandler(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_End)
CloseHandle(menu);
}


public void db_ViewNewestMaps(int client)
{
char sql_selectNewestMaps[] = "SELECT mapname, date FROM ck_newmaps ORDER BY date DESC LIMIT 50";
SQL_TQuery(g_hDb, sql_selectNewestMapsCallback, sql_selectNewestMaps, client, DBPrio_Low);
}

public void sql_selectNewestMapsCallback(Handle owner, Handle hndl, const char[] error, any data)
{
if (hndl == null)
{
LogError("[Surftimer] SQL Error (sql_selectNewestMapsCallback): %s", error);
return;
}

char szMapName[64];
char szDate[64];
if (SQL_HasResultSet(hndl))
{
Menu menu = CreateMenu(NewMapMenuHandler);
SetMenuTitle(menu, "New Maps: ");

int i = 1;
char szItem[128];
while (SQL_FetchRow(hndl))
{
SQL_FetchString(hndl, 0, szMapName, 64);
SQL_FetchString(hndl, 1, szDate, 64);
Format(szItem, sizeof(szItem), "%s since %s", szMapName, szDate);
AddMenuItem(menu, "", szItem, ITEMDRAW_DISABLED);
i++;
}
if (i == 1)
{
CloseHandle(menu);
}
else
{
SetMenuOptionFlags(menu, MENUFLAG_BUTTON_EXIT);
DisplayMenu(menu, data, MENU_TIME_FOREVER);
}
}
}

public void db_InsertNewestMaps()
{
char sql_insertNewestMaps[] = "INSERT INTO ck_newmaps (mapname) VALUES('%s');";
char szQuery[512];
Format(szQuery, 512, sql_insertNewestMaps, g_szMapName);
SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, DBPrio_Low);
}

//update Database just incase
public void db_present()
{
// Check for db upgrades
if (!SQL_FastQuery(g_hDb, "SELECT mapname FROM ck_newmaps LIMIT 1"))
{
db_upgradeDbNewMap();
return;
}
}


public void db_upgradeDbNewMap()
{
char sql_createNewestMaps[] = "CREATE TABLE IF NOT EXISTS ck_newmaps (mapname VARCHAR(32), date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(mapname)) DEFAULT CHARSET=utf8mb4;";

Transaction createTableTnx = SQL_CreateTransaction();

SQL_AddQuery(createTableTnx, sql_createNewestMaps);

SQL_ExecuteTransaction(g_hDb, createTableTnx, SQLTxn_CreateDatabaseSuccess, SQLTxn_CreateDatabaseFailed);
}
Loading

0 comments on commit d1c0cfb

Please sign in to comment.