diff --git a/src/plugins/Makefile b/src/plugins/Makefile index 31758d34..0e8bbc50 100644 --- a/src/plugins/Makefile +++ b/src/plugins/Makefile @@ -5,3 +5,5 @@ all: $(CC) chatfilter.src $(CC) connectsounds.src $(CC) voxannouncer.src + $(CC) banner.src + $(CC) ircbridge.src diff --git a/src/plugins/banner.c b/src/plugins/banner.c new file mode 100755 index 00000000..83a60858 --- /dev/null +++ b/src/plugins/banner.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "../shared/events.h" + +void BannerPlugin_MapInfo(void); +void BannerPlugin_Hostname(void); + +void +BannerPlug_Broadcast(string bmsg) +{ + + WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); + WriteByte(MSG_MULTICAST, EV_TEXT); + WriteByte(MSG_MULTICAST, 1); + WriteString(MSG_MULTICAST, bmsg); + WriteFloat(MSG_MULTICAST, -1); + WriteFloat(MSG_MULTICAST, 0.6); + WriteByte(MSG_MULTICAST, 2); + WriteByte(MSG_MULTICAST, 255); + WriteByte(MSG_MULTICAST, 255); + WriteByte(MSG_MULTICAST, 255); + WriteByte(MSG_MULTICAST, 0); + WriteByte(MSG_MULTICAST, 255); + WriteByte(MSG_MULTICAST, 0); + WriteFloat(MSG_MULTICAST, 0.01f); + WriteFloat(MSG_MULTICAST, 0.5f); + WriteFloat(MSG_MULTICAST, 4.0f); + WriteFloat(MSG_MULTICAST, 0.25f); + msg_entity = world; + multicast([0,0,0], MULTICAST_ALL); +} + +void +BannerPlugin_MapInfo(void) +{ + string bmsg; + string mname; + + mname = serverkey("mapname"); + bmsg = sprintf("Hope you enjoy your time on ^2%s^7!", mname); + BannerPlug_Broadcast(bmsg); + + /* loop back to the hostname info in 4 minutes */ + self.think = BannerPlugin_Hostname; + self.nextthink = time + 240.0f; +} + +void +BannerPlugin_Hostname(void) +{ + string bmsg; + string hname; + + hname = cvar_string("hostname"); + bmsg = sprintf("You're playing on ^1%s^7.", hname); + BannerPlug_Broadcast(bmsg); + + /* play the map info in 5 seconds */ + self.think = BannerPlugin_MapInfo; + self.nextthink = time + 5.0f; +} + +void +FMX_InitEnts(void) +{ + entity banner; + banner = spawn(); + banner.think = BannerPlugin_Hostname; + banner.nextthink = time + 30.0f; +} diff --git a/src/plugins/banner.src b/src/plugins/banner.src new file mode 100755 index 00000000..360d8db1 --- /dev/null +++ b/src/plugins/banner.src @@ -0,0 +1,8 @@ +#pragma target fte +#pragma PROGS_DAT "../../platform/p_banner.dat" +#define QWSSQC + +#includelist +../shared/fteextensions.qc +banner.c +#endlist diff --git a/src/plugins/ircbridge.c b/src/plugins/ircbridge.c index 4210a17f..fdce33c7 100644 --- a/src/plugins/ircbridge.c +++ b/src/plugins/ircbridge.c @@ -122,12 +122,6 @@ FMX_PlayerObituary(entity attk, entity targ, int weapon, int body, int dmg) string FMX_ParseClientCommand(string cmd) { - if (!g_ircbridge) { - g_ircbridge = spawn(); - g_ircbridge.think = IRCBridge_ServerConnect; - g_ircbridge.nextthink = time; - } - tokenize(cmd); switch (argv(0)) { case "say": @@ -136,3 +130,13 @@ FMX_ParseClientCommand(string cmd) } return cmd; } + + + +void +FMX_InitEnts(void) +{ + g_ircbridge = spawn(); + g_ircbridge.think = IRCBridge_ServerConnect; + g_ircbridge.nextthink = time + 1.0f; +} diff --git a/src/server/entry.c b/src/server/entry.c index 19c30c84..3cf36738 100644 --- a/src/server/entry.c +++ b/src/server/entry.c @@ -420,6 +420,8 @@ void initents(void) /* the maxclients serverinfo key? yeah, that one lies to the client. so * let's add our own that we can actually trust. */ forceinfokey(world, "sv_playerslots", cvar_string("sv_playerslots")); + + Plugin_InitEnts(); } /*