ANTI MESSAGE FLOODING ADD-ON

 

 

philip
profile | email

posted 09-03-98 8:49 PM CT (US)
Title: ANTI MESSAGE FLOODING ADD-ON
Difficulty: Easy
By: Philip (aka Maj.Bitch)
Email: peblair@gv.net // please report any bugs(??)
Date: 9-2-98
Note: Please give credit where credit is due.

=============================================================

This is a modification to the Message Flooding Tutorial originally
posted on QDevels by: 'Cryect'. Many thanks to him/her for their
originally and inspiration upon which this tutorial is based.

ABOUT:

One of the problems which I had with the original tutorial was that
you got banned immediately upon your first post. In other words,
you were only allowed 1 message to be posted "said" every 10 seconds.

What this modification does is to allow for 'some' rapid posting but
to dynamically enable the anti-message posting if the player attempts
to post more than 3 messages in 1 unit of Quake2 time (in other words,
they are leaning on the repeat key and attempting to flood the board!).
If they are caught flooding then they are banned from posting messages
to the game for 30 seconds (which is a fairly long amount of time).

So, players can post repeat messages rapidly (if they mispelled something
for instance) but if they lean on the keyboard, they get banned. If
they seem to like flooding that much then they should really enjoy this!!

Check it out for yourself!

=============================================================
================ Q_SHARED.H MODIFICATIONS ==================
=============================================================

Add the following defines to q_shared.h, or make the global
substitution (in reverse) if you don't like defines that much.

#define PRESENT_TIME level.time

=============================================================
================ MODIFICATIONS TO G_CLIENT STRUCT ===========
=============================================================

Add the following variables to the bottom of g_client struct.

//Flood prevention variables
float flood_timer;
int flood_num_msgs;
float flood_post_time;


=============================================================
============== P_CLIENT.C MODIFICATIONS =====================
=============================================================

Add the following lines to the bottom of InitClientPersistant().

// Init Flood Protection Variables
client->flood_num_msgs = 0;
client->flood_post_time = 0;
client->flood_timer = 0;


=============================================================
================ G_CMDS.C MODIFICATIONS =====================
=============================================================

Add the following variable to the top of cmd_say_f() right after
the other variable declarations.

int time_left=0;

===============

Add the following flood protection code at the top but right
after this line:
if (gi.argc() < 2 && !arg0)
return;

// Begin - Message Flooding Protection Code.

// if not already in a timer situation then..
if (!(ent->client->flood_timer > PRESENT_TIME))
// if attempt to post more than 3 msgs in 1 unit of time.
if ((ent->client->flood_num_msgs >= 3)
&& (ent->client->flood_post_time+1 > PRESENT_TIME)) {
ent->client->flood_timer = PRESENT_TIME + 30; // Start 30 sec Timer.
ent->client->flood_post_time=PRESENT_TIME; // Reset First Post Time.
ent->client->flood_num_msgs=0;} // Reset Num Messages posted

// Timer is running so NO POSTS ALLOWED. Just printf and exit..
if (ent->client->flood_timer > PRESENT_TIME){
time_left=(int)(ent->client->flood_timer-PRESENT_TIME);
gi.cprintf(ent, PRINT_HIGH, "Anti-Message Flooding In Effect!!\n");
gi.cprintf(ent, PRINT_HIGH, "No Posts Allowed for %i more seconds..\n",time_left);
return;}

// End - Message Flood Protection

==============

Now, at the very bottom of cmd_say_f() add these lines of code:

// Increment Flood Msg Count
ent->client->flood_num_msgs += 1;

// Capture first post time
if (ent->client->flood_post_time+1 < PRESENT_TIME)
ent->client->flood_post_time=PRESENT_TIME;

=============================================================

That should do it! Note: You can change the num messages limit
and the timer number to whatever you think is appropriate for
your mod.

regards,
Philip
aka Maj.Bitch