Rename Unnamed Soldier's Automatically



> >

Created 6 years ago

Rename Unnamed Soldier's Automatically

How to auto rename players who use blacklisted names
In order to rename Unnamed Soldiers, you will need to have CoDaM with HamGoodies installed on your server.
It has a function built in which is renaming "Unknown Soldiers" to a specified prefix.

You can define a name prefix in your CoDaM_HamGoodies.cfg file. Open it with any text editor and scroll to somewhere around line 40, you should see the following cvar:

set ham_name_prefix "myprefix"

Example: If your name prefix is: www.myclan.com, the player will be renamed to "www.myclan.com_5_41". The "_5_41" is a random generated integer.


How do i do modifications?


You can edit the source code in CoDaM_HamGoodies_CoD1.1_.pk3 under HamGoodies.gsc on line 360. You can also add custom names to rename.
Here's a simple example:
player = players[i];
if ( isdefined( player ) &&
 ( 
  	player.name == "hitler" ||
  	player.name == "adolf hitler" ||
  	player.name == "fuck you" ||
  	player.name == "console" ||
  	player.name == "wehrmacht" ||
  	player setClientCvar( "name", _prefix + "_" +
  	( player getEntityNumber() ) +
  	"_" + randomInt( 999 ) + "^7" );

This is the easiest way to do it if you're not very experienced with programming, of course there are more ways to do it, for example with an external php script. But this requires a bit more experience.



PHP-Example for Advanced Programmers:


This is a very simple php script which uses regular expressions to match unnamed/unknown soldiers
and any other specified names. Cato made the regexes for it. Note: This is a small excerpt from my original code and it hasn't been tested. You will need your own php backend which is fetching the player data (getstatus) and loop the players for it to work.

It checks if a player has a bad name, and then renames him into the specified prefix (Example: think-clan.com_22_587).
$prefix= '^2think-clan.com';

$badwords = array(
        'console',
        'fuck you',
	'123456',
        '(?:heil ?)?hitler',
        '(?:un)?(?:known|named)(.*?)(player|soldier)',
        '(?:search|suche) clan');


	$implode = implode('|', $badwords);
	$randomize= $prefix.''.rand(0,100).'_'.rand(0,1000);

	if(preg_match('¤(' . $implode . ')¤i', $playername, $m))
		{
		$fp2 = fsockopen("udp://".$server_ip, $server_port, $errno, $errstr);
			fwrite($fp2,"\xFF\xFF\xFF\xFF\x02rcon ".$server_rcon." set command rename ".$num." \"\q".$prefix."");
			fclose($fp2);
		}

(The "set command rename <id> <name>" command is part of codam or powerserver and those frameworks are required in order to rename a player via an external script)

Tutorial Details

Created: 6 years ago by ^THiNK#ALIEN

Views: 2104 Views

Keywords: Renaming, rename player, rename, automatic rename,

Share this Knowledge with your friends!

Direct Link:

4 Comments

Thx
Commented by THINK#CraZy  (Feb 06th, 2013 08:05 PM)

hey, what it does. what that code will do m not understanding becoz i tried it but not changed anything
Commented by ^ThM|L[O]ckY.  (Nov 20th, 2013 07:42 AM)

It will rename players who have the name "Un named soldier" etc. to something like yoursite.com_5_17
Commented by ~stb*MEGAbyte_  (Nov 21st, 2013 05:38 AM)

Thanks
Commented by ^ThM|L[O]ckY.  (Nov 21st, 2013 12:27 PM)

Please sign in or create an account to post a comment.