From 6df8c971e884b4b8f68ea4c3b24e5cbc970f555a Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Tue, 28 Mar 2023 22:24:56 -0400 Subject: [PATCH] SERVER: Add trigger_stuffcmd --- source/server/entities/triggers.qc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/server/entities/triggers.qc b/source/server/entities/triggers.qc index 0e86db0..607e2fe 100644 --- a/source/server/entities/triggers.qc +++ b/source/server/entities/triggers.qc @@ -240,6 +240,32 @@ void() trigger_activator = self.touch = trigger_activator_touch; } +#define SPAWNFLAG_TRIGGERCMD_NOPLAYER 1 +#define SPAWNFLAG_TRIGGERCMD_NOSPEC 2 +void() trigger_stuffcmd_touch = +{ + // First, lets make sure this is a client + if (other.classname != "player" && other.classname != "spectator") + return; + + // Don't interact with players + if ((self.spawnflags & SPAWNFLAG_TRIGGERCMD_NOPLAYER) && other.classname == "player") + return; + + // Don't interact with spectators + if ((self.spawnflags & SPAWNFLAG_TRIGGERCMD_NOSPEC) && other.classname == "spectator") + return; + + // Run the command. + stuffcmd(other, strcat(self.message, "\n")); +} + +void() trigger_stuffcmd = +{ + InitTrigger(); + self.touch = trigger_stuffcmd_touch; +} + /* =================== Custom Teddy Triggers ===================*/