Raised This Month: $51 Target: $400
 12% 

Automatic Bot Names


Post New Thread Reply   
 
Thread Tools Display Modes
XHeadHunterX
Member
Join Date: Aug 2013
Old 10-16-2013 , 15:10   Re: Automatic Bot Names
Reply With Quote #81

Any way to make this work on cs:go?
XHeadHunterX is offline
NicoandLuis
Member
Join Date: Jun 2013
Old 12-16-2013 , 09:42   Re: Automatic Bot Names
Reply With Quote #82

Can you do, so it gives certain names only to certain classes?
NicoandLuis is offline
NicoandLuis
Member
Join Date: Jun 2013
Old 12-28-2013 , 14:28   Re: Automatic Bot Names
Reply With Quote #83

*bump*
NicoandLuis is offline
agrif
Junior Member
Join Date: Jan 2010
Old 01-24-2014 , 11:14   Re: Automatic Bot Names
Reply With Quote #84

Hey everybody. Sorry I haven't been keeping up with this plugin, but I haven't run a TF2 server in a long while, so my motivation evaporated.

Still, I've merged in the changes from FirEXE, luki1412, and another patch I got via email, and I've made a 1.3.0 release from these, which I've attached. I'll also update the main post.

I probably won't be doing any development at all on this, but if you shoot me an email I'd be glad to merge in changes. Better yet, submit a pull request:

https://github.com/agrif/botnames/pulls
Attached Files
File Type: sp Get Plugin or Get Source (botnames.sp - 1760 views - 18.3 KB)
agrif is offline
Vastrix
Senior Member
Join Date: Aug 2012
Location: Zion
Old 07-19-2014 , 09:39   Re: Automatic Bot Names
Reply With Quote #85

Hey o/

We found an Issue:
When the server just started and people are joining, some of those people tend to be renamed
to one of the botnames.. :/
Any chance you can fix this? It's really annoying :s

Thanks
Vastrix is offline
depthbomb
Junior Member
Join Date: Jul 2014
Old 07-19-2014 , 16:24   Re: Automatic Bot Names
Reply With Quote #86

Quote:
Originally Posted by Vastrix View Post
Hey o/

We found an Issue:
When the server just started and people are joining, some of those people tend to be renamed
to one of the botnames.. :/
Any chance you can fix this? It's really annoying :s

Thanks
I can confirm this.
Though, it doesn't happen often and having the player reconnect fixes the issue.

Last edited by depthbomb; 07-19-2014 at 16:25.
depthbomb is offline
Vastrix
Senior Member
Join Date: Aug 2012
Location: Zion
Old 07-20-2014 , 04:49   Re: Automatic Bot Names
Reply With Quote #87

Quote:
Originally Posted by depthbomb View Post
I can confirm this.
Though, it doesn't happen often and having the player reconnect fixes the issue.
indeed
Vastrix is offline
micazoid
Veteran Member
Join Date: Oct 2010
Location: Munich - Germany
Old 10-28-2014 , 10:05   Re: Automatic Bot Names
Reply With Quote #88

Quote:
15:03:54 L 10/28/2014 - 15:03:53: [SM] Native "HookUserMessage" reported: Invalid message id supplied (-1)
15:03:54 L 10/28/2014 - 15:03:53: [SM] Displaying call stack trace for plugin "botnames.smx":
15:03:54 L 10/28/2014 - 15:03:53: [SM] [0] Line 404, /home/forums/content/files/6/7/6/9/6/129832.attach::OnPluginStart()
15:03:54 [SM] The plugin list has been refreshed and reloaded.
The following fixes this Plugin for Day of Defeat Source:

Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma unused cvarVersion

#define PLUGIN_VERSION "1.0"
#define PLUGIN_DESCRIPTION "Gives automatic names to bots on creation."
#define BOT_NAME_FILE "configs/botnames.txt"

// this array will store the names loaded
new Handle:bot_names;

// this array will have a list of indexes to
// bot_names, use these in order
new Handle:name_redirects;

// this is the next index to use into name_redirects
// update this each time you use a name
new next_index;

// various convars
new Handle:cvarVersion; // version cvar!
new Handle:cvarEnabled; // are we enabled?
new Handle:cvarPrefix; // bot name prefix
new Handle:cvarRandom; // use random-order names?
new Handle:cvarAnnounce; // announce new bots?
new Handle:cvarSuppress; // supress join/team/namechange messages?

