]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a hook to handle the message before anything has been replaced
authorMario <mario@smbclan.net>
Tue, 29 Nov 2016 04:32:13 +0000 (14:32 +1000)
committerMario <mario@smbclan.net>
Tue, 29 Nov 2016 04:33:01 +0000 (14:33 +1000)
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/events.qh

index e90dbeb9669a81e00cc94cb6651094e015081c4d..7f4899f127faed3c1d53e77e9ad15a4d236f197b 100644 (file)
@@ -238,6 +238,9 @@ string formatmessage(entity this, string msg)
        cursor = trace_endpos;
        cursor_ent = trace_ent;
 
+       MUTATOR_CALLHOOK(PreFormatMessage, this, msg);
+       msg = M_ARGV(1, string);
+
        while (1) {
                if (n < 1)
                        break; // too many replacements
index 21c8ef9a5c114e92b0650f4ca5b6ec251a14d3a5..b6e8c7f4b7b233f38edc3bf18e5c45417db27285 100644 (file)
@@ -134,6 +134,14 @@ MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
     /**/
 MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage);
 
+/** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */
+#define EV_PreFormatMessage(i, o) \
+    /** player        */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** message       */ i(string, MUTATOR_ARGV_1_string) \
+    /**/                 o(string, MUTATOR_ARGV_1_string) \
+    /**/
+MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage);
+
 /** returns true if throwing the current weapon shall not be allowed */
 #define EV_ForbidThrowCurrentWeapon(i, o) \
     /** player        */ i(entity, MUTATOR_ARGV_0_entity) \