Revision Difference
player.CreateNextBot#512666
<function name="CreateNextBot" parent="player" type="libraryfunc">⤶
	<description>⤶
Similar to the serverside command "bot", this function creates a new Player bot with the given name. This bot will not obey to the usual "bot_*" commands, and it's the same bot base used in TF2 and CS:S.⤶
⤶
The best way to control the behaviour of a Player bot right now is to use the <page>GM:StartCommand</page> hook and modify its input serverside.⤶
⤶
<note>Despite this Player being fake, it has to be removed from the server by using <page>Player:Kick</page> and **NOT** <page>Entity:Remove</page>.⤶
Also keep in mind that these bots still use player slots, so you won't be able to spawn them in singleplayer!</note>⤶
⤶
<note>Any Bot created using this method will be considered UnAuthed by Garry's Mod</note>⤶
	</description>⤶
	<realm>Server</realm>⤶
	<args>⤶
		<arg name="botName" type="string">The name of the bot, using an already existing name will append brackets at the end of it with a number pertaining it.

Example: "Bot name test", "Bot name test(1)".</arg>⤶
	</args>⤶
	<rets>⤶
		<ret name="" type="Player">The newly created Player bot. Returns NULL if there's no Player slots available to host it.</ret>⤶
	</rets>⤶
</function>⤶
⤶
<example>⤶
	<description>Create a bot if that is possible.</description>⤶
	<code>⤶
local listBots = {}⤶
⤶
function CreateBot()⤶
⤶
    if ( !game.SinglePlayer() && player.GetCount() &lt; game.MaxPlayers() ) then ⤶
⤶
        local num = #listBots⤶
⤶
        listBots[ num ] = player.CreateNextBot("Bot_" .. ( num + 1 ) )⤶
⤶
	    return listBots[ num ]⤶
⤶
    else⤶
⤶
	    print( "Can't create bot!" )⤶
⤶
    end⤶
⤶
end⤶
	</code>⤶
⤶
</example>
 Garry's Mod
			Garry's Mod 
		 Rust
			Rust 
		 Steamworks
			Steamworks 
		 Wiki Help
			Wiki Help