Quake DeveLS - Clan Banning

Author: Unkown
Difficulty:
Easy

This is a tutorial for the Ban Clan function. it is quite easily done. we just need to add a little check routine to ClientConnect in p_client.c. First off we need to add a couple of variables, the file descriptor, and a string to read out of the file

 
               qboolean ClientConnect (edict_t *ent, char *userinfo)
               {
                               char    *value;
                               // Clan Banning
               +             FILE    *banlist;
                               // Variable to handle the file.
               +             char    *line;
                               // To read the file line byline.

Pretty striaght forward. now the actual nitty gritty of it all. still in ClientConnect() in p_client.c

 
               if (ent->inuse == false) {
                               // clear the respawning variables
                               InitClientResp (ent->client);
                               if (!game.autosaved || !ent->client->pers.weapon)
                                              InitClientPersistant (ent->client);
               }
 
               ClientUserInfoChanged (ent, userinfo);
+             // Clan Banning
+             if ( banlist = fopen("banlist.txt", "r") )
               // Open theFile
+             {
+                             while ( fgets(line, 80, banlist) ) // We can still read...
+                {
+                        line[strlen(line)-1] = '\0';    // chop off the trailing \n
+                        if ( strstr(ent->client->pers.netname, line )  // if we found the current word in the nick...
+                        {
+                                return false;           // Refuse this client Entrance.
+                        }
+                }
+                fclose(banlist);                        // Give the file back to everyone.
+        }
+        else                                            // Can't openthe file.
+        {
+                gi.dprintf("Can't Open BANLIST.TXT\n");
+        }
               if (game.maxclients > 1)  

... there we go. that is it. not exactly a trying peice of code. now to addpeopl or whatever to the banlist you need to edit BANLIST.TXT in your root quake2 directory (e.g c:\quake2) it will look something like this.

 
[xxx]
lamer
goaway

now anyone with any of those things in their name will be denied access.

(SumFuka - don't hold me responsible for anyone using this tutorial in bad spirit ! I didn't write it, so sue me.)

Tutorial by Anon!

 
 
 

This site, and all content and graphics displayed on it,
are ©opyrighted to the Quake DeveLS team. All rights received.
Got a suggestion? Comment? Question? Hate mail? Send it to us!
Oh yeah, this site is best viewed in 16 Bit or higher, with the resolution on 800*600.
Thanks to Planet Quake for there great help and support with hosting.
Best viewed with Netscape 4 or IE 3