public Plugin:myinfo =
{
	name = "Bot Names",
	author = "Rakeri",
	description = PLUGIN_DESCRIPTION,
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?p=1054057"
}

// a function to generate name_redirects
GenerateRedirects()
{
	new loaded_names = GetArraySize(bot_names);

	if (name_redirects != INVALID_HANDLE)
	{
		ResizeArray(name_redirects, loaded_names);
	} else {
		name_redirects = CreateArray(1, loaded_names);
	}

	for (new i = 0; i < loaded_names; i++)
	{
		SetArrayCell(name_redirects, i, i);
		
		// nothing to do random-wise if i == 0
		if (i == 0)
		{
			continue;
		}

		// now to introduce some chaos
		if (GetConVarBool(cvarRandom))
		{
			SwapArrayItems(name_redirects, GetRandomInt(0, i - 1), i);
		}
	}
}

// a function to load data into bot_names
ReloadNames()
{
	next_index = 0;
	decl String:path[PLATFORM_MAX_PATH];
	BuildPath(Path_SM, path, sizeof(path), BOT_NAME_FILE);
	
	if (bot_names != INVALID_HANDLE)
	{
		ClearArray(bot_names);
	} else {
		bot_names = CreateArray(MAX_NAME_LENGTH);
	}
	
	new Handle:file = OpenFile(path, "r");
	if (file == INVALID_HANDLE)
	{
		//PrintToServer("bot name file unopened");
		return;
	}
	
	// this LENGTH*3 is sort of a hack
	// don't make long lines, people!
	decl String:newname[MAX_NAME_LENGTH*3];
	decl String:formedname[MAX_NAME_LENGTH];
	decl String:prefix[MAX_NAME_LENGTH];

	GetConVarString(cvarPrefix, prefix, MAX_NAME_LENGTH);

	while (IsEndOfFile(file) == false)
	{
		if (ReadFileLine(file, newname, sizeof(newname)) == false)
		{
			break;
		}
		
		// trim off comments starting with // or #
		new commentstart;
		commentstart = StrContains(newname, "//");
		if (commentstart != -1)
		{
			newname[commentstart] = 0;
		}
		commentstart = StrContains(newname, "#");
		if (commentstart != -1)
		{
			newname[commentstart] = 0;
		}
		
		new length = strlen(newname);
		if (length < 2)
		{
			// we loaded a bum name
			// (that is, blank line or 1 char == bad)
			//PrintToServer("bum name");
			continue;
		}

		// get rid of pesky whitespace
		TrimString(newname);
		
		Format(formedname, MAX_NAME_LENGTH, "%s%s", prefix, newname);
		PushArrayString(bot_names, formedname);
	}
	
	CloseHandle(file);
}

// called when the plugin loads
public OnPluginStart()
{
	// cvars!
	cvarVersion = CreateConVar("sm_botnames_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_PLUGIN | FCVAR_DONTRECORD);
	cvarEnabled = CreateConVar("sm_botnames_enabled", "1", "sets whether bot naming is enabled", FCVAR_NOTIFY | FCVAR_PLUGIN);
	cvarPrefix = CreateConVar("sm_botnames_prefix", "", "sets a prefix for bot names (include a trailing space, if needed!)", FCVAR_NOTIFY | FCVAR_PLUGIN);
	cvarRandom = CreateConVar("sm_botnames_random", "1", "sets whether to randomize names used", FCVAR_NOTIFY | FCVAR_PLUGIN);
	cvarAnnounce = CreateConVar("sm_botnames_announce", "1", "sets whether to announce bots when added", FCVAR_NOTIFY | FCVAR_PLUGIN);
	cvarSuppress = CreateConVar("sm_botnames_suppress", "1", "sets whether to supress join/team change/name change bot messages", FCVAR_NOTIFY | FCVAR_PLUGIN);
	
	// hook team change, connect to supress messages
	HookEvent("player_connect", Event_PlayerConnect, EventHookMode_Pre);
	HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre);

	// trickier... name changes are user messages, so...
	HookUserMessage(GetUserMessageId("SayText"), UserMessage_SayText2, true);

	// register our commands
	RegServerCmd("sm_botnames_reload", Command_Reload);

	AutoExecConfig();
}

