Plugins: Fixed InitEnts not being called, added another example plugin (Server Banner)
This commit is contained in:
parent
bb0c78cb0a
commit
baaa68069d
5 changed files with 106 additions and 6 deletions
|
@ -5,3 +5,5 @@ all:
|
|||
$(CC) chatfilter.src
|
||||
$(CC) connectsounds.src
|
||||
$(CC) voxannouncer.src
|
||||
$(CC) banner.src
|
||||
$(CC) ircbridge.src
|
||||
|
|
84
src/plugins/banner.c
Executable file
84
src/plugins/banner.c
Executable file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* 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;
|
||||
}
|
8
src/plugins/banner.src
Executable file
8
src/plugins/banner.src
Executable file
|
@ -0,0 +1,8 @@
|
|||
#pragma target fte
|
||||
#pragma PROGS_DAT "../../platform/p_banner.dat"
|
||||
#define QWSSQC
|
||||
|
||||
#includelist
|
||||
../shared/fteextensions.qc
|
||||
banner.c
|
||||
#endlist
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue