[CF-Devel] banish command

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Fri Jul 25 00:01:50 CDT 2003


OK, so I wrote a command so that DM's can banish players which is
basically kicking them off the server and putting their IP into the
ban_file.

It's all good and works except for the fact that when you kick a player
it goes into the play_again function so they aren't really disconnected
- this means they bypass the ban_file as long as they don't disconnect
their client.  I think that command_kick should disconect the player
that is kicked myself, but am not sure how to best change that (or if I
should). I would rather change kick than write an new player ending
routine since I am guessing that program exit points like this should be
few and well maintained...
So I'm putting this up for criticism since it is a bit more complex than
the no_shout thing and involves writing to a file and other stuff which
is pretty new to me in CF.  If it's ok, I'll put it up.

Here is the command:


int command_banish (object *op, char *params)
  {
	  player *pl;
	  FILE *bannedfile;
	  char  buf[MAX_BUF];
	  
	if (!params) {
         new_draw_info(NDI_UNIQUE, 0,op,"Usage: ban <player>.");
         return 1;
    }
	
	pl = get_other_player_from_name(op, params);
	if (!pl) return 1;
	
	sprintf (buf, "%s/%s", settings.confdir, BANFILE);
	
    if ((bannedfile = fopen(buf, "a")) == NULL) {
    	LOG (llevDebug, "Could not find file Banned file.\n");
		new_draw_info(NDI_UNIQUE,0,op,"Could not find file Banned file.");
    	return(0);
  		}
		
  	fprintf(bannedfile,"*@%s\n",pl->socket.host);
	LOG (llevDebug, "! %s banned %s from IP: %s.\n", op->name,
pl->ob->name, pl->socket.host);
  	new_draw_info_format(NDI_UNIQUE | NDI_RED, 0,op,"You banish %s",
pl->ob->name);
	new_draw_info_format(NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op,
			     "%s banishes %s from the land!", op->name, pl->ob->name);
	command_kick(op, pl->ob->name);
    fclose(bannedfile);
	return 1;
  }


_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list