public OnMapStart()
{
	ReloadNames();
	GenerateRedirects();
}

// reload bot name, via console
public Action:Command_Reload(args)
{
	ReloadNames();
	GenerateRedirects();
	PrintToServer("[botnames] Loaded %i names.", GetArraySize(bot_names));
}

// handle client connection, to change the names...
public OnClientPostAdminCheck(client)
{
	new loaded_names = GetArraySize(bot_names);

	if (IsFakeClient(client) && loaded_names != 0)
	{
		// we got a bot, here, boss
		
		decl String:newname[MAX_NAME_LENGTH];
		GetArrayString(bot_names, GetArrayCell(name_redirects, next_index), newname, MAX_NAME_LENGTH);

		next_index++;
		if (next_index > loaded_names - 1)
		{
			next_index = 0;
		}
		
		SetClientInfo(client, "name", newname);
		if (GetConVarBool(cvarAnnounce))
		{
			PrintToChatAll("[botnames] Bot %s created.", newname);
			PrintToServer("[botnames] Bot %s created.", newname);
		}
	}
	
}

// handle "SayText2" usermessages, including name change notifies!
public Action:UserMessage_SayText2(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
	if (!(GetConVarBool(cvarEnabled) && GetConVarBool(cvarSuppress)))
	{
		return Plugin_Continue;
	}

	decl String:message[256];

	BfReadShort(bf); // team color

	BfReadString(bf, message, sizeof(message));
	// check for Name_Change, not #TF_Name_Change (compatibility?)
	if (StrContains(message, "Name_Change") != -1)
	{
		BfReadString(bf, message, sizeof(message)); // original
		BfReadString(bf, message, sizeof(message)); // new
		if (FindStringInArray(bot_names, message) != -1)
		{
			// 'tis a bot!
			return Plugin_Handled;
		}
	}

	return Plugin_Continue;
}

// handle player team change, to supress bot messages
public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (!(GetConVarBool(cvarEnabled) && GetConVarBool(cvarSuppress)))
	{
		return Plugin_Continue;
	}

	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if (client == 0)
	{
		// weird error, ignore
		return Plugin_Continue;
	}
	if (IsFakeClient(client))
	{
		// fake client == bot
		SetEventBool(event, "silent", true);
		return Plugin_Changed;
	}

	return Plugin_Continue;
}

// handle player connect, to supress bot messages
public Action:Event_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (!(GetConVarBool(cvarEnabled) && GetConVarBool(cvarSuppress)))
	{
		return Plugin_Continue;
	}

	decl String:networkID[32];
	GetEventString(event, "networkid", networkID, sizeof(networkID));

	if(!dontBroadcast && StrEqual(networkID, "BOT"))
	{
		// we got a bot connectin', resend event as no-broadcast
		decl String:clientName[MAX_NAME_LENGTH], String:address[32];
		GetEventString(event, "name", clientName, sizeof(clientName));
		GetEventString(event, "address", address, sizeof(address));

		new Handle:newEvent = CreateEvent("player_connect", true);
		SetEventString(newEvent, "name", clientName);
		SetEventInt(newEvent, "index", GetEventInt(event, "index"));
		SetEventInt(newEvent, "userid", GetEventInt(event, "userid"));
		SetEventString(newEvent, "networkid", networkID);
		SetEventString(newEvent, "address", address);

		FireEvent(newEvent, true);

		return Plugin_Handled;
	}

	return Plugin_Continue;
}
__________________

Last edited by micazoid; 10-29-2014 at 02:58.
micazoid is offline
sparkie951
Member
Join Date: Jul 2014
Old 11-21-2014 , 14:19   Re: Automatic Bot Names
Reply With Quote #89

Nice app, just found it... Works great on my Insurgency...

Just for fun for my conservative friends, I created a Political Bot Name List...
Attached Files
File Type: txt botnames.txt (256 Bytes, 303 views)

Last edited by sparkie951; 11-27-2014 at 16:48.
sparkie951 is offline
TomXPro
Senior Member
Join Date: Aug 2014
Location: Germany
Old 11-22-2014 , 14:00   Re: Automatic Bot Names
Reply With Quote #90

Quote:
Originally Posted by XHeadHunterX View Post
Any way to make this work on cs:go?
Does it work on CSGO?
TomXPro is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode