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

Commit

Permalink
cp/wrcp messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo H committed Aug 2, 2019
1 parent a5ae6f7 commit 808871c
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 10 deletions.
5 changes: 5 additions & 0 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ bool g_iPrespeedText[MAXPLAYERS + 1];
// Silent Spectate
bool g_iSilentSpectate[MAXPLAYERS + 1];

// CP Messages
bool g_iCpMessages[MAXPLAYERS + 1];

// WRCP Messeages
bool g_iWrcpMessages[MAXPLAYERS + 1];
/*---------- Run Variables ----------*/

// Clients personal record in map
Expand Down
26 changes: 26 additions & 0 deletions addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,35 @@ void CreateCommands()
RegConsoleCmd("sm_prestrafe", Command_Prestrafe, "[surftimer] [settings] Toggles prestrafe messages for player");
RegConsoleCmd("sm_silentspec", Command_SilentSpec, "[surftimer] [settings] Toggles silent spectate for player");
RegConsoleCmd("sm_sspec", Command_SilentSpec, "[surftimer] [settings] Toggles silent spectate for player");
RegConsoleCmd("sm_togglewrcps", Command_ToggleWrcps, "[surftimer] on/off - Enable player checkpoints");
RegConsoleCmd("sm_togglecps", Command_ToggleCps, "[surftimer] on/off - Enable player checkpoints");

}

public Action Command_ToggleWrcps(int client, int args) {
if (g_iWrcpMessages[client]) {
g_iWrcpMessages[client] = false;
CPrintToChat(client, "%t", "ToggleWrcpsMessageToggleOff", g_szChatPrefix);
}
else {
g_iWrcpMessages[client] = true;
CPrintToChat(client, "%t", "ToggleWrcpsMessageToggleOn", g_szChatPrefix);
}
return Plugin_Handled;
}

public Action Command_ToggleCps(int client, int args) {
if (g_iCpMessages[client]) {
g_iCpMessages[client] = false;
CPrintToChat(client, "%t", "ToggleCpsMessageToggleOff", g_szChatPrefix);
}
else {
g_iCpMessages[client] = true;
CPrintToChat(client, "%t", "ToggleCpsMessageToggleOn", g_szChatPrefix);
}
return Plugin_Handled;
}

