-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a632c65
Showing
7 changed files
with
1,629 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
/addons/sourcemod/plugins/* | ||
!addons/sourcemod/plugins/.gitkeep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
sudo: false | ||
language: c | ||
|
||
addons: | ||
apt_packages: | ||
- lib32stdc++6 | ||
|
||
env: | ||
- SOURCEMOD=1.7 | ||
- SOURCEMOD=1.8 | ||
|
||
before_script: | ||
- mkdir build && cd build | ||
- wget "http://www.sourcemod.net/latest.php?version=$SOURCEMOD&os=linux" -O sourcemod-$SOURCEMOD-linux.tar.gz | ||
- tar -xzf sourcemod-$SOURCEMOD-linux.tar.gz | ||
- cd addons/sourcemod/scripting | ||
- chmod +x spcomp | ||
- cp -R $TRAVIS_BUILD_DIR/addons/sourcemod/scripting/* . | ||
|
||
script: ./compile.sh advertisements.sp | ||
|
||
before_deploy: | ||
- cp -R compiled/* $TRAVIS_BUILD_DIR/addons/sourcemod/plugins/ | ||
- cd $TRAVIS_BUILD_DIR | ||
- tar -czf release.tar.gz addons/ | ||
|
||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: o0ZnxHb4OjAz7GwQgYfcl+YopRo/a7fWy8/+Vt4V05bWiuoqG1Roc6dAMVzkNBRz4iCihjkQmwq5AVSxOrdqFa9xQAAFfydYAO2nreaD2k+Djj5W0JTzy/tO8ZFh1MSlJke6qerYJ2MoO7dlvSAWvEq1RhRiHQ2f8Gh+YTZNrnqNz9hV4jGywulYCTiqZRVx3NFnQLM65r7dZtyoQ9rE0qfy2c/vUDhuL4VxsOM14DmFxnfk7ekfqOI/J8dxWtLU9MlaBW0JiW6SVMUIDplQR0RHlQkrnml5XwQwHkW2eipOQwxOpP2NZUYkj4hfkmETs4W9O13igwbJM4CjlfWUaaRCeI9Ka6iiO6L9KGqzp+MVxCKajjNF1Krb/JklBoCHNbYBdZsVP97YeFjB+tT9duwN+CVamtGjCSspGxQMClranRCpphWbszzsvzdJcCEPowI/M16w+E7ejOO0KbaajEzmkpA8tjdj4NfoLrve5VtJtR9Nto9UBWFz7nrjx8/UXUR2gBkhwzxF6MBvpxC8nCGMzJHxLqUu3UP5SdpqhlR5e8SQkI7bDaZP7bY1LzLIGlSa8spwP+UuCqsHT5t1jfyXQIrT1ZuiH+3n7DWutUDu5nkAIKnk9COT2ao3aBYh9uMSD4Qr6lxO8TXfLuc8TytQdIzl+b3BDYb/B+4pqN0= | ||
file: release.tar.gz | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
condition: $SOURCEMOD = 1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Advertisements 2.0 | ||
// by Tsunami | ||
// | ||
// Types | ||
// ----- | ||
// center: Center message | ||
// chat: Chat message | ||
// hint: Hint message | ||
// menu: Menu message | ||
// top: Top message | ||
// | ||
// Flags (optional) | ||
// ----- | ||
// Accepts flags of admins that will not see the advertisement. | ||
// When omitted everyone will see the advertisement. | ||
// When left empty only admins will see the advertisement. | ||
|
||
"Advertisements" | ||
{ | ||
"1" | ||
{ | ||
"center" "www.domain.com" | ||
} | ||
"2" | ||
{ | ||
"center" "[email protected]" | ||
"hint" "[email protected]" | ||
} | ||
"3" | ||
{ | ||
"menu" "Next map is {sm_nextmap} in {timeleft} minutes." | ||
"flags" "cft" | ||
} | ||
"4" | ||
{ | ||
"chat" "{green}Current {lightgreen}Map: {default}{currentmap}" | ||
"flags" "z" | ||
} | ||
"5" | ||
{ | ||
"top" "{orange}Admins: friendly fire is {mp_friendlyfire}." | ||
"flags" "" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,297 @@ | ||
#include <sourcemod> | ||
#include <colorvariables> | ||
#include "advertisements/topcolors.sp" | ||
|
||
#pragma newdecls required | ||
#pragma semicolon 1 | ||
|
||
#define PL_VERSION "2.0.0" | ||
|
||
public Plugin myinfo = | ||
{ | ||
name = "Advertisements", | ||
author = "Tsunami", | ||
description = "Display advertisements", | ||
version = PL_VERSION, | ||
url = "http://www.tsunami-productions.nl" | ||
}; | ||
|
||
|
||
/** | ||
* Globals | ||
*/ | ||
bool g_bSayText2; | ||
KeyValues g_hAdvertisements; | ||
ConVar g_hEnabled; | ||
ConVar g_hFile; | ||
ConVar g_hInterval; | ||
Handle g_hTimer; | ||
|
||
|
||
/** | ||
* Plugin Forwards | ||
*/ | ||
public void OnPluginStart() | ||
{ | ||
CreateConVar("sm_advertisements_version", PL_VERSION, "Display advertisements", FCVAR_NOTIFY); | ||
g_hEnabled = CreateConVar("sm_advertisements_enabled", "1", "Enable/disable displaying advertisements."); | ||
g_hFile = CreateConVar("sm_advertisements_file", "advertisements.txt", "File to read the advertisements from."); | ||
g_hInterval = CreateConVar("sm_advertisements_interval", "30", "Amount of seconds between advertisements."); | ||
|
||
g_hInterval.AddChangeHook(ConVarChange_Interval); | ||
|
||
RegServerCmd("sm_advertisements_reload", Command_ReloadAds, "Reload the advertisements"); | ||
|
||
AddTopColors(); | ||
|
||
g_bSayText2 = (GetUserMessageId("SayText2") != INVALID_MESSAGE_ID); | ||
} | ||
|
||
public void OnMapStart() | ||
{ | ||
ParseAds(); | ||
|
||
g_hTimer = CreateTimer(g_hInterval.IntValue * 1.0, Timer_DisplayAd, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); | ||
} | ||
|
||
public void ConVarChange_Interval(ConVar convar, const char[] oldValue, const char[] newValue) | ||
{ | ||
if (g_hTimer) { | ||
KillTimer(g_hTimer); | ||
} | ||
|
||
g_hTimer = CreateTimer(g_hInterval.IntValue * 1.0, Timer_DisplayAd, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); | ||
} | ||
|
||
|
||
/** | ||
* Commands | ||
*/ | ||
public Action Command_ReloadAds(int args) | ||
{ | ||
ParseAds(); | ||
return Plugin_Handled; | ||
} | ||
|
||
|
||
/** | ||
* Menu Handlers | ||
*/ | ||
public int Handler_DoNothing(Menu menu, MenuAction action, int param1, int param2) {} | ||
|
||
|
||
/** | ||
* Timers | ||
*/ | ||
public Action Timer_DisplayAd(Handle timer) | ||
{ | ||
if (!g_hEnabled.BoolValue) { | ||
return; | ||
} | ||
|
||
char sCenter[1024], sChat[1024], sHint[1024], sMenu[1024], sTop[1024], sFlags[16]; | ||
g_hAdvertisements.GetString("center", sCenter, sizeof(sCenter)); | ||
g_hAdvertisements.GetString("chat", sChat, sizeof(sChat)); | ||
g_hAdvertisements.GetString("hint", sHint, sizeof(sHint)); | ||
g_hAdvertisements.GetString("menu", sMenu, sizeof(sMenu)); | ||
g_hAdvertisements.GetString("top", sTop, sizeof(sTop)); | ||
g_hAdvertisements.GetString("flags", sFlags, sizeof(sFlags), "none"); | ||
int iFlags = ReadFlagString(sFlags); | ||
bool bAdmins = StrEqual(sFlags, ""), | ||
bFlags = !StrEqual(sFlags, "none"); | ||
|
||
if (sCenter[0]) { | ||
ProcessVariables(sCenter); | ||
CRemoveColors(sCenter, sizeof(sCenter)); | ||
|
||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsClientInGame(i) && !IsFakeClient(i) && | ||
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) || | ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) { | ||
PrintCenterText(i, sCenter); | ||
|
||
DataPack hCenterAd; | ||
CreateDataTimer(1.0, Timer_CenterAd, hCenterAd, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); | ||
hCenterAd.WriteCell(i); | ||
hCenterAd.WriteString(sCenter); | ||
} | ||
} | ||
} | ||
if (sHint[0]) { | ||
ProcessVariables(sHint); | ||
CRemoveColors(sHint, sizeof(sHint)); | ||
|
||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsClientInGame(i) && !IsFakeClient(i) && | ||
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) || | ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) { | ||
PrintHintText(i, sHint); | ||
} | ||
} | ||
} | ||
if (sMenu[0]) { | ||
ProcessVariables(sMenu); | ||
CRemoveColors(sMenu, sizeof(sMenu)); | ||
|
||
Panel hPl = new Panel(); | ||
hPl.DrawText(sMenu); | ||
hPl.CurrentKey = 10; | ||
|
||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsClientInGame(i) && !IsFakeClient(i) && | ||
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) || | ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) { | ||
hPl.Send(i, Handler_DoNothing, 10); | ||
} | ||
} | ||
|
||
delete hPl; | ||
} | ||
if (sChat[0]) { | ||
ProcessVariables(sChat); | ||
CProcessVariables(sChat, sizeof(sChat)); | ||
|
||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsClientInGame(i) && !IsFakeClient(i) && | ||
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) || | ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) { | ||
if (g_bSayText2) { | ||
CSayText2(i, sChat, i); | ||
} else { | ||
PrintToChat(i, sChat); | ||
} | ||
} | ||
} | ||
} | ||
if (sTop[0]) { | ||
int iStart = 0, | ||
aColor[4] = {255, 255, 255, 255}; | ||
|
||
ParseTopColor(sTop, iStart, aColor); | ||
ProcessVariables(sTop[iStart]); | ||
|
||
KeyValues hKv = new KeyValues("Stuff", "title", sTop[iStart]); | ||
hKv.SetColor4("color", aColor); | ||
hKv.SetNum("level", 1); | ||
hKv.SetNum("time", 10); | ||
|
||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsClientInGame(i) && !IsFakeClient(i) && | ||
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) || | ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) { | ||
CreateDialog(i, hKv, DialogType_Msg); | ||
} | ||
} | ||
|
||
delete hKv; | ||
} | ||
|
||
if (!g_hAdvertisements.GotoNextKey()) { | ||
g_hAdvertisements.Rewind(); | ||
g_hAdvertisements.GotoFirstSubKey(); | ||
} | ||
} | ||
|
||
public Action Timer_CenterAd(Handle timer, DataPack pack) | ||
{ | ||
char sCenter[1024]; | ||
static int iCount = 0; | ||
|
||
pack.Reset(); | ||
int iClient = pack.ReadCell(); | ||
pack.ReadString(sCenter, sizeof(sCenter)); | ||
|
||
if (!IsClientInGame(iClient) || ++iCount >= 5) { | ||
iCount = 0; | ||
return Plugin_Stop; | ||
} | ||
|
||
PrintCenterText(iClient, sCenter); | ||
return Plugin_Continue; | ||
} | ||
|
||
|
||
/** | ||
* Stocks | ||
*/ | ||
void ParseAds() | ||
{ | ||
delete g_hAdvertisements; | ||
g_hAdvertisements = CreateKeyValues("Advertisements"); | ||
|
||
char sFile[64], sPath[PLATFORM_MAX_PATH]; | ||
g_hFile.GetString(sFile, sizeof(sFile)); | ||
BuildPath(Path_SM, sPath, sizeof(sPath), "configs/%s", sFile); | ||
|
||
if (!FileExists(sPath)) { | ||
SetFailState("File Not Found: %s", sPath); | ||
} | ||
|
||
g_hAdvertisements.ImportFromFile(sPath); | ||
g_hAdvertisements.GotoFirstSubKey(); | ||
} | ||
|
||
void ProcessVariables(char sText[1024]) | ||
{ | ||
char sBuffer[64]; | ||
if (StrContains(sText, "\\n") != -1) { | ||
Format(sBuffer, sizeof(sBuffer), "%c", 13); | ||
ReplaceString(sText, sizeof(sText), "\\n", sBuffer); | ||
} | ||
|
||
if (StrContains(sText, "{currentmap}", false) != -1) { | ||
GetCurrentMap(sBuffer, sizeof(sBuffer)); | ||
ReplaceString(sText, sizeof(sText), "{currentmap}", sBuffer, false); | ||
} | ||
|
||
if (StrContains(sText, "{date}", false) != -1) { | ||
FormatTime(sBuffer, sizeof(sBuffer), "%m/%d/%Y"); | ||
ReplaceString(sText, sizeof(sText), "{date}", sBuffer, false); | ||
} | ||
|
||
if (StrContains(sText, "{time}", false) != -1) { | ||
FormatTime(sBuffer, sizeof(sBuffer), "%I:%M:%S%p"); | ||
ReplaceString(sText, sizeof(sText), "{time}", sBuffer, false); | ||
} | ||
|
||
if (StrContains(sText, "{time24}", false) != -1) { | ||
FormatTime(sBuffer, sizeof(sBuffer), "%H:%M:%S"); | ||
ReplaceString(sText, sizeof(sText), "{time24}", sBuffer, false); | ||
} | ||
|
||
if (StrContains(sText, "{timeleft}", false) != -1) { | ||
int iMins, iSecs, iTimeLeft; | ||
if (GetMapTimeLeft(iTimeLeft) && iTimeLeft > 0) { | ||
iMins = iTimeLeft / 60; | ||
iSecs = iTimeLeft % 60; | ||
} | ||
|
||
Format(sBuffer, sizeof(sBuffer), "%d:%02d", iMins, iSecs); | ||
ReplaceString(sText, sizeof(sText), "{timeleft}", sBuffer, false); | ||
} | ||
|
||
ConVar hConVar; | ||
char sConVar[64], sSearch[64], sReplace[64]; | ||
int iEnd = -1, iStart = StrContains(sText, "{"), iStart2; | ||
while (iStart != -1) { | ||
iEnd = StrContains(sText[iStart + 1], "}"); | ||
if (iEnd == -1) { | ||
break; | ||
} | ||
|
||
strcopy(sConVar, iEnd + 1, sText[iStart + 1]); | ||
Format(sSearch, sizeof(sSearch), "{%s}", sConVar); | ||
|
||
if ((hConVar = FindConVar(sConVar))) { | ||
hConVar.GetString(sReplace, sizeof(sReplace)); | ||
ReplaceString(sText, sizeof(sText), sSearch, sReplace, false); | ||
} | ||
|
||
iStart2 = StrContains(sText[iStart + 1], "{"); | ||
if (iStart2 == -1) { | ||
break; | ||
} | ||
|
||
iStart += iStart2 + 1; | ||
} | ||
} |
Oops, something went wrong.