Raised This Month: $ Target: $400
 0% 

Bot not spawning in tf2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
flamingkirby
Junior Member
Join Date: Nov 2013
Old 11-24-2013 , 00:59   Bot not spawning in tf2
Reply With Quote #1

Hi, i looked at how people spawned bots at l4d2 as well as tf2 and i tried some of those ways but the bot is still not spawning. This is my code:

Code:
new entBot;

public OnMapStart()
{
	CreateTimer(1.0, spawnBot);
}

public Action:spawnBot(Handle:timer)
{
	entBot = CreateFakeClient("Bot Player");
	ChangeClientTeam(entBot, 2);
	DispatchKeyValue(entBot,"classname","bot");
	DispatchSpawn(entBot);
}
This still does not spawn a bot, if someone can please help me then that would be appreciated thanks. One last part of information, this is for arena mode so not sure if that has any effect but if it does then maybe some information on how to fix this?

Kind of new to sourcemod, started a few days ago and trying to spawn one bot on the server. I only showed the part of the code which spawns the bot, the rest is not necessary. I included all the files i need to use these functions but when i spawn, the bot does not. It shows that the bot is in the server but just never spawns =/.

Thanks if you can help me =).
__________________
flamingkirby is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-24-2013 , 04:48   Re: Bot not spawning in tf2
Reply With Quote #2

Whoa, either bots created using CreateFakeClient are mega-glitchy, or some more stuff needs to be prepared on the bot first (even if you set their class and TF2_RespawnPlayer); there's tons of problems I see from just a few moments of testing, like when I kill it, the kill feed reports a suicide of my own, and they can only be backstabbed from the front...

I suggest just using ServerCommand("sv_cheats 1; bot; sv_cheats 0"); -- It's hacky, but it works, and should be safe. You can also specify -name, -class, and -team using that command.

Also, OnMapStart is way too soon to be adding a bot if the plugin isn't late-loaded. Create an event hook for teamplay_round_start instead.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 11-24-2013 at 04:49.
MasterOfTheXP is offline
flamingkirby
Junior Member
Join Date: Nov 2013
Old 11-24-2013 , 06:58   Re: Bot not spawning in tf2
Reply With Quote #3

Ok, thanks. Will try that soon.
__________________
flamingkirby is offline
flamingkirby
Junior Member
Join Date: Nov 2013
Old 11-25-2013 , 02:47   Re: Bot not spawning in tf2
Reply With Quote #4

Ok, so i am using this command ->
Code:
ServerCommand("sv_cheats 1; bot -name %s -team %s; sv_cheats 0", "Test name", "red");
The only problem is that it does not say 'Test name' but just 'Test' as the name. Does anyone know how to fix this but also how to get the identity of the bot? I tried this to find the id of the bot but it does not print anything =(
__________________

Last edited by flamingkirby; 11-25-2013 at 02:48.
flamingkirby is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-25-2013 , 02:54   Re: Bot not spawning in tf2
Reply With Quote #5

Quote:
Originally Posted by flamingkirby View Post
The only problem is that it does not say 'Test name' but just 'Test' as the name. Does anyone know how to fix this but also how to get the identity of the bot? I tried this to find the id of the bot but it does not print anything =(
Try changing -name %s to -name \"%s\"

To grab the ID of the bot, make a global variable (AddingBot or something), set it to true when you're using the bot command, and then...
PHP Code:
public OnClientPutInServer(client)
{
    if (!
AddingBot) return;
    if (!
IsFakeClient(client)) return;
    
PrintToChatAll("Added bot with player index %i - %N"clientclient);
    
AddingBot false;

You may also want to cancel AddingBot 1 second after using the bot command, as it could fail (due to not having a player slot free), although getting the output of the command using ServerCommandEx might work (much) better.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 11-25-2013 at 02:57.
MasterOfTheXP is offline
flamingkirby
Junior Member
Join Date: Nov 2013
Old 11-25-2013 , 03:44   Re: Bot not spawning in tf2
Reply With Quote #6

Thanks for contributing and helping me . Planning on making plugins specific for dodgeball like humans vs bots which may seem quite tough to do but the bots will not be impossible to kill, they change their skill depending on the players in the server. That will be at a much later time. Right now using this bot to make a dodgeball bot which is somewhat impossible to kill hopefully and adding a skill system (seperate to the db bot) but also dodgeball bot specific. This was what i used for grabbing the id of the bot but did not print anything on screen -
Code:
public getBotID()
{
	new name[32];
	for(new i = 0; i <= MaxClients; i++)
	{
		if(IsFakeClient(i))
		{
			botID = i;
		}
	}
	GetClientName(botID, name, 32);
	PrintToChatAll("%s", name);
}
Oh well, will get better at using source pawn sooner or later .

One last thing if you happen to come across this post again or someone else, anyone really is welcome to post here .

My last problem is with the event object_deflected. It is default set to post and when the rocket first fires from the spawn in dodgeball and the bot or me airblasts, the event is not fired but when the bot or me airblasts it the second time, the event is fired. I am not sure why and tried researching about this event and how it works but nothing came up. I know the ownerid is nothing as it is from a spawn but the userid should work on the first deflection but seems to not as i have PrintToChatAll to see who the userid is to confirm it is not printing anything on first deflection.

That is all, thanks again .
__________________
flamingkirby is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-25-2013 , 05:13   Re: Bot not spawning in tf2
Reply With Quote #7

A few things with that function:
  • Remember, you can use %N in format functions (anything with any:... after a string parameter) -- much better than needing to make a new string, use GetClientName, and then printing that string. Also, the max name length could change at any time, so using 32 for name array size instead of MAX_NAME_LENGTH(+1?) is taboo.
  • IsFakeClient will error if it is checked on a non-connected client. Throw an if (!IsClientInGame(i)) continue; above it.
  • 0 is always the server console, and pretty much anything to check on clients (including IsClientInGame) will error if used on 0. Start the loop at 1.
  • Since there is only one bot for now, consider using break; after getting the bot index so you don't needlessly loop through the remaining player slots.
  • SourceTV and Replay count as bots, so you might want to check IsClientSourceTV and IsClientReplay too. But that's not important if you're not gonna use those, especially not right now
As for the deflection thing, that might be an issue with the dodgeball plugin you're using; maybe m_iDeflected is at a weird value, and that's blocking the event the first time around? No idea.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-25-2013 , 07:33   Re: Bot not spawning in tf2
Reply With Quote #8

Why don't you just use normal bots and mod their behavior with prethink or runcmd?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
flamingkirby
Junior Member
Join Date: Nov 2013
Old 11-27-2013 , 01:34   Re: Bot not spawning in tf2
Reply With Quote #9

I am just using the bot command because then i have no AI inside the bot, when i used tf_bot_add and change their name, they keep changing their name, i find the bot command alright for my purpose and later i can modify how they do things without predefined AI affecting the outcome. May look into prethink, have not heard about that one yet .
__________________
flamingkirby 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 17:33.


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