public Action Command_SilentSpec(int client, int args) {
if (!IsPlayerVip(client)) return Plugin_Handled;

Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/surftimer/db/queries.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ 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', 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 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 where steamid = '%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'";

// ck_playerrank
char sql_createPlayerRank[] = "CREATE TABLE IF NOT EXISTS `ck_playerrank` (`steamid` varchar(32) NOT NULL DEFAULT '', `steamid64` varchar(64) DEFAULT NULL, `name` varchar(32) DEFAULT NULL, `country` varchar(32) DEFAULT NULL, `points` int(12) DEFAULT '0', `wrpoints` int(12) NOT NULL DEFAULT '0', `wrbpoints` int(12) NOT NULL DEFAULT '0', `wrcppoints` int(11) NOT NULL DEFAULT '0', `top10points` int(12) NOT NULL DEFAULT '0', `groupspoints` int(12) NOT NULL DEFAULT '0', `mappoints` int(11) NOT NULL DEFAULT '0', `bonuspoints` int(12) NOT NULL DEFAULT '0', `finishedmaps` int(12) DEFAULT '0', `finishedmapspro` int(12) DEFAULT '0', `finishedbonuses` int(12) NOT NULL DEFAULT '0', `finishedstages` int(12) NOT NULL DEFAULT '0', `wrs` int(12) NOT NULL DEFAULT '0', `wrbs` int(12) NOT NULL DEFAULT '0', `wrcps` int(12) NOT NULL DEFAULT '0', `top10s` int(12) NOT NULL DEFAULT '0', `groups` int(12) NOT NULL DEFAULT '0', `lastseen` int(64) DEFAULT NULL, `joined` int(64) NOT NULL, `timealive` int(64) NOT NULL DEFAULT '0', `timespec` int(64) NOT NULL DEFAULT '0', `connections` int(64) NOT NULL DEFAULT '1', `readchangelog` int(11) NOT NULL DEFAULT '0', `style` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`steamid`, `style`)) DEFAULT CHARSET=utf8mb4;";
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3989,7 +3989,7 @@ public void Checkpoint(int client, int zone, int zonegroup, float time)
/* Finish the call, get the result */
Call_Finish();

if (g_bCheckpointsEnabled[client])
if (g_bCheckpointsEnabled[client] && g_iCpMessages[client])
CPrintToChat(client, "%t", "Misc30", g_szChatPrefix, g_iClientInZone[client][1] + 1, szTime, szDiff, sz_srDiff);

Format(szSpecMessage, sizeof(szSpecMessage), "%t", "Misc31", g_szChatPrefix, szName, g_iClientInZone[client][1] + 1, szTime, szDiff, sz_srDiff);
Expand Down Expand Up @@ -4026,7 +4026,7 @@ public void Checkpoint(int client, int zone, int zonegroup, float time)

if (percent > -1.0)
{
if (g_bCheckpointsEnabled[client])
if (g_bCheckpointsEnabled[client] && g_iCpMessages[client])
CPrintToChat(client, "%t", "Misc32", g_szChatPrefix, g_iClientInZone[client][1] + 1, szTime, sz_srDiff);

Format(szSpecMessage, sizeof(szSpecMessage), "%t", "Misc33", g_szChatPrefix, szName, g_iClientInZone[client][1] + 1, szTime, sz_srDiff);
Expand All @@ -4046,7 +4046,7 @@ public void CheckpointToSpec(int client, char[] buffer)
if (SpecMode == 4 || SpecMode == 5)
{
int Target = GetEntPropEnt(x, Prop_Send, "m_hObserverTarget");
if (Target == client)
if (Target == client && g_iCpMessages[x])
CPrintToChat(x, "%s", buffer);
}
}
Expand Down
14 changes: 11 additions & 3 deletions addons/sourcemod/scripting/surftimer/sql.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5483,6 +5483,9 @@ public void db_viewPlayerOptionsCallback(Handle owner, Handle hndl, const char[]
g_iSideHudModule[client][3] = SQL_FetchInt(hndl, 22);
g_iSideHudModule[client][4] = SQL_FetchInt(hndl, 23);
g_iPrespeedText[client] = view_as<bool>(SQL_FetchInt(hndl, 24));
g_iCpMessages[client] = view_as<bool>(SQL_FetchInt(hndl, 25));
g_iWrcpMessages[client] = view_as<bool>(SQL_FetchInt(hndl, 26));


// Functionality for normal spec list
if (g_iSideHudModule[client][0] == 5 && (g_iSideHudModule[client][1] == 0 && g_iSideHudModule[client][2] == 0 && g_iSideHudModule[client][3] == 0 && g_iSideHudModule[client][4] == 0))
Expand Down Expand Up @@ -5529,6 +5532,8 @@ public void db_viewPlayerOptionsCallback(Handle owner, Handle hndl, const char[]
g_iSideHudModule[client][4] = 0;
g_bSpecListOnly[client] = true;
g_iPrespeedText[client] = false;
g_iCpMessages[client] = false;
g_iWrcpMessages[client] = false;
}

if (!g_bSettingsLoaded[client])
Expand All @@ -5549,7 +5554,7 @@ public void db_updatePlayerOptions(int client)
// "UPDATE ck_playeroptions2 SET timer = %i, hide = %i, sounds = %i, chat = %i, viewmodel = %i, autobhop = %i, checkpoints = %i, centrehud = %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 where steamid = '%s'";
if (g_bSettingsLoaded[client] && g_bServerDataLoaded && g_bLoadedModules[client])
{
Format(szQuery, 1024, sql_updatePlayerOptions, BooltoInt(g_bTimerEnabled[client]), BooltoInt(g_bHide[client]), BooltoInt(g_bEnableQuakeSounds[client]), BooltoInt(g_bHideChat[client]), BooltoInt(g_bViewModel[client]), BooltoInt(g_bAutoBhopClient[client]), BooltoInt(g_bCheckpointsEnabled[client]), g_SpeedGradient[client], g_SpeedMode[client], BooltoInt(g_bCenterSpeedDisplay[client]), BooltoInt(g_bCentreHud[client]), g_iTeleSide[client], g_iCentreHudModule[client][0], g_iCentreHudModule[client][1], g_iCentreHudModule[client][2], g_iCentreHudModule[client][3], g_iCentreHudModule[client][4], g_iCentreHudModule[client][5], BooltoInt(g_bSideHud[client]), g_iSideHudModule[client][0], g_iSideHudModule[client][1], g_iSideHudModule[client][2], g_iSideHudModule[client][3], g_iSideHudModule[client][4], BooltoInt(g_iPrespeedText[client]), g_szSteamID[client]);
Format(szQuery, 1024, sql_updatePlayerOptions, BooltoInt(g_bTimerEnabled[client]), BooltoInt(g_bHide[client]), BooltoInt(g_bEnableQuakeSounds[client]), BooltoInt(g_bHideChat[client]), BooltoInt(g_bViewModel[client]), BooltoInt(g_bAutoBhopClient[client]), BooltoInt(g_bCheckpointsEnabled[client]), g_SpeedGradient[client], g_SpeedMode[client], BooltoInt(g_bCenterSpeedDisplay[client]), BooltoInt(g_bCentreHud[client]), g_iTeleSide[client], g_iCentreHudModule[client][0], g_iCentreHudModule[client][1], g_iCentreHudModule[client][2], g_iCentreHudModule[client][3], g_iCentreHudModule[client][4], g_iCentreHudModule[client][5], BooltoInt(g_bSideHud[client]), g_iSideHudModule[client][0], g_iSideHudModule[client][1], g_iSideHudModule[client][2], g_iSideHudModule[client][3], g_iSideHudModule[client][4], BooltoInt(g_iPrespeedText[client]), BooltoInt(g_iCpMessages[client]), BooltoInt(g_iWrcpMessages[client]), g_szSteamID[client]);
SQL_TQuery(g_hDb, SQL_CheckCallback, szQuery, client, DBPrio_Low);
}
}
Expand Down Expand Up @@ -5866,13 +5871,16 @@ public void sql_selectWrcpRecordCallback(Handle owner, Handle hndl, const char[]
g_bStageSRVRecord[data][stage] = false;
if (style == 0)
{
CPrintToChat(data, "%t", "SQL11", g_szChatPrefix, stage, g_szFinalWrcpTime[data], szDiff, sz_srDiff);
if (g_iWrcpMessages[data])
CPrintToChat(data, "%t", "SQL11", g_szChatPrefix, stage, g_szFinalWrcpTime[data], szDiff, sz_srDiff);

Format(szSpecMessage, sizeof(szSpecMessage), "%t", "SQL12", g_szChatPrefix, szName, stage, g_szFinalWrcpTime[data], szDiff, sz_srDiff);
}
else if (style != 0) // styles
{
CPrintToChat(data, "%t", "SQL13", g_szChatPrefix, stage, g_szStyleRecordPrint[style], g_szFinalWrcpTime[data], sz_srDiff, g_StyleStageRank[style][data][stage], g_TotalStageStyleRecords[style][stage]);
if (g_iWrcpMessages[data])
CPrintToChat(data, "%t", "SQL13", g_szChatPrefix, stage, g_szStyleRecordPrint[style], g_szFinalWrcpTime[data], sz_srDiff, g_StyleStageRank[style][data][stage], g_TotalStageStyleRecords[style][stage]);

Format(szSpecMessage, sizeof(szSpecMessage), "%t", "SQL14", g_szChatPrefix, stage, g_szStyleRecordPrint[style], g_szFinalWrcpTime[data], sz_srDiff, g_StyleStageRank[style][data][stage], g_TotalStageStyleRecords[style][stage]);
}
CheckpointToSpec(data, szSpecMessage);
Expand Down
20 changes: 20 additions & 0 deletions addons/sourcemod/translations/surftimer.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1518,4 +1518,24 @@
"#format" "{1:s}"
"en" "{1} Silent spectate is now {red}disabled"
}
"ToggleWrcpsMessageToggleOn"
{
"#format" "{1:s}"
"en" "{1} SRCP messages are now {green}enabled"
}
"ToggleWrcpsMessageToggleOff"
{
"#format" "{1:s}"
"en" "{1} SRCP messages are now {red}disabled"
}
"ToggleCpsMessageToggleOn"
{
"#format" "{1:s}"
"en" "{1} CP messages are now {green}enabled"
}
"ToggleCpsMessageToggleOff"
{
"#format" "{1:s}"
"en" "{1} CP messages are now {red}disabled"
}
}
6 changes: 5 additions & 1 deletion mysql-files/upgrading/upgrade-fluffy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
/* Prestrafe Message */

ALTER TABLE `ck_playeroptions2`
ADD COLUMN `prestrafe` INT(11) NOT NULL DEFAULT '0' AFTER `module5s`;
ADD COLUMN `prestrafe` INT(11) NOT NULL DEFAULT '0' AFTER `module5s`;
ALTER TABLE `ck_playeroptions2`
ADD COLUMN `cpmessages` INT(11) NOT NULL DEFAULT '1' AFTER `prestrafe`;
ALTER TABLE `ck_playeroptions2`
ADD COLUMN `wrcpmessages` INT(11) NOT NULL DEFAULT '1' AFTER `cpmessages`;

0 comments on commit 808871c

Please sign in to comment.